Project:SPARQL/other: Difference between revisions

no edit summary
No edit summary
No edit summary
 
Line 1: Line 1:
===Export for GloBI===
SPARQL query to export table with fields used by Globi. The output may need to be processed further.
<sparql tryit="1">
#List all interactions, optionally the localization, interaction type, and references
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 ?argumentTypeName ?sourceTaxon ?sourceTaxonName ?sourceWdmap ?sourceTaxonId ?interactionTypeName ?interactionTypeId ?targetTaxon ?targetTaxonName ?targetWdmap ?targetTaxonId ?sourceBodyPartName ?sourceBodyPartId ?referenceDoi ?referenceCitation WHERE {
SELECT DISTINCT ?argumentTypeName ?sourceTaxonName ?sourceTaxonId ?interactionTypeName ?interactionTypeId ?targetTaxonName ?targetTaxonId ?sourceBodyPartName ?sourceBodyPartId ?referenceDoi ?referenceCitation WHERE {
  ?sourceTaxon pps:P19 ?interaction.
  ?interaction ppss:P19 ?targetTaxon.
  OPTIONAL {
    ?interaction ppsq:P20 ?sourceBodyPart.
    ?sourceBodyPart rdfs:label ?sourceBodyPartName.
    OPTIONAL { ?sourceBodyPart ppt:P17 ?sourceBodyPartId. }
    OPTIONAL { ?sourceBodyPart ppt:P44 ?sourceBodyPartId. }
  }
  OPTIONAL {
    ?interaction ppsq:P26 ?type.
    ?type rdfs:label ?typeLabel.
    OPTIONAL { ?type ppt:P16 ?interactionTypeId. }
  }
  # if no interaction type is given, then default to "host of"
  BIND (EXISTS { ?interaction ppsq:P26 ?type. } AS ?existsType )
  BIND (IF(?existsType, ?typeLabel, "host of") AS ?interactionTypeName)
  OPTIONAL {
    ?interaction prov:wasDerivedFrom ?refnode.
    # OPTIONAL { ?refnode ppsr:P27 ?doi }
    OPTIONAL {
      ?refnode ppsr:P23 ?statedIn.
      OPTIONAL { ?statedIn ppt:P13 ?referenceDoi. }
      OPTIONAL { ?statedIn ppt:P14 ?referenceCitation. }
      BIND (STR("support") AS ?argumentTypeName)
    }
    OPTIONAL {
      ?refnode ppsr:P43 ?statedIn.
      OPTIONAL { ?statedIn ppt:P13 ?referenceDoi. }
      OPTIONAL { ?statedIn ppt:P14 ?referenceCitation. }
      BIND (STR("refute") AS ?argumentTypeName)
    }
  }
  OPTIONAL {
    ?sourceTaxon ppt:P11 ?sourceTaxon_ncbi.
    BIND ( CONCAT("NCBI:txid", STR(?sourceTaxon_ncbi)) as ?sourceTaxonId )
  }
  OPTIONAL {
    ?targetTaxon ppt:P11 ?targetTaxon_ncbi.
    BIND ( CONCAT("NCBI:txid", STR(?targetTaxon_ncbi)) as ?targetTaxonId )
  }
  ?sourceTaxon rdfs:label ?sourceTaxonName .
  OPTIONAL { ?targetTaxon rdfs:label ?targetTaxonName. }
  OPTIONAL { ?sourceTaxon ppt:P2 ?sourceWdmap . }
  OPTIONAL { ?targetTaxon ppt:P2 ?targetWdmap . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?sourceTaxonName ?targetTaxonName
</sparql>


===Draw taxonomy tree for Eukaryota (9-rank PR2 v5.0.0 taxonomy)===
===Draw taxonomy tree for Eukaryota (9-rank PR2 v5.0.0 taxonomy)===
Line 42: Line 107:
</sparql>
</sparql>


==Deprecated queries==


===Generate QuickStatements to link interaction hosts to their genera (DEPRECATED)===
===Generate QuickStatements to link interaction hosts to their genera (DEPRECATED)===