EBISPOT / OLS

Ontology Lookup Service from SPOT at EBI
http://www.ebi.ac.uk/ols
Apache License 2.0
96 stars 40 forks source link

Properties and individuals #36

Open lgatto opened 8 years ago

lgatto commented 8 years ago

I am struggling with the properties and individual queries. If I use the example to query a term, that works fine

GET /api/ontologies/{ontology}/terms/{iri}

and

curl 'http://www.ebi.ac.uk/ols/beta/api/ontologies/go/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FGO_0043226' -i -H 'Accept: application/json'

and try to adapt it to properties or individuals, I get errors

% curl 'http://www.ebi.ac.uk/ols/beta/api/ontologies/go/properties/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FGO_0043226' -i -H 'Accept: application/json' 
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: application/json;charset=UTF-8
Date: Sun, 03 Jan 2016 16:55:07 GMT
Transfer-Encoding: chunked
Connection: close

{"timestamp":1451840107864,"status":500,"error":"Internal Server Error","exception":"java.lang.IllegalArgumentException","message":"Request processing failed; nested exception is java.lang.IllegalArgumentException: Content must not be null!"}
curl 'http://www.ebi.ac.uk/ols/beta/api/ontologies/go/individuals/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FGO_0043226' -i -H 'Accept: application/json'
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: application/json;charset=UTF-8
Date: Sun, 03 Jan 2016 16:55:26 GMT
Transfer-Encoding: chunked
Connection: close

{"timestamp":1451840126852,"status":500,"error":"Internal Server Error","exception":"java.lang.IllegalArgumentException","message":"Request processing failed; nested exception is java.lang.IllegalArgumentException: Content must not be null!"}

Any help would be very much appreciated.

lgatto commented 8 years ago

Here's probably a more correct example, where I want to search for the has_part property with id BFO:0000051

curl 'http://www.ebi.ac.uk/ols/beta/api/ontologies/go/properties/http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_0000051' -i -H 'Accept: application/json' 
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Date: Sun, 03 Jan 2016 22:59:22 GMT
Connection: close
Content-Length: 0

There is possibly progress, moving from an Internal Server Error to a Bad Request...

simonjupp commented 8 years ago

If you are using the term/property URI in the URL then you need to double URL encode the URI.

curl 'http://www.ebi.ac.uk/ols/beta/api/ontologies/go/properties/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000051' -i -H 'Accept: application/json' 

Any of these alternatives would also work depending on the type of id you have.

http://www.ebi.ac.uk/ols/beta/api/ontologies/go/properties?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_0000051 http://www.ebi.ac.uk/ols/beta/api/ontologies/go/properties?short_form=BFO_0000051 http://www.ebi.ac.uk/ols/beta/api/ontologies/go/properties?obo_id=BFO:0000051

I'll fix the error messages, it shouldn't be returning a 500.

lgatto commented 8 years ago

Thanks.

Is there a way to get all properties of an ontology, along the lines of GET /api/ontologies/{ontology_id}/terms? Or all properties associated with a term? It looks like config/definitionProperties and config/hierarchicalProperties would be were to look for this information, but I can't figure out where to go from there.

LLTommy commented 8 years ago

To get properties of an ontology, try api/ontologies/{ontology}/properties, so for example http://www.ebi.ac.uk/ols/beta/api/ontologies/aeo/properties should return all properties as json that are displayed if you browse to http://www.ebi.ac.uk/ols/beta/ontologies/aeo and click on "property view".

simonjupp commented 8 years ago

In addition, information on properties associated to a term are embedded as links in the JSON that comes back on a term.

See http://www.ebi.ac.uk/ols/beta/api/ontologies/uberon/terms?iri=http://purl.obolibrary.org/obo/UBERON_0002107 has part_of, develops_from etc links

lgatto commented 8 years ago

Thanks @LLTommy and @simonjupp, very helpful.

Regarding the embedded link properties, is there a way to tell property links form other links, other than excluding those that are clearly not, such as self, graph, jstree, children, descendants, parents, ancestors (and possibly others)? Are these other links properties or could they represent other features?

Or, another possibility would be to first extract all the properties in an ontology and then identify the property links in the term by matching the link names in the property labels.

simonjupp commented 8 years ago

That's a good point. There isn't a good way to distinguish these. I guess they are all relationships apart from /graph and /jstree. Both of these are alternate serialisations and shouldn't be an endpoint but rather something you access using a different content type.

I think I'll change this in the next release so that /graph and /jstree links are removed from the json output. Then all you have are true relationships as links.

lgatto commented 8 years ago

It would be useful to make sure it is easily possible to distinguish between links to terms (self, children, descendants, parents, ancestors) and links to properties. Maybe using

_links/terms/self
             /children
              ...

and

_links/properties/has_part
                 /part_of
                  ...

and then, possibly

_links/graphs/jstree
             /graph