Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 1.48 KB

SPARQList_lineage.md

File metadata and controls

65 lines (50 loc) · 1.48 KB

Taxonomic hierarchy

Stanza version

Code

Get text version of this API results

Parameters

  • tax taxonomy ID
    • default: 9606
    • example: 9606, 31033

Endpoint

http://togogenome.org/sparql

result SPARQL query

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX taxo: <http://ddbj.nig.ac.jp/ontologies/taxonomy#>
PREFIX taxid: <http://identifiers.org/taxonomy/>
SELECT
  (REPLACE(STR(?tax), "http://identifiers.org/taxonomy/", "") AS ?tax_id)
  ?tax_label
  ?step
FROM <http://togogenome.org/graph/taxonomy>
WHERE {
  ?search_tax rdfs:label ?o FILTER (?search_tax = taxid:{{tax}}) .
  ?search_tax rdfs:subClassOf ?tax OPTION (transitive, t_direction 1, t_min(0), t_step("step_no") as ?step) .
  ?tax rdfs:label ?tax_label .
  FILTER (?tax != taxid:1)
}
ORDER BY DESC(?step)

output JSON transformation

({
  json({result}) {
    return result.results.bindings.map((row) => {
      const taxid = row.tax_id.value;
      const label = row.tax_label.value;
      return [taxid, label];
    });
  },
  text({result}) {
    return result.results.bindings.map((row) => {
      const taxid = row.tax_id.value;
      const label = row.tax_label.value;
      return label + " (" + taxid + ")"
    }).join(" / ");
  }
})