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

Latest hp.owl fails due to SynonymTypeProperty w/o label with AttributeError: 'NoneType' object has no attribute 'text' #176

Closed
davmlaw opened this issue Jun 21, 2022 · 1 comment
Labels
bug Issues or pull requests that specify a bug. fixed Issues which bug was fixed in subsequent commits.

Comments

@davmlaw
Copy link
Contributor

davmlaw commented Jun 21, 2022

If elem.find returns None it fails as the test is against the .text value not the return from find, ie:

/usr/local/lib/python3.8/dist-packages/pronto/parsers/rdfxml.py in parse_from(self, handle, threads)
    113                 self._extract_object_property(prop, curies)
    114             for prop in tree.iterfind(_NS["owl"]["AnnotationProperty"]):
--> 115                 self._extract_annotation_property(prop, curies)
    116             for class_ in tree.iterfind(_NS["owl"]["Class"]):
    117                 self._extract_term(class_, curies)

/usr/local/lib/python3.8/dist-packages/pronto/parsers/rdfxml.py in _extract_annotation_property(self, elem, curies)
    666             if resource == _NS["oboInOwl"].raw("SynonymTypeProperty"):
    667                 # extract ID and label of the synonymtypedef
--> 668                 label = elem.find(_NS["rdfs"]["label"]).text
    669                 if label is None:
    670                     label = ""

AttributeError: 'NoneType' object has no attribute 'text'

File from:

https://raw.githubusercontent.com/obophenotype/human-phenotype-ontology/master/hp.owl

I have been able to reproduce with a test file that contains:

    <owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/caloha-reqs-vetted#PLURAL">
        <rdfs:subPropertyOf rdf:resource="http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty"/>
    </owl:AnnotationProperty>

I fixed it locally by moving the test onto the element returned from find rather than element.text ie

                label_element = elem.find(_NS["rdfs"]["label"])
                if label_element:
                    label = label_element.text
                else:
                    label = ""
                    warnings.warn(
                        "`oboInOwl:SynonymTypeProperty` element has no label",
                        SyntaxWarning,
                        stacklevel=3,
                    )
@althonos althonos added bug Issues or pull requests that specify a bug. fixed Issues which bug was fixed in subsequent commits. labels Jun 28, 2022
@althonos
Copy link
Owner

Closed in #179 (thanks again).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or pull requests that specify a bug. fixed Issues which bug was fixed in subsequent commits.
Projects
None yet
Development

No branches or pull requests

2 participants