ncbo / ontologies_api

Hypermedia API for NCBO's ontology-related projects
http://data.bioontology.org
Other
25 stars 10 forks source link

How to get a list of all ontologies (title, URI, file) available on your service? (REST or data dump) #138

Closed k00ni closed 4 months ago

k00ni commented 5 months ago

Hello, I hope I am at the right place.

Is there a way to get the same list of the ontologies which I can browse at https://bioportal.bioontology.org/ontologies in a major file format (e.g. CSV, JSON,...)? Per ontology I am looking for the title, URI and a file URL (to download RDF). I checked https://data.bioontology.org/documentation but couldn't find any appropriate REST method to accomplish that.

Here is an example of a service, called Linked Open Vocabularies (https://lov.linkeddata.es/dataset/lov), which provides an ontology list via the REST API: https://lov.linkeddata.es/dataset/lov/api/v2/vocabulary/list

My current workaround would be to parse the HTML of https://bioportal.bioontology.org/ontologies and for each ontology entity check related page, such as https://bioportal.bioontology.org/ontologies/SNOMEDCT. But that seems a bit too much for this.

Thanks for your response.

jvendetti commented 5 months ago

Hi @k00ni - just for future reference, we prefer that questions regarding API usage are posted to our support list (support@bioontology.org). Thanks!

I'm wondering what you mean by URI? Are you talking about the ontology IRI in the ontology source file? Or the URI of the ontology in BioPortal? If you mean the ontology IRI, we don't currently store that information. However, we're actively working on adding that functionality and it should be available soon - roughly within the next month.

You can use a REST call like the following to see the list of ontologies with their names:

http://data.bioontology.org/ontologies?include=name,acronym&display_context=false&display_links=false

A snippet of the resulting JSON:

[
    {
        "name": "LinkML Common Metadata Elements and Terms",
        "acronym": "COMET",
        "@id": "https://data.bioontology.org/ontologies/COMET",
        "@type": "http://data.bioontology.org/metadata/Ontology"
    },
    {
        "name": "Homo sapiens Chromosomal Location Ontology for GRCh38",
        "acronym": "HSCLO38",
        "@id": "https://data.bioontology.org/ontologies/HSCLO38",
        "@type": "http://data.bioontology.org/metadata/Ontology"
    },
    {
        "name": "eDEM-Connect: Ontology of Dementia-related Agitation and Relationship between Informal Caregivers and Persons with Dementia",
        "acronym": "EDEM-CONNECTONTO",
        "@id": "https://data.bioontology.org/ontologies/EDEM-CONNECTONTO",
        "@type": "http://data.bioontology.org/metadata/Ontology"
    },
    {
        "name": "Taxonomy of Digital Research Activities in the Humanities",
        "acronym": "TADIRAH",
        "@id": "https://data.bioontology.org/ontologies/TADIRAH",
        "@type": "http://data.bioontology.org/metadata/Ontology"
    },

If you want to see a complete list of the attributes available for ontologies, you could issue a REST call like the following:

https://data.bioontology.org/ontologies?include=all

We don't offer a data dump of all the ontology source files in BioPortal. If you want to download the source file for a given ontology you can use the download endpoint, e.g., https://data.bioontology.org/ontologies/COMET/download. By default, this will give you the original source file. If you want a different format like CSV, you can modify the call to specify the format, e.g.,

https://data.bioontology.org/ontologies/COMET/download?download_format=csv https://data.bioontology.org/ontologies/COMET/download?download_format=rdf

k00ni commented 5 months ago

@jvendetti thank you for your detailed reply. I can't check your links right now, because I have no BioPortal account yet (therefore no api key), but the information you provided seem to be exactly what I want.

I'm wondering what you mean by URI? Are you talking about the ontology IRI in the ontology source file? Or the URI of the ontology in BioPortal? If you mean the ontology IRI, we don't currently store that information. However, we're actively working on adding that functionality and it should be available soon - roughly within the next month.

Most likely "ontology IRI", my mistake. I mean the same URI one would use to set the base URI of a RDF/Turtle file for instance:

@base <http://bag.basisregistraties.overheid.nl/def/bag> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<>
    a owl:Ontology ;
    rdfs:label "Basisregistraties adressen en gebouwen vocabulaire"@nl . 

(source)

Or the subject URI in the following triple:

<http://my-ontology.com/> a owl:Ontology .

Sometimes its the same as the related RDF file, sometimes its totally arbitrary and not even a real URI nor URL.

jvendetti commented 5 months ago

Hi @k00ni - there are some instructions for getting an API key here: https://www.bioontology.org/wiki/BioPortal_Help#Getting_an_API_key. Let us know if you have any issues with that.

I mean the same URI one would use to set the base URI of a RDF/Turtle file for instance: ...

OK, thanks for the clarification. As I mentioned above, the ontology IRI isn't quite available yet via our REST API, but it's coming soon.

k00ni commented 4 months ago

Thanks again for the feedback @jvendetti, my question was answered. I just created an account, grabbed the API key and started playing around with the API.

As I mentioned above, the ontology IRI isn't quite available yet via our REST API, but it's coming soon.

Is there a timetable? :) Where can I get more information after this is released? Ontology IRIs are essential data to me, so I am very surprised that they are not already part of the metadata.

jvendetti commented 4 months ago

Is there a timetable? :) Where can I get more information after this is released? Ontology IRIs are essential data to me, so I am very surprised that they are not already part of the metadata.

Hi @k00ni. The ontology IRIs are now available via the REST API (as of a production release on March 14th). They're stored in an attributed called uri on the OntologySubmission object.

Here's an example call to get the latest submission for the NCIT ontology:

https://data.bioontology.org/ontologies/NCIT/latest_submission?include=all&display_context=false&display_links=false

... and an abbreviated snippet of the returned JSON:

{
  "id": "https://data.bioontology.org/ontologies/NCIT/submissions/142",
  "submissionId": 142,

  "uri": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl",
}