diff options
author | zsloan | 2019-11-21 14:55:50 -0600 |
---|---|---|
committer | zsloan | 2019-11-21 14:55:50 -0600 |
commit | 8427ddfd7b60d74f4be3a453dd0b21ce7bfdb6f3 (patch) | |
tree | 4a036c0613cce54b067476e4f1c6a881c6ff4bb2 | |
parent | 74e81163fb3c2418b88f6d4fbb99760c63a3fea6 (diff) | |
download | genenetwork2-8427ddfd7b60d74f4be3a453dd0b21ce7bfdb6f3.tar.gz |
Added 3-letter codes to unpublished phenotype traits and fixed issue with ordering phenotype results from searches
-rw-r--r-- | wqflask/base/data_set.py | 19 | ||||
-rw-r--r-- | wqflask/base/trait.py | 9 | ||||
-rw-r--r-- | wqflask/wqflask/do_search.py | 6 | ||||
-rw-r--r-- | wqflask/wqflask/gsearch.py | 6 | ||||
-rw-r--r-- | wqflask/wqflask/search_results.py | 4 | ||||
-rw-r--r-- | wqflask/wqflask/show_trait/show_trait.py | 1 | ||||
-rw-r--r-- | wqflask/wqflask/templates/gsearch_gene.html | 6 | ||||
-rw-r--r-- | wqflask/wqflask/templates/gsearch_pheno.html | 8 | ||||
-rw-r--r-- | wqflask/wqflask/templates/search_result_page.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 13 |
11 files changed, 47 insertions, 29 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index f58367ca..6e07e383 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -26,6 +26,7 @@ import collections import codecs import json +import requests import gzip import cPickle as pickle import itertools @@ -63,7 +64,7 @@ logger = getLogger(__name__ ) # Each subclass will add to this DS_NAME_MAP = {} -def create_dataset(dataset_name, dataset_type = None, get_samplelist = True, group_name = None): +def create_dataset(dataset_name, rebuild=True, dataset_type = None, get_samplelist = True, group_name = None): if not dataset_type: dataset_type = Dataset_Getter(dataset_name) logger.debug("dataset_type", dataset_type) @@ -77,7 +78,7 @@ def create_dataset(dataset_name, dataset_type = None, get_samplelist = True, gro class Dataset_Types(object): - def __init__(self): + def __init__(self, rebuild=False): """Create a dictionary of samples where the value is set to Geno, Publish or ProbeSet. E.g. @@ -93,8 +94,10 @@ Publish or ProbeSet. E.g. """ self.datasets = {} - if USE_GN_SERVER: - data = gen_menu.gen_dropdown_json() + if rebuild: #ZS: May make this the only option + data = json.loads(requests.get("http://gn2.genenetwork.org/api/v_pre1/gen_dropdown").content) + logger.debug("THE DATA:", data) + #data = gen_menu.gen_dropdown_json() else: file_name = "wqflask/static/new/javascript/dataset_menu_structure.json" with open(file_name, 'r') as fh: @@ -119,12 +122,8 @@ Publish or ProbeSet. E.g. def __call__(self, name): return self.datasets[name] -def rebuild_dataset_ob(): - Dataset_Getter = Dataset_Types() - return Dataset_Getter - # Do the intensive work at startup one time only -Dataset_Getter = rebuild_dataset_ob() +Dataset_Getter = Dataset_Types() def create_datasets_list(): if USE_REDIS: @@ -705,7 +704,7 @@ class PhenotypeDataSet(DataSet): 'PublishXRef.Id'] # Figure out what display_fields is - self.display_fields = ['name', + self.display_fields = ['name', 'group_code', 'pubmed_id', 'pre_publication_description', 'post_publication_description', diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 322fb252..5fae34cf 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -352,7 +352,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): if dataset.type == 'Publish': query = """ SELECT - PublishXRef.Id, Publication.PubMed_ID, + PublishXRef.Id, InbredSet.InbredSetCode, Publication.PubMed_ID, Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description, Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation, Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users, @@ -361,12 +361,13 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): Publication.Month, Publication.Year, PublishXRef.Sequence, Phenotype.Units, PublishXRef.comments FROM - PublishXRef, Publication, Phenotype, PublishFreeze + PublishXRef, Publication, Phenotype, PublishFreeze, InbredSet WHERE PublishXRef.Id = %s AND Phenotype.Id = PublishXRef.PhenotypeId AND Publication.Id = PublishXRef.PublicationId AND PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND + PublishXRef.InbredSetId = InbredSet.Id AND PublishFreeze.Id = %s """ % (trait.name, dataset.id) @@ -428,6 +429,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): # holder = unicode(trait_info[i], "utf-8", "ignore") setattr(trait, field, holder) + trait.display_name = trait.name if dataset.type == 'Publish': trait.confidential = 0 if trait.pre_publication_description and not trait.pubmed_id: @@ -462,6 +464,9 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): if trait.pubmed_id: trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % trait.pubmed_id + else: + if trait.group_code: + trait.display_name = trait.group_code + "_" + str(trait.name) if dataset.type == 'ProbeSet' and dataset.group: description_string = unicode(str(trait.description).strip(codecs.BOM_UTF8), 'utf-8') diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index b6580bbe..0df72b0d 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -251,7 +251,8 @@ class PhenotypeSearch(DoSearch): WHERE PublishXRef.InbredSetId = %s and PublishXRef.PhenotypeId = Phenotype.Id and PublishXRef.PublicationId = Publication.Id - and PublishFreeze.Id = %s""" % ( + and PublishFreeze.Id = %s + ORDER BY PublishXRef.Id""" % ( from_clause, escape(str(self.dataset.group.id)), escape(str(self.dataset.id)))) @@ -262,7 +263,8 @@ class PhenotypeSearch(DoSearch): and PublishXRef.InbredSetId = %s and PublishXRef.PhenotypeId = Phenotype.Id and PublishXRef.PublicationId = Publication.Id - and PublishFreeze.Id = %s""" % ( + and PublishFreeze.Id = %s + ORDER BY PublishXRef.Id""" % ( from_clause, where_clause, escape(str(self.dataset.group.id)), diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py index dbb77826..53e5f2b7 100644 --- a/wqflask/wqflask/gsearch.py +++ b/wqflask/wqflask/gsearch.py @@ -118,7 +118,8 @@ class GSearch(object): Publication.`Year`, Publication.`PubMed_ID`, PublishXRef.`LRS`, - PublishXRef.`additive` + PublishXRef.`additive`, + InbredSet.`InbredSetCode` FROM Species,InbredSet,PublishFreeze,PublishXRef,Phenotype,Publication WHERE PublishXRef.`InbredSetId`=InbredSet.`Id` AND PublishFreeze.`InbredSetId`=InbredSet.`Id` @@ -146,6 +147,7 @@ class GSearch(object): this_trait = {} this_trait['index'] = i + 1 this_trait['name'] = str(line[4]) + this_trait['display_name'] = this_trait['name'] this_trait['dataset'] = line[2] this_trait['dataset_fullname'] = line[3] this_trait['hmac'] = user_manager.data_hmac('{}:{}'.format(line[4], line[2])) @@ -167,6 +169,8 @@ class GSearch(object): this_trait['pubmed_link'] = webqtlConfig.PUBMEDLINK_URL % line[8] else: this_trait['pubmed_link'] = "N/A" + if line[12]: + this_trait['display_name'] = line[12] + "_" + str(this_trait['name']) this_trait['LRS_score_repr'] = "N/A" if line[10] != "" and line[10] != None: this_trait['LRS_score_repr'] = '%3.1f' % line[10] diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 5a5a850b..2ac6d4b5 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -110,6 +110,10 @@ views.py). trait_dict['index'] = index + 1 this_trait = trait.GeneralTrait(dataset=self.dataset, name=trait_id, get_qtl_info=True, get_sample_info=False) trait_dict['name'] = this_trait.name + if this_trait.dataset.type == "Publish": + trait_dict['display_name'] = this_trait.display_name + else: + trait_dict['display_name'] = this_trait.name trait_dict['dataset'] = this_trait.dataset.name trait_dict['hmac'] = user_manager.data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name)) if this_trait.dataset.type == "ProbeSet": diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 64597711..09004396 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -45,7 +45,6 @@ class ShowTrait(object): if 'trait_id' in kw and kw['dataset'] != "Temp": self.temp_trait = False self.trait_id = kw['trait_id'] - data_set.rebuild_dataset_ob() helper_functions.get_species_dataset_trait(self, kw) elif 'group' in kw: self.temp_trait = True diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 1a4ff752..85127e99 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -9,8 +9,10 @@ <div class="container" style="width: 2000px;"> - <h3>GN searched 754 datasets and 39,765,944 traits across 10 species, and found {{ trait_count }} results that match your query. - You can filter these results by adding key words in the fields below and you can also sort results on most columns.</h3> + <h3>GN searched for the term(s) <b>"{{ terms }}"</b> in 754 datasets and 39,765,944 traits across 10 species<br/> + and found <b>{{ trait_count }}</b> results that match your query.<br/> + You can filter these results by adding key words in the fields below<br/> + and you can also sort results on most columns.</h3> <p>To study a record, click on its Record ID below.<br />Check records below and click Add button to add to selection.</p> <div> diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html index c626a589..bc88a76e 100644 --- a/wqflask/wqflask/templates/gsearch_pheno.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -9,8 +9,10 @@ <div class="container"> - <h3>GN searched 51 datasets and 13763 traits across 10 species, and found {{ trait_count }} results that match your query. - You can filter these results by adding key words in the fields below and you can also sort results on most columns.</h3> + <h3>GN searched for the term(s) <b>"{{ terms }}"</b> in 51 datasets and 13763 traits across 10 species<br/> + and found <b>{{ trait_count }}</b> results that match your query.<br/> + You can filter these results by adding key words in the fields below<br/> + and you can also sort results on most columns.</h3> <p>To study a record, click on its ID below.<br />Check records below and click Add button to add to selection.</p> <div> @@ -160,7 +162,7 @@ 'type': "natural", 'data': null, 'render': function(data, type, row, meta) { - return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.name + '</a>' + return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.display_name + '</a>' } }, { diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 262a563d..b66540d7 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -276,7 +276,7 @@ 'width': "60px", 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { - return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.name + '</a>' + return '<a href="/show_trait?trait_id=' + data.name + '&dataset=' + data.dataset + '">' + data.display_name + '</a>' } }{% if dataset.type == 'ProbeSet' %}, { diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 0f49b092..0b4618f1 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -15,7 +15,7 @@ {% block content %} <!-- Start of body --> <div class="container"> - <h2>Trait Data and Analysis for <b>{{ this_trait.name }}</b></h2> + <h2>Trait Data and Analysis for <b>{{ this_trait.display_name }}</b></h2> {% if this_trait.dataset.type != 'Publish' %} <h3>{{ this_trait.description_fmt[0]|upper }}{{ this_trait.description_fmt[1:] }}</h3> {% endif %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index bff9f9d2..1c513591 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -125,12 +125,13 @@ def index_page(): import_collections = params['import_collections'] if import_collections == "true": g.cookie_session.import_traits_to_user() - if USE_GN_SERVER: - # The menu is generated using GN_SERVER - return render_template("index_page.html", gn_server_url = GN_SERVER_URL, version=GN_VERSION) - else: - # Old style static menu (OBSOLETE) - return render_template("index_page_orig.html", version=GN_VERSION) + #if USE_GN_SERVER: + # # The menu is generated using GN_SERVER + # return render_template("index_page.html", gn_server_url = GN_SERVER_URL, version=GN_VERSION) + #else: + + # Old style static menu (OBSOLETE) + return render_template("index_page_orig.html", version=GN_VERSION) @app.route("/tmp/<img_path>") |