SPARQL query for classification
After spidering uBio the next task is how to display the classification of a taxon. The following SPARQL query does the trick:
This query takes a canonical name in uBio, finds the display form, and from that the classification. The lines
fetch the lineage which is stored as a sequence:
This method of describing a taxonomic lineage was described in my paper in
Biodiversity Informatics
. uBio serves the lineage from lower to higher taxon (i.e., bottom up), but I want to display it top down. I do all display using XSLT style sheets, so we use the <xsl:sort order="descending"> trick (see here for an example). Then it's simply a case of indenting each node using <xsl:value-of select="18 * (position()-1)"/>, and borrowing uBio's end.png to get the tree effect.
PREFIX ubio: <urn:lsid:ubio.org:predicates:>
PREFIX gla: <urn:lsid:lsid.zoology.gla.ac.uk:predicates:>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?node, ?title, ?rank, ?name, ?description
WHERE {
<urn:lsid:ubio.org:namebank:2735665> gla:objectiveSynonym ?display .
?class ubio:namebankIdentifier ?display .
?class ubio:classificationName ?name
?class ubio:classificationDescription ?description .
?class gla:lineage ?seq .
?seq ?li ?node .
?node dc:title ?title .
?node gla:rank ?rank
}
This query takes a canonical name in uBio, finds the display form, and from that the classification. The lines
?class gla:lineage ?seq .
?seq ?li ?node .
fetch the lineage which is stored as a sequence:
<gla:lineage>
<rdf:Seq>
<rdf:li rdf:resource="urn:lsid:ubio.org:classificationbank:5178917"/>
<rdf:li rdf:resource="urn:lsid:ubio.org:classificationbank:5095531"/>
.
.
.
<rdf:li rdf:resource="urn:lsid:ubio.org:classificationbank:5131593"/>
</rdf:Seq>
</gla:lineage>
This method of describing a taxonomic lineage was described in my paper in
Biodiversity Informatics
. uBio serves the lineage from lower to higher taxon (i.e., bottom up), but I want to display it top down. I do all display using XSLT style sheets, so we use the <xsl:sort order="descending"> trick (see here for an example). Then it's simply a case of indenting each node using <xsl:value-of select="18 * (position()-1)"/>, and borrowing uBio's end.png to get the tree effect.
0 Comments:
Post a Comment
<< Home