diff --git a/scholia/app/templates/disease-index.html b/scholia/app/templates/disease-index.html index cfac23eab..743d27b41 100644 --- a/scholia/app/templates/disease-index.html +++ b/scholia/app/templates/disease-index.html @@ -4,20 +4,62 @@ {% block page_content %} -

Disease

+

Diseases

-Diseases. +
-

Examples

+

Examples

- +
+
-{% endblock %} +
+

Single items

+
+
+
+
Schizophrenia
+
+ A mental disorder characterized by continuous or relapsing episodes of psychosis. +
+ +
Microcephaly
+
+ A medical condition involving a smaller-than-normal head. +
+ +
Rett syndrome
+
+ A genetic disorder that typically becomes apparent after 6–18 months of age and almost exclusively in females. +
+ +
Zika fever
+
+ An infectious disease caused by the Zika virus. +
+ +
Fatty liver disease
+
+ A condition where excess fat builds up in the liver. +
+
+
- +
+ +
+
+

Redirecting

+
+
+

If you know the identifier, then Scholia can make a lookup based on the identifier:

+ +
+
omim/137580
+
Look up OMIM ID 137580. This will redirect to Tourette syndrome.
+
+
+
+
+ +{% endblock %} diff --git a/scholia/app/views.py b/scholia/app/views.py index 6dc099424..703542822 100644 --- a/scholia/app/views.py +++ b/scholia/app/views.py @@ -16,7 +16,7 @@ from ..arxiv import get_metadata as get_arxiv_metadata from ..query import (arxiv_to_qs, cas_to_qs, atomic_symbol_to_qs, doi_to_qs, doi_prefix_to_qs, github_to_qs, biorxiv_to_qs, - chemrxiv_to_qs, + chemrxiv_to_qs, omim_to_qs, identifier_to_qs, inchikey_to_qs, issn_to_qs, orcid_to_qs, viaf_to_qs, q_to_class, q_to_dois, random_author, twitter_to_qs, cordis_to_qs, mesh_to_qs, pubmed_to_qs, @@ -1084,6 +1084,23 @@ def redirect_mesh(meshid): return render_template('404.html', error=could_not_find("MeSH ID")) +@main.route('/omim/') +def redirect_omim(omimID): + """Detect and redirect for OMIM identifiers. + + Parameters + ---------- + omim : str + OMIM identifier. + + """ + qs = omim_to_qs(omimID) + if len(qs) > 0: + q = qs[0] + return redirect(url_for('app.show_author', q=q), code=302) + return render_template('404.html', error=could_not_find("OMIM ID")) + + @main.route('/orcid/') def redirect_orcid(orcid): """Detect and redirect for ORCID. diff --git a/scholia/query.py b/scholia/query.py index 20c2e6979..b9c62d2fa 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -18,6 +18,7 @@ scholia.query mesh-to-q scholia.query ncbi-gene-to-q scholia.query ncbi-taxon-to-q + scholia.query omim-to-q scholia.query orcid-to-q scholia.query pubchem-to-q scholia.query pubmed-to-q @@ -772,6 +773,37 @@ def issn_to_qs(issn): for item in data['results']['bindings']] +def omim_to_qs(omimID): + """Convert OMIM identifier to Wikidata ID. + + Parameters + ---------- + omim : str + OMIM identifier + + Returns + ------- + qs : list of str + List of strings with Wikidata IDs. + + Examples + -------- + >>> omim_to_qs('181500') == ['Q41112'] + True + + """ + query = 'select ?disease where {{ ?disease wdt:P492 "{omimID}" }}'.format( + omimID=escape_string(omimID)) + + url = 'https://query.wikidata.org/sparql' + params = {'query': query, 'format': 'json'} + response = requests.get(url, params=params, headers=HEADERS) + data = response.json() + + return [item['disease']['value'][31:] + for item in data['results']['bindings']] + + def orcid_to_qs(orcid): """Convert orcid to Wikidata ID. @@ -1757,6 +1789,11 @@ def main(): if len(qs) > 0: print(qs[0]) + elif arguments['omim-to-q']: + qs = omim_to_qs(arguments['']) + if len(qs) > 0: + print(qs[0]) + elif arguments['orcid-to-q']: qs = orcid_to_qs(arguments['']) if len(qs) > 0: