Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] [BioPortal] Feedback from marwa811

Michael Dorf mdorf at
Thu Sep 3 09:09:41 PDT 2020

Hi Marwa,

No problem, we are here to help. I’ve looked at both ontologies that you’ve mentioned, and they each represent a different case.

IDO metrics API call ( returns and empty set with a status 200 (OK):

{ }

CST metrics API call ( returns an error with a status 404 (Not Found), which points to an existing ontology object that’s missing its core data (submission):


"errors": [
     *   "Ontology CST submission not found."
  *   "status": 404


You should have a handling in your code for each of these cases. You need to examine the metrics response object that you get for each ontology before making further calls on that object:

JsonNode ontologies = jsonToNode(get(link));

for (JsonNode ontology : ontologies) {
// put a breakpoint here and see what get(ontology.get("links").get("metrics").asText()) returns in each of these cases
// don’t automatically call jsonToNode() on the result, but instead handle each case individually

// alternatively, you can do try {} catch {} on these exceptions and skip the ontology if necessary
JsonNode metrics = null;

try {
metrics = jsonToNode(get(ontology.get("links").get("metrics").asText()));
} catch(FileNotFoundException e) {
// your code handling here for file not found
// ....
} catch(NullPointerException e) {
// your code handling here for null pointer exception
// ....
} catch(Exception e) {
// your code handling for all other exceptions
// ....
continue; // or exit or whatever

Keep in mind, these are just some ideas. My point is you should always examine the response of a call first and make a decision based on that response instead of making a blind call on that response.

Hope this gives you some pointers (vs NullPointers :-))


On Sep 1, 2020, at 3:51 PM, support at<mailto:support at> wrote:

Name: marwa811

Email: marwa.abdelrehem at<mailto:marwa.abdelrehem at>



I hope you are patient with me, since I am asking a lot in some "coding" details for Bioportal REST API.
Now I want to get "metrics" for any ontology. But what I discovered when running the code is that some ontologies don't have metrics link or file!! e.g. IDO and CST ontologies.
in this case, a file not found exception hits me "even if I am checking if the jsonnode object is null"
JsonNode metrics=null;
metrics = jsonToNode(get(ontology.get("links").get("metrics").asText()));

if(metrics != null)
String ontmetrics= "Classes: "+metrics.get("classes").asText() + "\n" ;
// Print out all the metrics
System.out.println("No available metrics for this ontology");
here the second line of the code throws the Filenotfound exception to handle this?

bioontology-support mailing list
bioontology-support at<mailto:bioontology-support at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the bioontology-support mailing list