Project:SPARQL/examples: Difference between revisions

Jump to navigation Jump to search
Line 89: Line 89:
</sparql>
</sparql>


===Find interactions where the symbiont is member of Pseudomonadota===
===List interactions where host is a member of Blattodea (cockroaches and termites), according to Wikidata===
 
Symbiont items linked to Wikidata items by NCBI taxonomy ID. Not all symbionts have corresponding Wikidata items or NCBI taxonomy IDs.


<sparql tryit="1">
<sparql tryit="1">
Line 97: Line 95:
PREFIX ppt: <https://ppsdb.wikibase.cloud/prop/direct/>
PREFIX ppt: <https://ppsdb.wikibase.cloud/prop/direct/>


SELECT DISTINCT ?host ?hostLabel ?symb ?symbLabel ?ncbi ?wditem
SELECT DISTINCT ?host ?hostLabel ?symb ?symbLabel ?wditem  
WITH {
WITH {
   SELECT DISTINCT ?host ?symb ?ncbi ?hostLabel ?symbLabel
   SELECT DISTINCT ?wditem WHERE {
  WHERE {
     SERVICE <https://query.wikidata.org/sparql> {
     ?host ppt:P19 ?symb.
      ?wditem wdt:P171* wd:Q25309.
    ?symb ppt:P11 ?ncbi.
     }
    ?host rdfs:label ?hostLabel.
     ?symb rdfs:label ?symbLabel.
   }
   }
} AS %ncbis
} AS %wd
WHERE {
WHERE {
   INCLUDE %ncbis
   INCLUDE %wd
   SERVICE <https://query.wikidata.org/sparql> {
   ?host ppt:P19 ?symb.
    ?wditem wdt:P685 ?ncbi;
  ?host ppt:P29 ?parent.
          rdfs:label ?wdlabel.
  ?parent ppt:P2 ?wditem.
    ?wditem wdt:P171* wd:Q12962137. # child taxon of Pseudomonadota (parent taxon of Gammaproteobacteria)
  ?host rdfs:label ?hostLabel.
    FILTER ( LANG(?wdlabel) = "en" )
  ?symb rdfs:label ?symbLabel.
  }
} ORDER BY ?symbLabel ?hostLabel
} ORDER BY ?symbLabel
</sparql>
</sparql>


===Find interactions where symbiont is member of Alphaproteobacteria according to Wikidata===
===List interactions where symbiont is member of Alphaproteobacteria according to Wikidata===


Get items with a parent taxon that is mapped to a taxon in Wikidata, relying on the taxonomy that is given there.
Get items with a parent taxon that is mapped to a taxon in Wikidata, relying on the taxonomy that is given there.

Navigation menu