Wikidata talk:ScienceSource project/Queries

From Wikidata
Jump to navigation Jump to search

Histogram query[edit]

Saving work in progress:

#For article Q6679

SELECT ?decile ?hybrid

  WHERE {
    ?annotation wdt:P3 wd:Q5 ;
                wdt:P19 ?anchor;
                wdt:P16 ?dic0.
    VALUES ?dic { wd:Q6803 wd:Q6793 }.
    ?dic wdt:P16 ?dic0.
    BIND((IF (?dic=wd:Q6803, "Q6803",1/0)) AS ?hybrid1)
    BIND((IF (?dic=wd:Q6793, "Q6793",1/0)) AS ?hybrid2)
    BIND(COALESCE(?hybrid1,?hybrid2) AS ?hybrid)

    ?anchor wdt:P12 wd:Q6679.
    ?anchor wdt:P10 ?charnumber.
    ?annotationZ wdt:P19 ?anchorZ.
    ?anchorZ wdt:P7 wd:Q6;
             wdt:P12 wd:Q6679;
             wdt:P10 ?length.
   BIND (floor(10*?charnumber/?length) AS ?decile)
  
  }

Try it!

#For article Q6679
#Two columns of data
SELECT ?decile (COUNT(?hybrid1) AS ?count1) (COUNT(?hybrid2) AS ?count2) 

  WHERE {
    ?annotation wdt:P3 wd:Q5 ;
                wdt:P19 ?anchor;
                wdt:P16 ?dic0.
    VALUES ?dic { wd:Q6803 wd:Q6793 }.
    ?dic wdt:P16 ?dic0.
    BIND((IF (?dic=wd:Q6803, "Q6803",1/0)) AS ?hybrid1)
    BIND((IF (?dic=wd:Q6793, "Q6793",1/0)) AS ?hybrid2)  
    BIND(COALESCE(?hybrid1,?hybrid2) AS ?hybrid)
    BIND(COALESCE(?hybrid1Label,?hybrid2Label) AS ?hl)
    ?anchor wdt:P12 wd:Q6679.
    ?anchor wdt:P10 ?charnumber.
    ?annotationZ wdt:P19 ?anchorZ.
    ?anchorZ wdt:P7 wd:Q6;
             wdt:P12 wd:Q6679;
             wdt:P10 ?length.
   BIND (floor(10*?charnumber/?length) AS ?decile)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }
 GROUP BY ?decile

Try it!

#For article Q6679
#Two columns of data, breakdown of paper 2% at a time
SELECT ?quantile (COUNT(?hybrid1) AS ?count1) (COUNT(?hybrid2) AS ?count2) 

  WHERE {
    ?annotation wdt:P3 wd:Q5 ;
                wdt:P19 ?anchor;
                wdt:P16 ?dic0.
    VALUES ?dic { wd:Q6803 wd:Q6793 }.
    ?dic wdt:P16 ?dic0.
    BIND((IF (?dic=wd:Q6803, "Q6803",1/0)) AS ?hybrid1)
    BIND((IF (?dic=wd:Q6793, "Q6793",1/0)) AS ?hybrid2)  
    BIND(COALESCE(?hybrid1,?hybrid2) AS ?hybrid)
    BIND(COALESCE(?hybrid1Label,?hybrid2Label) AS ?hl)
    ?anchor wdt:P12 wd:Q6679.
    ?anchor wdt:P10 ?charnumber.
    ?annotationZ wdt:P19 ?anchorZ.
    ?anchorZ wdt:P7 wd:Q6;
             wdt:P12 wd:Q6679;
             wdt:P10 ?length.
   BIND (floor(50*?charnumber/?length) AS ?quantile)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }
 GROUP BY ?quantile
 ORDER BY ASC(?quantile)

Try it!

Filtered co-occurrence[edit]

This is Wikidata Query Service SPARQL, unlike others on the page, and so can be run from here. Needs debugging.

#Co-occurrence of ScienceSource annotations with known Wikidata drug-disease treatment pairs filtered out.
PREFIX ss: <http://sciencesource.wmflabs.org/entity/>
PREFIX sst: <http://sciencesource.wmflabs.org/prop/direct/>

SELECT ?drugann ?drug ?diseaseann ?disease ?articletitle ?articledate
WHERE
 {
SERVICE <http://sciencesource-query.wmflabs.org/proxy/wdqs/bigdata/namespace/wdq/sparql>
  {      ?diseaseann sst:P2 ?wdcode1;
                     sst:P15 ?disease;
                     sst:P16 "infectiousdiseases";
                     sst:P19 ?anchor1.
         ?drugann sst:P2 ?wdcode2;
                  sst:P15 ?drug;
                  sst:P16 "infectiousdiseasesdrugs";
                  sst:P19 ?anchor2.       
         ?anchor1 sst:P10 ?charnumber1.
         ?anchor2 sst:P10 ?charnumber2.
         ?anchor1 sst:P12 ?article.
         ?anchor2 sst:P12 ?article.
         ?article sst:P17 ?articledate.
         ?article sst:P20 ?articletitle.
         FILTER (abs(?charnumber2 - ?charnumber1) < 200)
  }
   ?item1 wdt:P31 wd:Q12136.
   FILTER(str(?item1) = CONCAT("http://wikidata.org/entity/", ?wdcode1))
   ?item2 wdt:P31 wd:Q11173.
   FILTER(str(?item2) = CONCAT("http://wikidata.org/entity/", ?wdcode2))
   MINUS {?item2 wdt:P2175 ?item1}
   }
LIMIT 100

Try it!

Crossmatching Wikidata items (on focus list) to SS article items[edit]

This is WDQS SPARQL, can be run from this page.

#Filtering query to select articles from the focus list
#From PLOS NTD and with PMC ID, main subject "infectious disease" or part of

PREFIX ss: <http://sciencesource.wmflabs.org/entity/>
PREFIX sst: <http://sciencesource.wmflabs.org/prop/direct/>
  
SELECT DISTINCT ?item ?stritem ?articleitem ?itemLabel ?pmcid ?journalLabel ?title ?date ?licenseLabel ?mainsubjectLabel
  WHERE 
        {
          
        SERVICE <http://sciencesource-query.wmflabs.org/proxy/wdqs/bigdata/namespace/wdq/sparql>
       { ?articleitem sst:P3 ss:Q4;
            sst:P2 ?stritem. }
          
          ?item wdt:P31 wd:Q13442814 .
          ?item wdt:P5008 wd:Q55439927 .
          ?item wdt:P932 ?pmcid .
          ?item wdt:P1433 wd:Q3359737.
          ?item wdt:P1433 ?journal .
          ?item wdt:P1476 ?title .
          ?item wdt:P577 ?date .
          ?item wdt:P275 ?license .
          ?item wdt:P921 ?mainsubject .
          ?mainsubject wdt:P361* wd:Q18123741 .
          BIND(substr(str(?item),32,39) AS ?stritem) .
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
        }

Try it!

Improved version of the same idea.

#Filtering query to select articles from the focus list not on the ScienceSource wiki

PREFIX ss: <http://sciencesource.wmflabs.org/entity/>
PREFIX sst: <http://sciencesource.wmflabs.org/prop/direct/>
  
SELECT DISTINCT ?item ?itemLabel
  WHERE 
        {
          
          ?item wdt:P5008 wd:Q55439927 ;
                wdt:P921 ?mainsubject .
          ?mainsubject wdt:P1995 wd:Q327657 .
          
       MINUS { SERVICE <http://sciencesource-query.wmflabs.org/proxy/wdqs/bigdata/namespace/wdq/sparql>
       { ?articleitem sst:P3 ss:Q4;
            sst:P2 ?stritem. }

          BIND(substr(str(?item),32,39) AS ?stritem) .}
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
        }

Try it!

Filtered co-occurrence (doesn't yet work)[edit]

#Infectious diseases, related drugs, filtered co-occurrence

PREFIX ss: <http://sciencesource.wmflabs.org/entity/>
PREFIX sst: <http://sciencesource.wmflabs.org/prop/direct/>       
          
SELECT ?item1 ?item2 ?str1 ?str2 
WHERE {
   
  ?item1 wdt:P31 wd:Q12136;
        wdt:P1995 ?medspec.
  ?medspec wdt:P361* wd:Q788926 .
  ?item2 wdt:P31 wd:Q12140;
         wdt:P2175 ?condition.
  ?condition wdt:P1995 wd:Q788926.
  MINUS {?item2 wdt:P2175 ?item1}.
  BIND(substr(str(?item1),32) AS ?str1) .
  BIND(substr(str(?item2),32) AS ?str2) .
  
  SERVICE <http://sciencesource-query.wmflabs.org/proxy/wdqs/bigdata/namespace/wdq/sparql>
       {?annotation1 sst:P16 "infectiousdiseases";
                     sst:P2 ?str1;
                     sst:P3 ss:Q5.
        ?annotation2 sst:P16 "infectiousdiseasesdrugs";
                     sst:P2 ?str2;
                     sst:P3 ss:Q5.
       ?annotation1 sst:P19 ?anchor1.
        ?annotation2 sst:P19 ?anchor2.
        ?anchor1 sst:P12 ?article;
                 sst:P3 ss:Q2.
        ?anchor2 sst:P12 ?article;
                 sst:P3 ss:Q2.
        ?article sst:P3 ss:Q4.
        ?anchor1 sst:P10 ?charnumber1.
        ?anchor2 sst:P10 ?charnumber2.
        FILTER (?charnumber2 - ?charnumber1 = 100)
       }
  
  }
LIMIT 10

Try it!

SS disease list[edit]

This is a finder query for missing medical condition treated (P2175) statements here. A VALUES query with a long list, it could in principle be a federated query, but there is a performance issue to overcome.

#Diseases with MeSH ID where there is no drug treatment, and ScienceSource has annotations
SELECT DISTINCT ?item ?label
  WHERE {?item wdt:P31 wd:Q12136;
               rdfs:label ?label;
               wdt:P486 ?mesh.
         FILTER(STRSTARTS(?mesh, 'D'))
         MINUS {?drug wdt:P2175 ?item}
         
         VALUES ?term {
"abdominal aortic aneurysm"
"abetalipoproteinemia"
"abscess"
"Acanthamoeba keratitis"
"acariasis"
"acrodermatitis enteropathica"
"acromegaly"
"ACTH-secreting pituitary adenoma"
"actinomycosis"
"acute hemorrhagic conjunctivitis"
"acute intermittent porphyria"
"acute kidney injury"
"acute porphyria"
"acute thyroiditis"
"Addison's disease"
"Adenovirus infection"
"adiposis dolorosa"
"adrenal adenoma"
"adrenal cortical adenoma"
"adrenal gland disease"
"adrenal insufficiency"
"adult respiratory distress syndrome"
"African histoplasmosis"
"African horse sickness"
"African tick-bite fever"
"age related macular degeneration"
"AIDS"
"AIDS-related complex"
"airway obstruction"
"Alastrim"
"Albright's hereditary osteodystrophy"
"Alexander disease"
"alkaptonuria"
"allergic asthma"
"allergic bronchopulmonary aspergillosis"
"alpha 1-antitrypsin deficiency"
"alpha-mannosidosis"
"Alstrom syndrome"
"alveolar echinococcosis"
"alveolitis"
"amblyopia"
"amebiasis"
"American histoplasmosis"
"amoebic dysentery"
"amyloid neuropathy"
"amyloidosis"
"anaerobic pneumonia"
"ancylostomiasis"
"androgen insensitivity syndrome"
"aneurysm"
"angiostrongyliasis"
"angle-closure glaucoma"
"anisakiasis"
"anisometropia"
"ankylosing spondylitis"
"ankylosis"
"anterior uveitis"
"anthracosis"
"anthropozoonosis"
"aortic aneurysm"
"apparent mineralocorticoid excess"
"Argentine hemorrhagic fever"
"argininemia"
"argininosuccinic aciduria"
"arthritis"
"arthropathy"
"asbestosis"
"ascariasis"
"ascaridiasis"
"aspergilloma"
"aspergillosis"
"aspiration pneumonia"
"aspiration pneumonitis"
"aspirin-induced asthma"
"asthma"
"astigmatism"
"asymptomatic neurosyphilis"
"atelectasis"
"atheroembolic renal disease"
"autoimmune disease"
"autoimmune polyendocrine syndrome"
"autoimmune polyendocrine syndrome type 1"
"autoimmune thyroiditis"
"autosomal dominant optic atrophy"
"avian influenza"
"avian sarcoma"
"babesiosis"
"bacillary angiomatosis"
"bacillus anthracis"
"bacterial conjunctivitis"
"bacterial infectious disease"
"bacterial pneumonia"
"balantidiasis"
"band keratopathy"
"Barth syndrome"
"bartonellosis"
"bejel"
"beriberi"
"berylliosis"
"biotinidase deficiency"
"bird fancier's lung"
"blackwater fever"
"Blastocystosis"
"blastomycosis"
"blepharitis"
"blindness"
"Bolivian hemorrhagic fever"
"bone disease"
"borderline leprosy"
"Borna disease"
"borreliosis"
"botulism"
"bronchiectasis"
"bronchiolitis"
"bronchiolitis obliterans"
"bronchitis"
"bronchopneumonia"
"bronchospasm"
"brucellosis"
"bubonic plague"
"bulbar polio"
"bullous emphysema"
"bullous keratopathy"
"Buruli ulcer disease"
"calcinosis"
"calciphylaxis"
"campylobacteriosis"
"Canavan disease"
"candidemia"
"candidiasis"
"carbohydrate metabolic disorder"
"carcinoid"
"cardiovascular syphilis"
"Carrion's disease"
"cat-scratch disease"
"cataract"
"catarrh"
"central retinal vein occlusion"
"cercarial dermatitis"
"cerebral malaria"
"cerebrotendinous xanthomatosis"
"Chagas disease"
"chancroid"
"Chediak-Higashi syndrome"
"chemical pneumonitis"
"chickenpox"
"chikungunya"
"childhood obesity"
"chlamydia infection"
"cholera"
"cholesteatoma"
"cholesterol ester storage disease"
"choroideremia"
"chromoblastomycosis"
"chronic kidney disease"
"Chronic mucocutaneous candidiasis"
"chronic obstructive pulmonary disease"
"chronic progressive external ophthalmoplegia"
"Chronic recurrent multifocal osteomyelitis"
"chronic rhinitis"
"citrullinemia"
"clonorchiasis"
"Clostridium difficile colitis"
"coccidioidomycosis"
"coccidiosis"
"collagenous sprue"
"Colorado tick fever"
"Complete androgen insensitivity syndrome"
"complications of diabetes mellitus"
"conductive hearing loss"
"Condyloma"
"cone dystrophy"
"congenital adrenal hyperplasia"
"congenital disorder of glycosylation"
"congenital generalized lipodystrophy"
"congenital hypothyroidism"
"congenital syphilis"
"congenital toxoplasmosis"
"conjunctivitis"
"connective tissue disease"
"Contrast-induced nephropathy"
"corneal endothelial cell loss"
"corneal neovascularization"
"corneal perforation"
"corneal ulcer"
"cortical deafness"
"cowpox"
"Crimean-Congo hemorrhagic fever"
"croup"
"cryptococcosis"
"cryptogenic organizing pneumonia"
"cryptosporidiosis"
"Cushing's syndrome"
"cutaneous anthrax"
"cutaneous candidiasis"
"Cutaneous larva migrans"
"cutaneous leishmaniasis"
"cutaneous lupus erythematosus"
"cycloplegia"
"cyclosporiasis"
"cystic echinococcosis"
"cysticercosis"
"cystinosis"
"cystinuria"
"cystoid macular edema"
"D-bifunctional protein deficiency"
"dacryoadenitis"
"Danon disease"
"decalcification"
"demodicosis"
"dengue fever"
"dengue hemorrhagic fever"
"dermatomycosis"
"dermatomyositis"
"dermatophytosis"
"desquamative interstitial pneumonia"
"diabetes insipidus"
"diabetes mellitus"
"diabetic angiopathy"
"diabetic autonomic neuropathy"
"diabetic foot"
"diabetic ketoacidosis"
"diabetic neuropathy"
"diabetic retinopathy"
"diarrhea"
"diphtheria"
"diphyllobothriasis"
"dirofilariasis"
"discitis"
"distomatosis"
"Donohue syndrome"
"dracunculiasis"
"Drusen"
"Duane retraction syndrome"
"dysentery"
"early yaws"
"Eastern equine encephalitis"
"Ebola virus disease"
"echinococcosis"
"echinostomiasis"
"ehrlichiosis"
"empty sella syndrome"
"empyema"
"endemic goiter"
"endemic typhus"
"endometrial carcinoma"
"endophthalmitis"
"enophthalmos"
"enterobiasis"
"eosinophilic pneumonia"
"epidemic typhus"
"erysipelas"
"erysipeloid"
"erythema infectiosum"
"erythropoietic protoporphyria"
"esophageal candidiasis"
"esotropia"
"estrogen excess"
"euthyroid sick syndrome"
"exfoliation syndrome"
"exotropia"
"experimental diabetes mellitus"
"exudative vitreoretinopathy"
"Fabry disease"
"familial combined hyperlipidemia"
"familial dysbetalipoproteinemia"
"familial hypercholesterolemia"
"familial hyperlipidemia"
"familial hypocalciuric hypercalcemia"
"Familial partial lipodystrophy"
"Fanconi syndrome"
"Farber lipogranulomatosis"
"farmer's lung"
"fasciitis"
"fasciolopsiasis"
"fasciolosis"
"fibromyalgia"
"filarial elephantiasis"
"filariasis"
"floater"
"focal segmental glomerulosclerosis"
"folate deficiency"
"Frasier syndrome"
"fungal infection of the central nervous system"
"fungal infectious disease"
"fungal meningitis"
"furunculosis"
"fusariosis"
"galactosemia"
"gangliosidosis"
"gas gangrene"
"gastrointestinal anthrax"
"Gaucher's disease"
"genital herpes"
"Gerstmann-Straussler-Scheinker syndrome"
"giardiasis"
"gigantism"
"Gitelman syndrome"
"glanders"
"glaucoma"
"glomerulonephritis"
"glucocorticoid-remediable aldosteronism"
"glucose intolerance"
"glucose metabolism disease"
"glutaric aciduria type 1"
"glycogen storage disease"
"GM2 gangliosidosis"
"goiter"
"gonadal disease"
"gonorrhea"
"gout"
"gram-negative bacterial infection"
"granulomatous amebic encephalitis"
"granulosa cell tumor"
"Graves' disease"
"hand, foot and mouth disease"
"hantavirus pulmonary syndrome"
"Hartnup disease"
"Haverhill fever"
"hemorrhagic fever with renal syndrome"
"hepatic tuberculosis"
"hepatitis A"
"hepatitis B"
"hepatitis C"
"hepatitis D"
"hepatitis E"
"hereditary coproporphyria"
"Hermansky-Pudlak syndrome"
"hermaphroditism"
"herpangina"
"herpes simplex"
"herpes zoster"
"histoplasmosis"
"HIV seropositivity"
"HIV-associated lipodystrophy"
"homocystinuria"
"hospital-acquired infection"
"human granulocytic anaplasmosis"
"human monocytic ehrlichiosis"
"hydronephrosis"
"hymenolepiasis"
"hyperaldosteronism"
"hyperandrogenism"
"hypercalcemia"
"hyperglycemia"
"hyperhomocysteinemia"
"hyperinsulinemia"
"hyperlipidemia"
"hyperlucent lung"
"hyperopia"
"hyperostosis"
"hyperparathyroidism"
"hyperphosphatemia"
"hyperphosphatemic familial tumoral calcinosis"
"hyperpituitarism"
"hyperprolactinemia"
"hypersomnia"
"hyperthyroidism"
"hyperthyroxinemia"
"hypertriglyceridemia"
"hypertropia"
"hyperuricemia"
"Hypervitaminosis"
"hypervitaminosis D"
"hypervolemia"
"hypobetalipoproteinemia"
"hypocalcaemia"
"Hypoestrogenism"
"hypoglycemia"
"hypogonadism"
"hypokalemia"
"hypolipoproteinemia"
"Hyponatremia"
"hypoparathyroidism"
"hypophosphatasia"
"hypophosphatemia"
"hypophosphatemic rickets"
"hypopituitarism"
"hypopyon"
"hypothyroidism"
"hypoxia"
"idiopathic pulmonary fibrosis"
"inclusion conjunctivitis"
"indeterminate leprosy"
"infectious disease"
"infectious mononucleosis"
"influenza"
"inhalation anthrax"
"inner ear disease"
"insulin coma"
"intermediate uveitis"
"interstitial lung disease"
"interstitial nephritis"
"intestinal infectious disease"
"intestinal schistosomiasis"
"intestinal tuberculosis"
"invasive aspergillosis"
"invasive pulmonary aspergillosis"
"iris disease"
"ischemia"
"isovaleric acidemia"
"Japanese encephalitis"
"joint effusion"
"juvenile neuronal ceroid lipofuscinosis"
"juvenile rheumatoid arthritis"
"Kallmann syndrome"
"Kartagener syndrome"
"keratitis"
"keratoconjunctivitis"
"keratoconjunctivitis sicca"
"keratoconus"
"keratomalacia"
"Keshan disease"
"kidney failure"
"Krabbe disease"
"kuru"
"kwashiorkor"
"Kyasanur forest disease"
"kyphosis"
"La Crosse encephalitis"
"labyrinthitis"
"lactic acidosis"
"lactose intolerance"
"lagophthalmos"
"Laron syndrome"
"laryngospasm"
"Lassa fever"
"late yaws"
"latent syphilis"
"Leber congenital amaurosis"
"Leber hereditary optic neuropathy"
"legionellosis"
"lepromatous leprosy"
"leprosy"
"leptospirosis"
"leukodystrophy"
"Leydig cell tumor"
"Li-Fraumeni syndrome"
"lice infestation"
"lipid metabolism disorder"
"lipid storage disease"
"lipodystrophy"
"lipomatosis"
"listeriosis"
"lobomycosis"
"loiasis"
"louping ill"
"louse-borne relapsing fever"
"lumbar spinal stenosis"
"lung abscess"
"lung disease"
"lung tumor"
"lupus nephritis"
"Lyme disease"
"lymph node tuberculosis"
"lymphangioleiomyomatosis"
"lymphatic abnormality"
"lymphocytic choriomeningitis"
"lymphogranuloma venereum"
"lysinuric protein intolerance"
"lysosomal storage disease"
"macular degeneration"
"macular holes"
"malaria"
"malignant Leydig cell tumor"
"mansonelliasis"
"maple syrup urine disease"
"marasmus"
"Marburg virus disease"
"mastoiditis"
"maturity-onset diabetes of the young"
"measles"
"mediastinal cyst"
"mediastinitis"
"Meesmann corneal dystrophy"
"melioidosis"
"membranous glomerulonephritis"
"meningitis"
"meningococcal meningitis"
"Menkes disease"
"metabolic acidosis"
"metabolic bone disease"
"metabolic syndrome"
"metachromatic leukodystrophy"
"methylmalonic acidemia"
"mevalonic aciduria"
"microsporidiosis"
"miliary tuberculosis"
"mitochondrial disease"
"mitochondrial encephalomyopathy"
"mixed connective tissue disease"
"mixed hyperlipidemia"
"mixed malaria"
"molluscum contagiosum"
"monkeypox"
"mucocutaneous leishmaniasis"
"mucolipidosis"
"Mucolipidosis type IV"
"mucopolysaccharidosis"
"mucopolysaccharidosis I"
"mucosulfatidosis"
"multibacillary leprosy"
"multidrug-resistant tuberculosis"
"multiple acyl-CoA dehydrogenase deficiency"
"multiple carboxylase deficiency"
"multiple endocrine neoplasia"
"multiple symmetric lipomatosis"
"mumps"
"Murray Valley encephalitis"
"Mycoplasma pneumonia"
"Mycoplasma pneumoniae pneumonia"
"myiasis"
"myoglobinuria"
"myopathy"
"myopia"
"myositis"
"myxedema"
"nasopharyngitis"
"necatoriasis"
"necrotizing fasciitis"
"necrotizing ulcerative gingivitis"
"Nelson syndrome"
"neovascular glaucoma"
"nephrogenic diabetes insipidus"
"nephropathia epidemica"
"nephrosclerosis"
"nephrotic syndrome"
"neuritis"
"neuroendocrine tumor"
"neurohypophyseal diabetes insipidus"
"neuronal ceroid lipofuscinosis"
"neuroretinitis"
"neuroschistosomiasis"
"Newcastle disease"
"Niemann-Pick disease"
"Niemann-Pick disease type B"
"night blindness"
"Nijmegen breakage syndrome"
"nocardiosis"
"nodular goiter"
"obesity"
"obstructive lung disease"
"Occipital horn syndrome"
"ocular albinism"
"ocular hypertension"
"oculocerebrorenal syndrome"
"oculocutaneous albinism"
"oculoglandular tularemia"
"Omsk hemorrhagic fever"
"onchocerciasis"
"onychomycosis"
"open-angle glaucoma"
"ophthalmoplegia"
"opisthorchiasis"
"Opportunistic infection"
"opportunistic mycosis"
"optic nerve disease"
"optic neuritis"
"oral candidiasis"
"oral tuberculosis"
"orbital cellulitis"
"orbital myositis"
"ornithosis"
"Oropouche fever"
"osteitis fibrosa"
"osteoarthritis"
"osteochondritis dissecans"
"osteomyelitis"
"osteophyte"
"osteoporosis"
"ostertagiasis"
"otitis media"
"otomycosis"
"ovarian dysfunction"
"panhypopituitarism"
"panniculitis"
"paracoccidioidomycosis"
"paragonimiasis"
"parasitic infectious diseases"
"parasitic skin disease"
"parathyroid gland disease"
"paratyphoid fever"
"pasteurellosis"
"pathologic fracture"
"paucibacillary leprosy"
"Pelizaeus-Merzbacher disease"
"pellagra"
"penicilliosis"
"pericardial tuberculosis"
"peripheral artery disease"
"peroxisomal disease"
"pertussis"
"petechia"
"phaeohyphomycosis"
"phenylketonuria"
"Piedra"
"pituitary apoplexy"
"pituitary carcinoma"
"pityriasis versicolor"
"plague"
"plantar wart"
"Plasmodium falciparum malaria"
"Plasmodium malariae malaria"
"Plasmodium ovale malaria"
"Plasmodium vivax malaria"
"pleural tuberculosis"
"pneumococcal pneumonia"
"pneumoconiosis"
"pneumocystosis"
"pneumonia"
"pneumonic plague"
"pneumonic tularemia"
"pneumothorax"
"poliomyelitis"
"polyarteritis nodosa"
"polycystic ovary syndrome"
"polymyalgia rheumatica"
"Pontiac fever"
"porphyria"
"porphyria cutanea tarda"
"posterior uveitis"
"Powassan encephalitis"
"Precocious puberty"
"premature menopause"
"premature ovarian failure"
"primary amebic meningoencephalitis"
"primary ciliary dyskinesia"
"primary congenital glaucoma"
"primary effusion lymphoma"
"primary hyperoxaluria"
"primary hyperparathyroidism"
"primary syphilis"
"progeria"
"proliferative vitreoretinopathy"
"propionic acidemia"
"protein-energy malnutrition"
"pseudohermaphroditism"
"pseudohypoparathyroidism"
"pseudopseudohypoparathyroidism"
"psoriatic arthritis"
"pulmonary alveolar proteinosis"
"pulmonary cryptococcosis"
"pulmonary cyst"
"pulmonary edema"
"pulmonary embolism"
"pulmonary emphysema"
"pulmonary eosinophilia"
"pulmonary fibrosis"
"pulmonary sarcoidosis"
"pulmonary tuberculosis"
"pycnodysostosis"
"pyomyositis"
"Q fever"
"rabies"
"ranula"
"Reflux nephropathy"
"refractive error"
"renal glycosuria"
"renal osteodystrophy"
"renal tuberculosis"
"renal tubular acidosis"
"renovascular hypertension"
"respiratory failure"
"retinal degeneration"
"retinal detachment"
"retinal disease"
"retinal vascular occlusion"
"retinal vein occlusion"
"retinitis"
"retinitis pigmentosa"
"retinopathy of prematurity"
"retinoschisis"
"rheumatoid arthritis"
"rhinitis"
"rhinoscleroma"
"rhinosporidiosis"
"rickets"
"rickettsialpox"
"Rift Valley fever"
"Rocky Mountain spotted fever"
"Ross River fever"
"rubella"
"rubeosis iridis"
"sacroiliitis"
"salmonellosis"
"Sandhoff disease"
"Sanfilippo syndrome"
"sarcocystosis"
"sarcoidosis"
"scabies"
"scarlet fever"
"schistosomiasis"
"scotoma"
"scrub typhus"
"scurvy"
"secondary hyperparathyroidism"
"secondary syphilis"
"sensorineural hearing loss"
"septic arthritis"
"septic shock"
"Sertoli-Leydig cell tumor"
"shigellosis"
"sialuria"
"Siberian tick typhus"
"silicosis"
"silicotuberculosis"
"sitosterolemia"
"Sjögren's syndrome"
"skeletal tuberculosis"
"sleep disorder"
"sleep paralysis"
"sleeping sickness"
"Sly syndrome"
"smallpox"
"somatostatinoma"
"sparganosis"
"sphingolipidosis"
"spinal stenosis"
"spirochetal diseases"
"splenic tuberculosis"
"spondylitis"
"spondyloarthropathy"
"sporotrichosis"
"spotted fever"
"St. Louis encephalitis"
"staphylococcal skin infection"
"strabismus"
"strongyloidiasis"
"subacute sclerosing panencephalitis"
"subacute thyroiditis"
"suppurative thyroiditis"
"sweating sickness"
"swine influenza"
"sympathetic ophthalmia"
"synovitis"
"syphilis"
"systemic lupus erythematosus"
"T-cell lymphoma"
"tabes dorsalis"
"taeniasis"
"Tangier disease"
"tapeworm infection"
"Tay-Sachs disease"
"Tay-Sachs disease AB variant"
"tenosynovitis"
"tertiary neurosyphilis"
"tertiary syphilis"
"tetanus"
"tetany"
"thelaziasis"
"thoracic disease"
"thrombosis"
"thyroid carcinoma"
"thyroid crisis"
"thyroid gland disease"
"thyroid hormone resistance syndrome"
"thyroiditis"
"thyrotoxicosis"
"tick infestation"
"tick-borne encephalitis"
"tick-borne relapsing fever"
"Tinea"
"tinea barbae"
"tinea capitis"
"tinea corporis"
"tinea cruris"
"tinea favosa"
"tinea manuum"
"tinea nigra"
"tinea pedis"
"toxic shock syndrome"
"toxocariasis"
"toxoplasmosis"
"tracheitis"
"tracheomalacia"
"trachoma"
"transmissible spongiform encephalopathy"
"traveler's diarrhea"
"trench fever"
"trichinosis"
"trichomoniasis"
"trichosporonosis"
"trichuriasis"
"trypanosomiasis"
"tuberculoid leprosy"
"tuberculosis"
"tuberculous peritonitis"
"tuberculous salpingitis"
"tularemia"
"tungiasis"
"type 1 diabetes mellitus"
"type 2 diabetes mellitus"
"typhoid fever"
"typhus"
"tyrosinemia type I"
"ulceroglandular tularemia"
"urea cycle disorder"
"urinary schistosomiasis"
"uveitis"
"vaccinia"
"variant Creutzfeldt–Jakob"
"variegate porphyria"
"variola major"
"vascular calcification"
"vascular disease"
"vasculitis"
"Venezuelan equine encephalitis"
"ventilator-associated pneumonia"
"vestibular disease"
"vestibular neuronitis"
"VIPoma"
"viral encephalitis"
"viral hepatitis"
"viral infectious disease"
"viral pneumonia"
"visceral leishmaniasis"
"vitamin B12 deficiency"
"vitamin K deficiency"
"vitreous detachment"
"Vitreous hemorrhage"
"WAGR syndrome"
"Werner syndrome"
"West Nile encephalitis"
"West Nile fever"
"Western equine encephalitis"
"Wilson disease"
"Wolman disease"
"X-linked adrenoleukodystrophy"
"X-linked hypophosphatemic rickets"
"xanthinuria"
"xanthomatosis"
"xerophthalmia"
"yaws"
"yellow fever"
"yersiniosis"
"Zika fever"
"Zollinger-Ellison syndrome"
}
         FILTER (lang(?label) = "en")
         FILTER (str(?label) = ?term)
         
         }

Try it!

NDF-RT issue[edit]

See Wikidata talk:WikiProject Medicine#medical condition treated (P2175) matters for why NDF-RT (Q21008030) may no longer be a good reference.

#Locating P2175 statements referenced to the NDF-RT database
SELECT DISTINCT ?drug ?drugLabel ?disease ?diseaseLabel
  WHERE {?reference pr:P248 wd:Q21008030.
         ?statement prov:wasDerivedFrom ?reference.
         ?statement ps:P2175 ?disease.
         ?drug p:P2175 ?statement.
        
       SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
         
        }

Try it!

Variant for a maintenance query:

#Locating "instance of review article" statements referenced to PubMed Central
SELECT DISTINCT ?statement
  WHERE {
         ?reference pr:P248 wd:Q229883.
         ?statement prov:wasDerivedFrom ?reference.
         ?statement ps:P31 wd:Q7318358.  
       
         SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
         
        }

Try it!