Skip to content

Instantly share code, notes, and snippets.

@rdmpage
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdmpage/e1552e40451ac0474548 to your computer and use it in GitHub Desktop.
Save rdmpage/e1552e40451ac0474548 to your computer and use it in GitHub Desktop.
== Taxonomy tester - species and subspecies with same name
This test compares the epithets of species and subspecies in the same genus. If a subspecies with a given epithet exists in a genus, there should not be another species (other than the species to which subspecies belongs if it is the nominate subspecies).
This example uses the butterfly genus Heliopyrgus
//hide
//setup
//output
[source,cypher]
----
CREATE
(gbif1950649:taxon { name:"Heliopyrgus", rank:"GENUS", uninomial:"Heliopyrgus", authorship:"Herrera, 1957", accordingTo:"The Catalogue of Life, 3rd January 2011"}),
(gbif1950649)-[:HASPARENT]->(gbif6953),
(gbif1950651:taxon { name:"Heliopyrgus willi", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"willi", authorship:"Plötz, 1884", accordingTo:"Interim Register of Marine and Nonmarine Genera"}),
(gbif1950651)-[:HASPARENT]->(gbif1950649),
(gbif4301886:taxon { name:"Heliopyrgus sublinea", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"sublinea", authorship:" (Schaus, 1902)", accordingTo:"Integrated Taxonomic Information System"}),
(gbif4301886)-[:HASPARENT]->(gbif1950649),
(gbif1950653:taxon { name:"Heliopyrgus nearchus", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"nearchus", authorship:"Edwards, 1882", accordingTo:"Interim Register of Marine and Nonmarine Genera"}),
(gbif1950653)-[:HASPARENT]->(gbif1950649),
(gbif1950656:taxon { name:"Heliopyrgus margarita", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"margarita", authorship:"Bell, 1937", accordingTo:"Interim Register of Marine and Nonmarine Genera"}),
(gbif1950656)-[:HASPARENT]->(gbif1950649),
(gbif1950654:taxon { name:"Heliopyrgus domicella", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"domicella", authorship:"Erichson, 1848", accordingTo:"The Catalogue of Life, 3rd January 2011"}),
(gbif1950654)-[:HASPARENT]->(gbif1950649),
(gbif6203771:taxon { name:"Heliopyrgus domicella willi", rank:"SUBSPECIES", genusPart:"Heliopyrgus", epithet:"willi", authorship:"Plötz, 1884", accordingTo:"The Catalogue of Life, 3rd January 2011"}),
(gbif6203771)-[:HASPARENT]->(gbif1950654),
(gbif7215372:taxon { name:"Heliopyrgus domicella domicella", rank:"SUBSPECIES", genusPart:"Heliopyrgus", epithet:"domicella", authorship:"", accordingTo:"Integrated Taxonomic Information System"}),
(gbif7215372)-[:HASPARENT]->(gbif1950654),
(gbif6203772:taxon { name:"Heliopyrgus domicella margarita", rank:"SUBSPECIES", genusPart:"Heliopyrgus", epithet:"margarita", authorship:"Bell, 1937", accordingTo:"The Catalogue of Life, 3rd January 2011"}),
(gbif6203772)-[:HASPARENT]->(gbif1950654),
(gbif1950655:taxon { name:"Heliopyrgus bellatrix", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"bellatrix", authorship:"Plötz, 1884", accordingTo:"Interim Register of Marine and Nonmarine Genera"}),
(gbif1950655)-[:HASPARENT]->(gbif1950649),
(gbif1950650:taxon { name:"Heliopyrgus americanus", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"americanus", authorship:"Blanchard, 1852", accordingTo:"The Catalogue of Life, 3rd January 2011"}),
(gbif1950650)-[:HASPARENT]->(gbif1950649),
(gbif1950652:taxon { name:"Heliopyrgus aconita", rank:"SPECIES", genusPart:"Heliopyrgus", epithet:"aconita", authorship:"Plötz, 1884", accordingTo:"Interim Register of Marine and Nonmarine Genera"}),
(gbif1950652)-[:HASPARENT]->(gbif1950649)
----
// graph
== Test that no species ands subspecies have the same name.
This next query should return an empty result (note that the query has speciesa and speciesb, so we exclude the species that have the same name as the nominate subspecies (e.g., we don't count Heliopyrgus domicella and Heliopyrgus domicella domicella).
[source,cypher]
----
MATCH
(speciesa:taxon)-[:HASPARENT]->(genus:taxon),
(subspecies:taxon)-[:HASPARENT]->(speciesb:taxon)-[:HASPARENT]->(genus:taxon)
WHERE speciesa.epithet = subspecies.epithet
RETURN speciesa.epithet, speciesa.name, subspecies.name
----
//table
The query is not empty, so we have a problem. In this example, two species of Heliopyrgus are also treated as subspecies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment