[bioontology-support] [BioPortal] Feedback from marwa811

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[bioontology-support] [BioPortal] Feedback from marwa811

support

Name: marwa811

Email: [hidden email]

Location: https%3A%2F%2Fbioportal.bioontology.org%2Fhelp


Feedback:

Hi,
I am using your API for retrieving data about Bioportal ontologies. https://github.com/ncbo/ncbo_rest_sample_code/blob/master/java/src/ListOntologies.java
This example is efficient and simple and outputs a list of the ontologies' names and ids. I also need to output the categories (Domains) for each ontology. Could you guide me (with code snippet) on how to make this?
Regards,
Marwa


_______________________________________________
bioontology-support mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/bioontology-support
Reply | Threaded
Open this post in threaded view
|

Re: [bioontology-support] [BioPortal] Feedback from marwa811

Michael Dorf
Hi Marwa,

Thank you for contacting us. I don’t have a working Java environment setup to test my recommendation (we are a Ruby/Rails shop), but since you are already have a working code that retrieves the ontologies, you only need to add a parameter “display=…” for the REST service to bring in the list of categories (domains) for each ontology. Your code should look like this:

// Follow the ontologies link by looking for the media type in the list of links
String link = resources.get("links").findValue("ontologies").asText();
link += "?display=acronym,name,summaryOnly,flat,ontologyType,hasDomain";

Then, as you iterate over the ontologies, you should be able to do something like this:

for (JsonNode ontology : ontologies) {
ontNames.add(ontology.get(
"name").asText() + "\n" + ontology.get("@id").asText() + "\n\n");
ArrayList<String> categories = (new ObjectMapper()).convertValue(ontology.get("hasDomain"), ArrayList.class);

I don’t know if this exact code works as written, but you should be able to tweak it to a working version.

Hope this helps.

Michael



On Aug 30, 2020, at 5:23 PM, [hidden email] wrote:

Name: marwa811

[hidden email]

Location: https%3A%2F%2Fbioportal.bioontology.org%2Fhelp


Feedback:

Hi,
I am using your API for retrieving data about Bioportal ontologies. https://github.com/ncbo/ncbo_rest_sample_code/blob/master/java/src/ListOntologies.java
This example is efficient and simple and outputs a list of the ontologies' names and ids. I also need to output the categories (Domains) for each ontology. Could you guide me (with code snippet) on how to make this?
Regards,
Marwa


_______________________________________________
bioontology-support mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/bioontology-support


_______________________________________________
bioontology-support mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/bioontology-support
Reply | Threaded
Open this post in threaded view
|

Re: [bioontology-support] [BioPortal] Feedback from marwa811

Michael Dorf
Thank you for sharing this, Marwa, that’s a very useful code snippet!  I'm CCing this to the support list in case someone on it searches for a solution to a similar issue.

Michael


On Aug 31, 2020, at 4:42 PM, Marwa Hussein <[hidden email]> wrote:

Thanks Micheal your reply was very useful to me I managed to get the categories with just very simple lines of code
    JsonNode categories = jsonToNode(get(ontology.get("links").get("categories").asText()));      
        ArrayList<String> categoryList = new ArrayList<String>();
          for (JsonNode category : categories) {
         if (!category.get("acronym").isNull()) {
         categoryList.add(category.get("acronym").asText() +"\n");
         }
          }
Regards,
Marwa

From: Michael Dorf <[hidden email]>
Sent: Monday, August 31, 2020 11:39 PM
To: [hidden email] <[hidden email]>
Cc: Marwa Hussein <[hidden email]>
Subject: Re: [bioontology-support] [BioPortal] Feedback from marwa811
 
Hi Marwa,

Thank you for contacting us. I don’t have a working Java environment setup to test my recommendation (we are a Ruby/Rails shop), but since you are already have a working code that retrieves the ontologies, you only need to add a parameter “display=…” for the REST service to bring in the list of categories (domains) for each ontology. Your code should look like this:

// Follow the ontologies link by looking for the media type in the list of links
String link = resources.get("links").findValue("ontologies").asText();
link += "?display=acronym,name,summaryOnly,flat,ontologyType,hasDomain";

Then, as you iterate over the ontologies, you should be able to do something like this:

for (JsonNode ontology : ontologies) {
ontNames.add(ontology.get(
"name").asText() + "\n" + ontology.get("@id").asText() + "\n\n");
ArrayList<String> categories = (new ObjectMapper()).convertValue(ontology.get("hasDomain"), ArrayList.class);

I don’t know if this exact code works as written, but you should be able to tweak it to a working version.

Hope this helps.

Michael



On Aug 30, 2020, at 5:23 PM, [hidden email] wrote:

Name: marwa811 
Location: https%3A%2F%2Fbioportal.bioontology.org%2Fhelp

Feedback:
Hi, 
I am using your API for retrieving data about Bioportal ontologies. https://github.com/ncbo/ncbo_rest_sample_code/blob/master/java/src/ListOntologies.java 
This example is efficient and simple and outputs a list of the ontologies' names and ids. I also need to output the categories (Domains) for each ontology. Could you guide me (with code snippet) on how to make this? 
Regards, 
Marwa

_______________________________________________
bioontology-support mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/bioontology-support


_______________________________________________
bioontology-support mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/bioontology-support