owlcollab / owltools

OWLTools
BSD 3-Clause "New" or "Revised" License
108 stars 33 forks source link

getIdentifier should work with non-obolibrary PURLs (required for solr loading) #245

Closed cmungall closed 6 years ago

cmungall commented 6 years ago

OWLGraphWrapperExtended

    /**
     * gets the OBO-style ID of the specified object. E.g. "GO:0008150"
     * 
     * @param iriId
     * @return OBO-style identifier, using obo2owl mapping
     */
    public String getIdentifier(IRI iriId) {
        return Owl2Obo.getIdentifier(iriId);
    }

Instead it should:

  1. Check if the IRI starts with the obolib prefix, if yes, use Owl2Obo.getIdentifier
  2. If no, check if oboInOw#id is present. if so, use it

In future we may also want the ability to use prefixcommons curie util to do this in a custom way

cmungall commented 6 years ago

Test case:

Prefix: GO: <http://purl.obolibrary.org/obo/GO_>
Prefix: x <http://example.org/>
Prefix: oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>

Ontology: <http://purl.obolibrary.org/obo/test>

AnnotationProperty: oboInOwl:id

Class: GO:0000001
    Annotations:
        rdfs:label "test1"

Class: GO:0000002
    Annotations:
        rdfs:label "test2",
        oboInOwl:id "FAKE:1234"

Class: x:005
    Annotations:
        rdfs:label "test3",
        oboInOwl:id "X:5"

The IDs should be GO:0000001, GO:0000002, X:5

cmungall commented 6 years ago

One more test

Class: x:010
    Annotations:
        rdfs:label "test4"

should preserve URL

cmungall commented 6 years ago

@yy20716 can you add one more test, as above?

yy20716 commented 6 years ago

Thank you for your reminder. I added that case in this pull request.

yy20716 commented 6 years ago

I guess this issue can be closed but please let me know if you encounter any other problems. Thank you.

kltm commented 6 years ago

Looking good so far.