From de77a333a7bcc7260e5cf91bf786f84c9c68bc06 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 18 Feb 2020 15:47:32 -0600 Subject: Added NCBI summary to trait page when applicable --- wqflask/wqflask/show_trait/show_trait.py | 18 +++++++++++++++++- wqflask/wqflask/templates/show_trait_details.html | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 4efaa968..10ce38a7 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -5,6 +5,7 @@ import os import datetime import cPickle import uuid +import requests import json as json from collections import OrderedDict @@ -129,6 +130,8 @@ class ShowTrait(object): self.get_external_links() self.build_correlation_tools() + self.ncbi_summary = get_ncbi_summary(self.this_trait) + #Get nearest marker for composite mapping if not self.temp_trait: if check_if_attr_exists(self.this_trait, 'locus_chr') and self.dataset.type != "Geno" and self.dataset.type != "Publish": @@ -560,4 +563,17 @@ def check_if_attr_exists(the_trait, id_type): else: return True else: - return False \ No newline at end of file + return False + +def get_ncbi_summary(this_trait): + if check_if_attr_exists(this_trait, 'geneid'): + #ZS: Need to switch this try/except to something that checks the output later + try: + response = requests.get("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=%s&retmode=json" % this_trait.geneid) + logger.debug("NCBI:", json.loads(response.content)['result'][this_trait.geneid]) + summary = json.loads(response.content)['result'][this_trait.geneid]['summary'] + return summary + except: + return None + else: + return None \ No newline at end of file diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html index 3584be22..20dee54e 100644 --- a/wqflask/wqflask/templates/show_trait_details.html +++ b/wqflask/wqflask/templates/show_trait_details.html @@ -50,6 +50,12 @@