Cypher
This page provides some examples on how to access GloBI using neo4j's cypher query services. GloBI hosts a neo4j server instance that is publicly accessible, so you have a flexible way to query species interaction data. Here's some examples of such queries using the GloBI neo4j instance: http://tinyurl.com/whatthingsdohumanseat or http://tinyurl.com/whatthingsdotunaeat. Alternatives to accessing the GloBI species interaction data can be found here. If you have any questions about using the GloBI cypher query interface, please open an issue.
Copy / paste cypher query below in Cypher Data Explorer. See issue #19 for more information.
CYPHER 1.9 START predatorTaxon = node:taxons(name='Homo sapiens'), preyTaxon = node:taxonPaths('path:Mammalia'),envo = node:environments('*:*') MATCH predatorTaxon<-[:CLASSIFIED_AS]-predator-[:ATE]->prey-[:CLASSIFIED_AS]->preyTaxon<-[:CLASSIFIED_AS]-pred2-[:ATE]->prey2-[:CLASSIFIED_AS]->preyOfPreyTaxon, predator-[:COLLECTED_AT]->location-[:HAS_ENVIRONMENT]->envo
WHERE envo.name = 'coast' RETURN envo.externalId, envo.name, preyTaxon.commonNames?, preyTaxon.path?, predatorTaxon.name as predatorName, preyTaxon.name as preyName, count(distinct preyOfPreyTaxon.name) as preyOfPreyCount
Look up first 10 distinct prey taxons for predator specimens that were classified as Syacium papillosum and matched against external taxonomy.
Execute query using cURL
curl -X POST -H Accept:application/json -H Content-Type:application/json -d '{"query": "CYPHER 1.9 START taxon = node:taxons(name=\"Syacium papillosum\") MATCH taxon<-[x:CLASSIFIED_AS]-predatorSpecimen-[:ATE]->preySpecimen-[:CLASSIFIED_AS]->preyTaxon where has(preyTaxon.externalId) and has(taxon.externalId) RETURN distinct preyTaxon.externalId as preyTaxonId, taxon.externalId as predatorTaxonId LIMIT 10"}' -v https://neo4j.globalbioticinteractions.org/db/data/cypher
Example JSON response
{ "data" : [ [ "NCBITaxon:292503", "NCBITaxon:195649" ], [ "NCBITaxon:6805", "NCBITaxon:195649" ], [ "NCBITaxon:150701", "NCBITaxon:195649" ], [ "urn:lsid:marinespecies.org:taxname:101467", "NCBITaxon:195649" ], [ "NCBITaxon:111522", "NCBITaxon:195649" ], [ "NCBITaxon:338195", "NCBITaxon:195649" ], [ "urn:lsid:marinespecies.org:taxname:158021", "NCBITaxon:195649" ], [ "urn:lsid:marinespecies.org:taxname:118287", "NCBITaxon:195649" ], [ "urn:lsid:marinespecies.org:taxname:158368", "NCBITaxon:195649" ], [ "NCBITaxon:6810", "NCBITaxon:195649" ] ], "columns" : [ "preyTaxonId", "predatorTaxonId" ] }
Copy and paste the Cypher query into http://tinyurl.com/whatthingsdohumanseat to reproduce results.
Example Cypher query
CYPHER 1.9 START study = node:studies('*:*') MATCH study-[:COLLECTED]->source-[:CLASSIFIED_AS]->sourceTaxon, source-[rel:ATE|PREYS_UPON|PARASITE_OF|HAS_HOST|INTERACTS_WITH]->target-[:CLASSIFIED_AS]->targetTaxon WHERE sourceTaxon.name = "Adalia bipunctata" RETURN id(source) as sourceOccurrenceId, sourceTaxon.externalId, sourceTaxon.name, id(rel) as occurrenceInteractionId, type(rel) as occurrenceInteractionType, id(target) as targetOccurrenceId, targetTaxon.externalId, targetTaxon.name
Example result
==> | sourceOccurrenceId | sourceTaxon.externalId | sourceTaxon.name | occurrenceInteractionId | occurrenceInteractionType | targetOccurrenceId | targetTaxon.externalId | targetTaxon.name |
==> +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
==> | 881982 | "EOL:1174823" | "Adalia bipunctata" | 220187 | "PARASITE_OF" | 881983 | "urn:lsid:bioinfo.org.uk:taxa:157663" | "Podapolipus" |
==> | 881980 | "EOL:1174823" | "Adalia bipunctata" | 220182 | "PARASITE_OF" | 881981 | "urn:lsid:bioinfo.org.uk:taxa:157663" | "Podapolipus" |
==> | 881973 | "EOL:1174823" | "Adalia bipunctata" | 220167 | "INTERACTS_WITH" | 881974 | "urn:lsid:bioinfo.org.uk:taxa:157662" | "Tetrastichus coccinellae" |
==> | 881910 | "EOL:1174823" | "Adalia bipunctata" | 220022 | "INTERACTS_WITH" | 881911 | "urn:lsid:bioinfo.org.uk:taxa:91775" | "Phalacrotophora fasciata" |
==> | 881892 | "EOL:1174823" | "Adalia bipunctata" | 219977 | "INTERACTS_WITH" | 881893 | "urn:lsid:bioinfo.org.uk:taxa:102934" | "Phalacrotophora berolinensis" |
==> | 881877 | "EOL:1174823" | "Adalia bipunctata" | 219942 | "INTERACTS_WITH" | 881879 | "urn:lsid:bioinfo.org.uk:taxa:102934" | "Phalacrotophora berolinensis" |
==> | 881859 | "EOL:1174823" | "Adalia bipunctata" | 219902 | "INTERACTS_WITH" | 881860 | "urn:lsid:bioinfo.org.uk:taxa:91775" | "Phalacrotophora fasciata" |
==> +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Total number of specimens collected across all studies
curl -X POST -H Accept:application/json -H Content-Type:application/json -d '{"query": "CYPHER 1.9 START study = node:studies(\"*:*\") MATCH study-[:COLLECTED]->specimen RETURN count(specimen)"}' -v https://neo4j.globalbioticinteractions.org/db/data/cypher
Total number of classifications made across all studies
curl -X POST -H Accept:application/json -H Content-Type:application/json -d '{"query": "CYPHER 1.9 START study = node:studies(\"*:*\") MATCH study-[:COLLECTED]->specimen-[predatorClassifications:CLASSIFIED_AS]->taxon RETURN count(predatorClassifications)"}' -v https://neo4j.globalbioticinteractions.org/db/data/cypher
Total number of predator specimens that were classified as taxon matched against external taxonomy
curl -X POST -H Accept:application/json -H Content-Type:application/json -d '{"query": "CYPHER 1.9 START study = node:studies(\"*:*\") MATCH study-[:COLLECTED]->specimen-[:CLASSIFIED_AS]->taxon WHERE has(taxon.externalId) RETURN count(specimen)"}' -v https://neo4j.globalbioticinteractions.org/db/data/cypher
List of predator taxon names that did not match against an external taxonomy (with source-study reference)
curl -X POST -H Accept:application/json -H Content-Type:application/json -d '{"query": "CYPHER 1.9 START study = node:studies(\"*:*\") MATCH study-[:COLLECTED]->specimen-[:CLASSIFIED_AS]->taxon WHERE taxon.externalId = \"no:match\" RETURN distinct taxon.name, study.title"}' -v https://neo4j.globalbioticinteractions.org/db/data/cypher
List of distinct predator names from a specific list of studies
CYPHER 1.9 START study = node:studies('*:*')
MATCH study-[:COLLECTED]->predator-[:CLASSIFIED_AS]->predatorTaxon
WHERE study.title in ['BAREMORE_ANGEL_SHARK','BARNES','simons/mississippiAlabamaFishDiet.csv.gz','akinMadIsland','Blewett2000CharlotteHarborFL','wrast/lavacaBayTrophicData.csv.gz']
RETURN distinct(predatorTaxon.name)
Produces a result such as:
"Caranx hippos"
"Syacium gunteri"
"Gadus morhua"
"Zalieutes mcgintyi"
"Clupea harengus"
...