SELECT ?c ?cLabel WHERE {
{?c wdt:P31 wd:Q11173} UNION
{?c wdt:P31 wd:Q79529}
?c wdt:P31 wd:Q12140 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
There is also a legal status for drug approval now, which allows to indicated the specific countries/agencies a drug has been approved by.
SELECT DISTINCT ?drug ?disease_treated WHERE {
?drug wdt:P31 wd:Q12140. # pharmaceutical drug
?drug wdt:P2175 ?disease_treated .
}
A few simple queries to show the power of Wikidata. Depending on the use case, the queries can just combined into one.
SELECT ?pot_drugs ?pot_drugsLabel WHERE {
wd:Q180614 wdt:P2176 ?pot_drugs . # give me all drugs available for melanoma
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
SELECT ?drug_target ?drug_targetLabel WHERE {
wd:Q423111 wdt:P129 ?drug_target . # give me all drugs targets of vemurafenib
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
SELECT ?drug_target ?drug_targetLabel ?go_itemLabel ?go_term WHERE {
wd:Q423111 wdt:P129 ?drug_target . # for vemurafenib, give me all drug targets
?drug_target wdt:P682 ?go_item . # give me all GO biological process annotations for the targets
?go_item wdt:P686 ?go_term
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY ?drug_targetLabel
SELECT ?inhibitor ?inhibitorLabel WHERE {
?gene wdt:P351 '673' . # get the gene item with entrez ID 673
?gene wdt:P688/wdt:P129 ?inhibitor .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
SELECT ?disease ?diseaseLabel WHERE {
wd:Q7041828 wdt:P2175 ?disease . # give me all diseases which can be treated by nivolumab
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
SELECT * WHERE {
{?x wdt:P652 ?unii .} MINUS
{?x wdt:P2115 ?nui .}
}
SELECT ?mab ?mabLabel WHERE {
{?mab wdt:P279 wd:Q422248 .} UNION
{?mab wdt:P31 wd:Q422248 .}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
bd:serviceParam wikibase:language "de" .
}
}
This query is based on the assumption that all items of instance of chemical compound or monoclonal antibody who's label ends with 'mab' is a monoclonal antibody. Execute
SELECT DISTINCT ?ab ?abLabel where {
{?ab wdt:P31 wd:Q12140 .} UNION
{?ab wdt:P31 wd:Q11173 . }
?ab rdfs:label ?abLabel filter (lang(?abLabel) = "en" || lang(?abLabel) = "de") .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
bd:serviceParam wikibase:language "de" .
}
FILTER (STRENDS(?abLabel, 'mab'))
}
GROUP BY ?ab ?abLabel
Get all monoclonal antibodies with revevant external IDs, based on categorization with 'instance of' monoclonal antibody
SELECT ?ab ?abLabel ?cas ?gtp ?chembl WHERE {
?ab wdt:P31 wd:Q422248.
OPTIONAL { ?ab wdt:P231 ?cas. }
OPTIONAL { ?ab wdt:P595 ?gtp. }
OPTIONAL { ?ab wdt:P592 ?chembl. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
SELECT ?ab ?abLabel ?cas ?gtp ?chembl WHERE {
?ab wdt:P31 wd:Q422248.
?ab wdt:P2175 wd:Q180614 .
OPTIONAL { ?ab wdt:P231 ?cas. }
OPTIONAL { ?ab wdt:P595 ?gtp. }
OPTIONAL { ?ab wdt:P592 ?chembl. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Get all monoclonal antibodies which might treat melanoma, include references where knowledge has been imported from
SELECT ?drugLabel ?drug ?ref_id ?ref_db ?ref_dbLabel ?ref_date WHERE {
?drug wdt:P2175 wd:Q180614 ;
wdt:P31 wd:Q422248 .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
OPTIONAL {
?drug p:P2175 ?s2 .
?s2 prov:wasDerivedFrom ?v .
?v <http://www.wikidata.org/prop/reference/P592>|<http://www.wikidata.org/prop/reference/P2115> ?ref_id .
?v <http://www.wikidata.org/prop/reference/P248> ?ref_db .
?v <http://www.wikidata.org/prop/reference/P813> ?ref_date .
}
}
group by ?drug ?drugLabel ?ref_id ?ref_db ?ref_dbLabel ?ref_date
Get all drugs that can be used for treatment of asthma, then get the protein targets and other drugs these targets could be modified by. Also return the type of interaction.
PREFIX q: <http://www.wikidata.org/prop/qualifier/>
SELECT DISTINCT ?drug ?drugLabel ?protein ?proteinLabel ?drug2 ?drug2Label ?v ?vLabel WHERE {
wd:Q35869 wdt:P2176 ?drug .
?drug wdt:P2175 ?condition .
?drug wdt:P129 ?protein .
?protein wdt:P129 ?drug2 .
?drug2 p:P129 ?s .
OPTIONAL {
?s q:P794 ?v . # P794 'as' qualifier property
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
SELECT * WHERE {
?drug wdt:P2175 ?d.
{?drug wdt:P592 ?chembl.} #minus
{?drug wdt:P2115 ?ndfrt}
}
Get all chemical compounds which have treatment info but lack a PDB ID (that suggests that no dedicated target of a compound is known)
SELECT DISTINCT ?x ?xLabel ?condition ?conditionLabel WHERE {
{?x wdt:P2175 ?condition . } MINUS
{
?x wdt:P31 wd:Q11173.
?x wdt:P638 ?pdb.
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
SELECT ?disease ?label (GROUP_CONCAT(DISTINCT(?alias); separator="|") AS ?aliases) WHERE {
{?disease wdt:P486 ?mesh .} UNION # Mesh
{?disease wdt:P699 ?doid .} UNION # DO
{?disease wdt:P494 wd:Q11173 .} MINUS # ICD-10
{?disease wdt:P31 wd:Q11173 .}
OPTIONAL {
?disease rdfs:label ?label FILTER (LANG(?label) = "en") .
}
OPTIONAL {
?disease skos:altLabel ?alias FILTER (LANG(?alias) = "en") .
}
}
GROUP BY ?disease ?label ?aliases
SELECT ?atc ?d ?dLabel ?target ?targetLabel ?diseaseLabel WHERE {
?d wdt:P267 ?atc.
?d wdt:P129 ?target .
OPTIONAL {
?d wdt:P2175 ?disease .
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY ?atc
SELECT DISTINCT * WHERE {
?d wdt:P31 wd:Q12136 .
?d wdt:P2892 ?umls .
}
SELECT ?drug ?drugLabel ?manufacturer ?manufacturerLabel WHERE {
?drug wdt:P31 wd:Q12140 .
?drug wdt:P176 ?manufacturer .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
SELECT ?wpid ?gene ?geneLabel ?protei ?proteinLabel ?compound ?compoundLabel WHERE {
wd:Q29883419 wdt:P2410 ?wpid;
wdt:P527 ?gene.
?gene wdt:P688 ?protein.
?protein wdt:P129 ?compound .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Get all subcategories of dermatologic drug and the actual compounds
SELECT ?compound ?compoundLabel ?category ?categoryLabel WHERE {
?compound wdt:P2868 ?category .
?category wdt:P279* wd:Q41825808 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
What diseases can be treated with dermatologic drugs?
SELECT ?compound ?compoundLabel ?category ?categoryLabel ?disease ?diseaseLabel WHERE {
?compound wdt:P2868 ?category .
?category wdt:P279* wd:Q41825808 .
OPTIONAL {?compound wdt:P2175 ?disease .}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
What are the known targets in a cell hit by drugs of the category dermatologic drugs
SELECT ?compound ?compoundLabel ?category ?categoryLabel ?target ?targetLabel WHERE {
?compound wdt:P2868 ?category .
?category wdt:P279* wd:Q41825808 .
OPTIONAL {?compound wdt:P129 ?target .}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
SELECT ?c ?cLabel ?role ?roleLabel WHERE {
?c wdt:P235 ?ikey .
?c wdt:P2868 ?role .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}