althonos/pronto

Adding annotations to synonym type declarations yields KeyError: '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}resource

Opened this issue · 1 comments

<?xml version="1.0"?>
<rdf:RDF xmlns="http://purl.obolibrary.org/obo/ncbitaxon.owl#"
     xml:base="http://purl.obolibrary.org/obo/ncbitaxon.owl"
     xmlns:OMO="http://purl.obolibrary.org/obo/OMO_"
     xmlns:obo="http://purl.obolibrary.org/obo/"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:terms="http://purl.org/dc/terms/"
     xmlns:oboInOwl="http://www.geneontology.org/formats/oboInOwl#"
     xmlns:NCBITaxon="http://purl.obolibrary.org/obo/NCBITaxon_"
     xmlns:ncbitaxon="http://purl.obolibrary.org/obo/ncbitaxon#">
    <owl:Ontology rdf:about="http://purl.obolibrary.org/obo/ncbitaxon.owl">
    </owl:Ontology>
    


    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Annotation properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->


    
    <!-- http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty -->
    <owl:AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty"/>

    <!-- http://www.geneontology.org/formats/oboInOwl#hasScope -->
    <owl:AnnotationProperty rdf:about="http://www.geneontology.org/formats/oboInOwl#hasScope">
        <rdfs:label>has scope</rdfs:label>    
    </owl:AnnotationProperty>

    <!-- http://purl.obolibrary.org/obo/ncbitaxon#genbank_synonym -->

    <owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/ncbitaxon#genbank_synonym">
        <oboInOwl:hasScope>oio:hasRelatedSynonym</oboInOwl:hasScope>
        <rdfs:label>genbank synonym</rdfs:label>
        <rdfs:subPropertyOf rdf:resource="http://www.geneontology.org/formats/oboInOwl#SynonymTypeProperty"/>
    </owl:AnnotationProperty>
    

</rdf:RDF>

gives

  File "/Users/cjm/repos/ontology-access-kit/src/oaklib/implementations/pronto/pronto_implementation.py", line 177, in __post_init__
    ontology = Ontology(str(resource.local_path), **kwargs)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/ontology.py", line 283, in __init__
    cls(self).parse_from(_handle)  # type: ignore
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/parsers/rdfxml.py", line 115, in parse_from
    self._extract_annotation_property(prop, curies)
  File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/pronto/parsers/rdfxml.py", line 699, in _extract_annotation_property
    scope = _SYNONYMS.get(elem_scope.attrib[_NS["rdf"]["resource"]])
KeyError: '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}resource'

Okay that's because I was assuming the scope would be given as an IRI and a rdf:resource attribute:

<oboInOwl:hasScope rdf:resource="http://www.geneontology.org/formats/oboInOwl#hasRelatedSynonym"/>

I'll update the parser to fall back to a warning but I think that may also be a weird serialization from your end 👍