Skip to end of metadata
Go to start of metadata

Searching a Specimen or Structure Tree

Each node of a Structure or Specimen tree includes a materialized path of its ancestors' id's. Both Structure.structure_id_path and Specimen.specimen_id_path are delimited by forward slashes ("/"). Use these flat data structures to find a node's ancestors or descendants.

Search for Descendants
Example

Use a multiple stage RMA request to search for the Human Brain Atlas ontology's hippocampal formation structure (HiF), and all of its descendants:

http://api.brain-map.org/api/v2/data/query.xml?criteria=
    model::Structure,rma::criteria,[acronym$eq'HiF'],ontology[abbreviation$eq'Human'],
    pipe::list[path$eq'structure_id_path'],
    pipe::replace[pattern$eq'$'][replacement$eq'*'][input$in$path][output$eq'descendants'],
    model::Structure,rma::criteria,[structure_id_path$il$descendants],ontology[abbreviation$eq'Human']
Notes
  • The first model::Structure stage searches for the Structure instance.
  • pipe::list stage defines a "path" variable and assigns the Structure.structure_id_path value to it.
  • The pipe::replace stage is used to append the wildcard (star) to the end of the path variable and assign it to the "descendants" variable.
  • The final model::Structure stage searches for the descendants of HiF by matching the beginning of their structure_id_path values to the path variable.
Search for Ancestors
Example

Search for the Human Brain Atlas ontology's hippocampal formation structure (HiF) and all of its ancestors:

http://api.brain-map.org/api/v2/data/query.xml?criteria=
    model::Structure,rma::criteria,[acronym$eq'HiF'],ontology[abbreviation$eq'Human'],
    pipe::list[path$eq'structure_id_path'],
    pipe::replace[pattern$eq'(^\/)|(\/$)'][replacement$eq''][input$in$path][output$eq'path'],
    pipe::split[pattern$eq'/'][input$in$path][output$eq'ancestors'],
    model::Structure,rma::criteria,[id$in$ancestors],ontology[abbreviation$eq'Human']
Notes
  • The first model::Structure stage searches for the Structure instance.
  • pipe::list stage defines a "path" variable and assigns Structure.structure_id_path to it.
  • The pipe::replace stage is used to remove the leading and trailing forward slashes from path.
  • pipe::split splits the path into an array and assigns that to the "ancestors" variable.
  • The final model::Structure stage searches for ancestors of HiF with the array of Structure.id.
  • No labels