GithubHelp home page GithubHelp logo

Comments (6)

jamesamcl avatar jamesamcl commented on September 3, 2024 2

The IDs used to be simple numbers in OLS3 but in OLS4 they are base64 strings. See:

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FPCO_0000031/jstree

[ {
  "id" : "aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx",
  "parent" : "#",
  "iri" : "http://purl.obolibrary.org/obo/PCO_0000031",
  "text" : "organismal entity",
  "state" : {
    "opened" : false,
    "selected" : true
  },
  "children" : true,
  "a_attr" : {
    "iri" : "http://purl.obolibrary.org/obo/PCO_0000031",
    "ontology_name" : "agro",
    "title" : "http://purl.obolibrary.org/obo/PCO_0000031",
    "class" : "is_a"
  },
  "ontology_name" : "agro"
}, {
  "id" : "aHR0cDovL3d3dy53My5vcmcvMjAwMi8wNy9vd2wjVGhpbmc=",
  "parent" : "#",
  "iri" : "http://www.w3.org/2002/07/owl#Thing",
  "text" : "Thing",
  "state" : {
    "opened" : true
  },
  "children" : false,
  "a_attr" : {
    "iri" : "http://www.w3.org/2002/07/owl#Thing",
    "ontology_name" : "agro",
    "title" : "http://www.w3.org/2002/07/owl#Thing",
    "class" : "is_a"
  },
  "ontology_name" : "agro"
} ]

Note the ID is aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx. So the correct URL for the children is:

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FPCO_0000031/jstree/children/aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx

which returns

[ {
  "id" : "aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMxO2h0dHA6Ly9wdXJsLm9ib2xpYnJhcnkub3JnL29iby9QQ09fMDAwMDAwMA==",
  "parent" : "aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx",
  "iri" : "http://purl.obolibrary.org/obo/PCO_0000000",
  "text" : "collection of organisms",
  "state" : {
    "opened" : false
  },
  "children" : true,
  "a_attr" : {
    "iri" : "http://purl.obolibrary.org/obo/PCO_0000000",
    "ontology_name" : "agro",
    "title" : "http://purl.obolibrary.org/obo/PCO_0000000",
    "class" : "is_a"
  },
  "ontology_name" : "agro"
} ]

This should be compatible with the unmodified tree widget code from OLS3 as we tested it at the time.

The numeric IDs were changed to be base64'd IRIs to ensure the same API call returns the same result every time (as the numbers were not order guaranteed).

from ols4.

Pooya-Oladazimi avatar Pooya-Oladazimi commented on September 3, 2024

@jamesamcl
Many thanks for the clarification.
But it would be nice to return an empty result set when a wrong id is given rather than raise a 500 server issue response code.

from ols4.

haideriqbal avatar haideriqbal commented on September 3, 2024

Thanks @jamesamcl for the clarification... in terms of response @Pooya-Oladazimi I believe returning a 404 error instead of an empty set would be a better approach here as the child being searched doesn't exist.

from ols4.

Pooya-Oladazimi avatar Pooya-Oladazimi commented on September 3, 2024

@jamesamcl @haideriqbal

I had a further look at this and noticed a problem with it.

As an example, look at this call that returns the jsTree for the term "generically dependent continuant" from AGRO ontology:
(frontend view: https://www.ebi.ac.uk/ols4/ontologies/agro/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000031)

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000031/jstree?viewMode=All&siblings=false

Now if you decode the base64 "parent" field:
aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL0JGT18wMDAwMDAxO2h0dHA6Ly9wdXJsLm9ib2xpYnJhcnkub3JnL29iby9CRk9fMDAwMDAwMg==

you get two Iris:
http://purl.obolibrary.org/obo/BFO_0000001;http://purl.obolibrary.org/obo/BFO_0000002

This is not correct since the term has only one parent and this one is a list of ancestors. Without a direct parent, tree building faces some issues.

The equivalent call in OLS3:
https://service.tib.eu/ts4tib/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000031/jstree?viewMode=All&siblings=false

from ols4.

jamesamcl avatar jamesamcl commented on September 3, 2024

The "parent" field indeed contains a base64 string of a concatenated list of ancestors, because that's the only way to uniquely identify the parent node (as the same class can appear multiple times in the tree if there are different paths to it through its ancestors, so just the immediate parent would not be enough).

You're not actually supposed to decode it, it's just a unique identifier for the parent node. In OLS3 numbers were generated (specifically, node IDs from neo4j), in OLS4 we use this string, but it still serves the same purpose.

This API was built to support the tree view widget: https://github.com/EBISPOT/ols-treeview so maybe looking at that code would be helpful

from ols4.

Pooya-Oladazimi avatar Pooya-Oladazimi commented on September 3, 2024

@jamesamcl

Thanks for the quick response. I was under the impression that that parent field is the parent node iri that I use to build a hierarchical list from this flat list. I get it now. Thanks again.

from ols4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.