Project:SPARQL/examples: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 376: Line 376:
</sparql>
</sparql>


=== Generate QuickStatements to link host taxa to Wikidata items by matching NCBI taxon ID ===
=== Generate QuickStatements to link taxa to Wikidata items by matching NCBI taxon ID ===


<sparql tryit="1">
<sparql tryit="1">
Line 386: Line 386:
PREFIX ppsr: <https://ppsdb.wikibase.cloud/prop/reference/>
PREFIX ppsr: <https://ppsdb.wikibase.cloud/prop/reference/>


#SELECT DISTINCT ?host ?qid ?pplabel ?ncbi ?P2 ?wdlabel
SELECT DISTINCT ?qid ?P2
SELECT DISTINCT ?qid ?P2
WITH {
WITH {
   SELECT DISTINCT ?host ?qid ?ncbi ?pplabel
   SELECT DISTINCT ?ppitem ?qid ?ncbi ?pplabel
   WHERE {
   WHERE {
     ?host pps:P19 ?interaction.
     ?ppitem ppt:P11 ?ncbi.
    ?host ppt:P11 ?ncbi.
     ?ppitem rdfs:label ?pplabel.
     ?host rdfs:label ?pplabel.
     FILTER NOT EXISTS { ?ppitem ppt:P2 ?wikidata_mapping. }
     FILTER NOT EXISTS { ?host ppt:P2 ?wikidata_mapping. }
     BIND (ENCODE_FOR_URI(REPLACE(STR(?ppitem), ".*Q", "Q")) AS ?qid)
     BIND (ENCODE_FOR_URI(REPLACE(STR(?host), ".*Q", "Q")) AS ?qid) # article item
   }
   }
} AS %ncbis
} AS %ncbis
Line 401: Line 399:
   INCLUDE %ncbis
   INCLUDE %ncbis
   SERVICE <https://query.wikidata.org/sparql> {
   SERVICE <https://query.wikidata.org/sparql> {
    # find wikidata items with this DOI
     ?wditem wdt:P685 ?ncbi;
     ?P2 wdt:P685 ?ncbi;
           rdfs:label ?wdlabel.
           rdfs:label ?wdlabel.
     FILTER ( LANG(?wdlabel) = "en" )
     FILTER ( LANG(?wdlabel) = "en" )
    BIND (CONCAT('\"', STR(?wditem), '\"') AS ?P2)
   }
   }
}
}
</sparql>
</sparql>


===Graph of all classes===
===Graph of all classes===

Navigation menu