Project:SPARQL/examples: Difference between revisions

Jump to navigation Jump to search
Line 146: Line 146:
   ?symb rdfs:label ?symbLabel.
   ?symb rdfs:label ?symbLabel.
} ORDER BY ?symbLabel ?hostLabel  
} ORDER BY ?symbLabel ?hostLabel  
</sparql>
===List Alphaproteobacterial symbionts localized in host nucleus===
<sparql tryit="1">
PREFIX pp: <https://ppsdb.wikibase.cloud/entity/>
PREFIX ppt: <https://ppsdb.wikibase.cloud/prop/direct/>
PREFIX pps: <https://ppsdb.wikibase.cloud/prop/>
PREFIX ppss: <https://ppsdb.wikibase.cloud/prop/statement/>
PREFIX ppsq: <https://ppsdb.wikibase.cloud/prop/qualifier/>
PREFIX ppsr: <https://ppsdb.wikibase.cloud/prop/reference/>
SELECT DISTINCT ?host ?hostLabel ?symbiont ?symbiontLabel ?localization ?localizationLabel
WITH {
  SELECT DISTINCT ?wditem WHERE {
    SERVICE <https://query.wikidata.org/sparql> {
      # taxon within Alphaproteobacteria
      ?wditem wdt:P171* wd:Q306579.
    }
  }
} AS %wd
WHERE {
  INCLUDE %wd
  ?host pps:P19 ?interaction.
  ?interaction ppss:P19 ?symbiont.
  ?symbiont ppt:P29 ?parent.
  # parent taxon is in Alphaproteobacteria
  ?parent ppt:P2 ?wditem.
  ?interaction ppsq:P20 ?localization.
  # nucleus or subclass of nucleus
  ?localization ppt:P24* pp:Q78
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?hostLabel
</sparql>
</sparql>


Navigation menu