Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension ownership relationships are not restored properly #368

Open
tcmitchell opened this issue Jul 24, 2020 · 2 comments
Open

Extension ownership relationships are not restored properly #368

tcmitchell opened this issue Jul 24, 2020 · 2 comments
Milestone

Comments

@tcmitchell
Copy link
Collaborator

If an RDF/XML SBOL file is loaded that contains ownership relationships those relationships are not restored. There is currently code in Document.parse_annotation_objects that heuristically tries to determine whether an extension/annotation object is a TopLevel by the existence of the SBOL_PERSISTENT_IDENTITY property. But that property is on Identified (per the code and the spec), not TopLevel.

Another approach might be to parse the XML and build a list of top level object URIs, and then use that list to determine which annotation objects (whose builder has not been registered) are TopLevel and which are not. From there we can determine that an annotation object is not top level, and thus if the object of the relationship is a URIRef it must be a parent/child relationship. We aren't sure this will work, but it is worth further exploration.

For users of the library a better workaround is to register extension classes so that relationships are properly constructed.

@tcmitchell
Copy link
Collaborator Author

Here is an example of pre-parsing the XML to extract the top level objects. This is a step in the right direction, but not sufficient. There is more that is needed. Also, elementtree is not a great solution if the XML files are going to be very large. One way they can be very large is an overly broad SynBioHub query. In that case SAX might be a more appropriate XML parsing strategy.

    def tag2uri(self, etree_tag):
        import re
        m = re.match('^{(.*)}(.*)$', etree_tag)
        if not m:
            return etree_tag
        return m[1] + m[2]

    def test_top_level_detection(self):
        import xml.etree.ElementTree as ET
        import rdflib
        rdf_about = f'{{{rdflib.namespace.RDF}}}about'
        tree = ET.parse(CRISPR_LOCATION)
        root = tree.getroot()
        top_level_identities = {}
        for child in root:
            identity = child.get(rdf_about)
            top_level_identities[identity] = self.tag2uri(child.tag)
        for k, v in top_level_identities.items():
            print(f'{k} => {v}')
        self.assertEqual(31, len(top_level_identities))

@jakebeal
Copy link
Collaborator

jakebeal commented Aug 4, 2020

Which milestone does this belong in?

@jakebeal jakebeal added this to the 1.2 milestone Aug 20, 2020
@tcmitchell tcmitchell modified the milestones: 1.2, Future Tasks Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants