--
cgit v1.2.3
From c8f9367bc12340bb8b8a7ce1a5f42789e311555a Mon Sep 17 00:00:00 2001
From: zsloan
Date: Mon, 19 Apr 2021 16:57:52 +0000
Subject: Removed commented out js file
---
wqflask/wqflask/templates/base.html | 1 -
1 file changed, 1 deletion(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html
index 1fbaad51..e6f22deb 100644
--- a/wqflask/wqflask/templates/base.html
+++ b/wqflask/wqflask/templates/base.html
@@ -257,7 +257,6 @@
-
--
cgit v1.2.3
From 789dd88a0b9a6a8cbe0413c47212c89c1681765c Mon Sep 17 00:00:00 2001
From: zsloan
Date: Mon, 19 Apr 2021 17:08:30 +0000
Subject: Removedu nused function from network_graph.py
---
wqflask/wqflask/network_graph/network_graph.py | 12 ------------
1 file changed, 12 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/network_graph/network_graph.py b/wqflask/wqflask/network_graph/network_graph.py
index 1d5316a2..132e1884 100644
--- a/wqflask/wqflask/network_graph/network_graph.py
+++ b/wqflask/wqflask/network_graph/network_graph.py
@@ -182,15 +182,3 @@ class NetworkGraph(object):
samples=self.all_sample_list,
sample_data=self.sample_data,
elements=self.elements,)
-
- def get_trait_db_obs(self, trait_db_list):
- self.trait_list = []
- for i, trait_db in enumerate(trait_db_list):
- if i == (len(trait_db_list) - 1):
- break
- trait_name, dataset_name = trait_db.split(":")
- dataset_ob = data_set.create_dataset(dataset_name)
- trait_ob = create_trait(dataset=dataset_ob,
- name=trait_name,
- cellid=None)
- self.trait_list.append((trait_ob, dataset_ob))
--
cgit v1.2.3
From 68ee0a995fceaf6aefdd3c8f780e46a83b51a0e8 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Mon, 19 Apr 2021 17:11:41 +0000
Subject: Specify only getting the first two items after splitting the
trait/dataset input string
---
wqflask/utility/helper_functions.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'wqflask')
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py
index 7eb7f013..46eeb35d 100644
--- a/wqflask/utility/helper_functions.py
+++ b/wqflask/utility/helper_functions.py
@@ -40,7 +40,7 @@ def get_trait_db_obs(self, trait_db_list):
data, _separator, hmac_string = trait.rpartition(':')
data = data.strip()
assert hmac_string==hmac.hmac_creation(data), "Data tampering?"
- trait_name, dataset_name = data.split(":")
+ trait_name, dataset_name = data.split(":")[:2]
if dataset_name == "Temp":
dataset_ob = data_set.create_dataset(dataset_name=dataset_name, dataset_type="Temp", group_name=trait_name.split("_")[2])
else:
--
cgit v1.2.3
From 34e4933de5a1cd444abe618fcfd93b424bf3442e Mon Sep 17 00:00:00 2001
From: Alexander Kabui
Date: Tue, 20 Apr 2021 01:38:26 +0300
Subject: refactor code for iterating mrna tissue data
---
wqflask/base/mrna_assay_tissue_data.py | 39 +++++++++++++++++++---
.../wqflask/correlation/correlation_functions.py | 6 ++--
wqflask/wqflask/correlation/correlation_gn3_api.py | 24 +++++++------
3 files changed, 51 insertions(+), 18 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py
index f1929518..0220d73b 100644
--- a/wqflask/base/mrna_assay_tissue_data.py
+++ b/wqflask/base/mrna_assay_tissue_data.py
@@ -6,6 +6,7 @@ from utility import db_tools
from utility import Bunch
from utility.db_tools import escape
+from gn3.db_utils import database_connector
from utility.logger import getLogger
@@ -44,16 +45,42 @@ class MrnaAssayTissueData(object):
and t.Mean = x.maxmean;
'''.format(in_clause)
- results = g.db.execute(query).fetchall()
- lower_symbols = []
+ # lower_symbols = []
+ lower_symbols = {}
for gene_symbol in gene_symbols:
+ # lower_symbols[gene_symbol.lower()] = True
if gene_symbol != None:
- lower_symbols.append(gene_symbol.lower())
-
+ lower_symbols[gene_symbol.lower()] = True
+
+ import time
+ # initial_time = time.time()
+ # conn,cursor = database_connector()
+ # cursor.execute(query)
+ # for result in cursor.fetchall():
+ # symbol = result[0]
+ # self.data[symbol].gene_id = result[1]
+ # self.data[symbol].data_id = result[2]
+ # self.data[symbol].chr = result[3]
+ # self.data[symbol].mb = result[4]
+ # self.data[symbol].description = result[5]
+ # self.data[symbol].probe_target_description = result[6]
+
+
+ # print("my loop takes>>>>",time.time()-initial_time)
+ # conn.close()
+ # r
+
+ # takes 5 seconds
+ initial_time = time.time()
+ results = list(g.db.execute(query).fetchall())
for result in results:
symbol = result[0]
- if symbol.lower() in lower_symbols:
+ # if symbol is not None
+ # exists = lower_symbols.get(symbol.lower())
+ # if symbol.lower() in lower_symbols:
+ if symbol is not None and lower_symbols.get(symbol.lower()):
+
symbol = symbol.lower()
self.data[symbol].gene_id = result.GeneId
@@ -62,6 +89,7 @@ class MrnaAssayTissueData(object):
self.data[symbol].mb = result.Mb
self.data[symbol].description = result.description
self.data[symbol].probe_target_description = result.Probe_Target_Description
+ print("time taken in the loop is",time.time()-initial_time)
###########################################################################
#Input: cursor, symbolList (list), dataIdDict(Dict)
@@ -82,6 +110,7 @@ class MrnaAssayTissueData(object):
WHERE TissueProbeSetData.Id IN {} and
TissueProbeSetXRef.DataId = TissueProbeSetData.Id""".format(db_tools.create_in_clause(id_list))
+
results = g.db.execute(query).fetchall()
for result in results:
if result.Symbol.lower() not in symbol_values_dict:
diff --git a/wqflask/wqflask/correlation/correlation_functions.py b/wqflask/wqflask/correlation/correlation_functions.py
index fd7691d4..af1d6060 100644
--- a/wqflask/wqflask/correlation/correlation_functions.py
+++ b/wqflask/wqflask/correlation/correlation_functions.py
@@ -82,6 +82,6 @@ def cal_zero_order_corr_for_tiss (primaryValue=[], targetValue=[], method='pears
def get_trait_symbol_and_tissue_values(symbol_list=None):
tissue_data = MrnaAssayTissueData(gene_symbols=symbol_list)
-
- if len(tissue_data.gene_symbols):
- return tissue_data.get_symbol_values_pairs()
+ if len(tissue_data.gene_symbols) >0:
+ results = tissue_data.get_symbol_values_pairs()
+ return results
diff --git a/wqflask/wqflask/correlation/correlation_gn3_api.py b/wqflask/wqflask/correlation/correlation_gn3_api.py
index ba606b92..e7394647 100644
--- a/wqflask/wqflask/correlation/correlation_gn3_api.py
+++ b/wqflask/wqflask/correlation/correlation_gn3_api.py
@@ -12,6 +12,7 @@ from gn3.computations.correlations import compute_all_sample_correlation
from gn3.computations.correlations import map_shared_keys_to_values
from gn3.computations.correlations import compute_all_tissue_correlation
from gn3.computations.correlations import compute_all_lit_correlation
+from gn3.computations.correlations import experimental_compute_all_tissue_correlation
from gn3.db_utils import database_connector
GN3_CORRELATION_API = "http://127.0.0.1:8202/api/correlation"
@@ -37,7 +38,6 @@ def process_samples(start_vars, sample_names, excluded_samples=None):
def create_target_this_trait(start_vars):
"""this function creates the required trait and target dataset for correlation"""
-
this_dataset = data_set.create_dataset(dataset_name=start_vars['dataset'])
target_dataset = data_set.create_dataset(
dataset_name=start_vars['corr_dataset'])
@@ -81,7 +81,7 @@ def compute_correlation(start_vars, method="pearson"):
target_dataset.get_trait_data(list(sample_data.keys()))
this_trait = retrieve_sample_data(this_trait, this_dataset)
- print("Creating dataset and trait took",time.time()-initial_time)
+ print("Creating dataset and trait took", time.time()-initial_time)
this_trait_data = {
"trait_sample_data": sample_data,
@@ -94,7 +94,7 @@ def compute_correlation(start_vars, method="pearson"):
this_trait=this_trait_data,
target_dataset=results)
- print("doing sample correlation took",time.time()-initial_time)
+ print("doing sample correlation took", time.time()-initial_time)
# requests_url = f"{GN3_CORRELATION_API}/sample_x/{method}"
return correlation_results
@@ -109,11 +109,16 @@ def compute_correlation(start_vars, method="pearson"):
"target_tissues_dict": target_tissue_data
}
initial_time = time.time()
- correlation_results = compute_all_tissue_correlation(primary_tissue_dict=corr_input_data["primary_tissue"],
- target_tissues_data=corr_input_data["target_tissues_dict"],
- corr_method=method)
- print("time taken for compute tissue is",time.time()-initial_time)
-
+ correlation_results = experimental_compute_all_tissue_correlation(primary_tissue_dict=corr_input_data["primary_tissue"],
+ target_tissues_data=corr_input_data[
+ "target_tissues_dict"],
+ corr_method=method)
+ print("correlation y took", time.time()-initial_time)
+ # initial_time = time.time()
+ # correlation_results = compute_all_tissue_correlation(primary_tissue_dict=corr_input_data["primary_tissue"],
+ # target_tissues_data=corr_input_data["target_tissues_dict"],
+ # corr_method=method)
+ # print("time taken for compute tissue is", time.time()-initial_time)
# requests_url = f"{GN3_CORRELATION_API}/tissue_corr/{method}"
return correlation_results
@@ -131,7 +136,7 @@ def compute_correlation(start_vars, method="pearson"):
species=species, gene_id=this_trait_geneid)
return lit_corr_results
- print("the time taken is",time.time()-initial_time)
+ print("the time taken is", time.time()-initial_time)
# requests_url = f"{GN3_CORRELATION_API}/lit_corr/{species}/{this_trait_geneid}"
# corr_input_data = geneid_dict
# corr_results = requests.post(requests_url, json=corr_input_data)
@@ -161,7 +166,6 @@ def get_tissue_correlation_input(this_trait, trait_symbol_dict):
primary_trait_tissue_values = primary_trait_tissue_vals_dict[this_trait.symbol.lower(
)]
- time_to_to_fetch_all = time.time()
corr_result_tissue_vals_dict = correlation_functions.get_trait_symbol_and_tissue_values(
symbol_list=list(trait_symbol_dict.values()))
primary_tissue_data = {
--
cgit v1.2.3
From 315d7f13b254aa62e277805d7d9816b0c7042479 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 22 Apr 2021 18:23:50 +0000
Subject: Added JS that sets the 'add to collection' dropdown to default to the
collection the use set as their default collection
---
wqflask/wqflask/static/new/javascript/search_results.js | 11 +++++++++++
1 file changed, 11 insertions(+)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js
index ecb1220d..48b9b7be 100644
--- a/wqflask/wqflask/static/new/javascript/search_results.js
+++ b/wqflask/wqflask/static/new/javascript/search_results.js
@@ -326,4 +326,15 @@ $(function() {
} );
}
+ apply_default = function() {
+ let default_collection_id = $.cookie('default_collection');
+ if (default_collection_id) {
+ let the_option = $('[name=existing_collection] option').filter(function() {
+ return ($(this).text().split(":")[0] == default_collection_id);
+ })
+ the_option.prop('selected', true);
+ }
+ }
+ apply_default();
+
});
\ No newline at end of file
--
cgit v1.2.3
From 1a7bb988ee360b3ef48e22e25b419c375dccb9fa Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 22 Apr 2021 18:26:01 +0000
Subject: Account for situations where the trait symbol is null for ProbeSet
traits; previously it could throw an error
---
wqflask/wqflask/search_results.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index f23c0582..cb01a2af 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -119,7 +119,7 @@ class SearchResultPage(object):
trait_dict['dataset'] = this_trait.dataset.name
trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name))
if this_trait.dataset.type == "ProbeSet":
- trait_dict['symbol'] = this_trait.symbol
+ trait_dict['symbol'] = this_trait.symbol if this_trait.symbol else "N/A"
trait_dict['description'] = "N/A"
if this_trait.description_display:
trait_dict['description'] = this_trait.description_display
--
cgit v1.2.3
From b0ccb12682fed83bf72d22ff42f1f442a8e6176e Mon Sep 17 00:00:00 2001
From: BonfaceKilz
Date: Mon, 19 Apr 2021 14:43:16 +0300
Subject: Remove stale comments
---
wqflask/base/data_set.py | 11 ----
wqflask/utility/helper_functions.py | 4 --
wqflask/wqflask/show_trait/show_trait.py | 72 +++++++++++++++-----------
wqflask/wqflask/templates/index_page_orig.html | 10 ----
wqflask/wqflask/templates/submit_trait.html | 12 -----
wqflask/wqflask/views.py | 23 ++------
6 files changed, 46 insertions(+), 86 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 178234fe..cc5a428c 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -262,8 +262,6 @@ class Markers(object):
elif isinstance(p_values, dict):
filtered_markers = []
for marker in self.markers:
- #logger.debug("marker[name]", marker['name'])
- #logger.debug("p_values:", p_values)
if marker['name'] in p_values:
#logger.debug("marker {} IS in p_values".format(i))
marker['p_value'] = p_values[marker['name']]
@@ -276,10 +274,6 @@ class Markers(object):
marker['lrs_value'] = - \
math.log10(marker['p_value']) * 4.61
filtered_markers.append(marker)
- # else:
- #logger.debug("marker {} NOT in p_values".format(i))
- # self.markers.remove(marker)
- #del self.markers[i]
self.markers = filtered_markers
@@ -306,7 +300,6 @@ class HumanMarkers(Markers):
marker['Mb'] = float(splat[3]) / 1000000
self.markers.append(marker)
- #logger.debug("markers is: ", pf(self.markers))
def add_pvalues(self, p_values):
super(HumanMarkers, self).add_pvalues(p_values)
@@ -520,7 +513,6 @@ def datasets(group_name, this_group=None):
break
if tissue_already_exists:
- #logger.debug("dataset_menu:", dataset_menu[i]['datasets'])
dataset_menu[i]['datasets'].append((dataset, dataset_short))
else:
dataset_menu.append(dict(tissue=tissue_name,
@@ -735,9 +727,6 @@ class PhenotypeDataSet(DataSet):
DS_NAME_MAP['Publish'] = 'PhenotypeDataSet'
def setup(self):
-
- #logger.debug("IS A PHENOTYPEDATASET")
-
# Fields in the database table
self.search_fields = ['Phenotype.Post_publication_description',
'Phenotype.Pre_publication_description',
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py
index 7eb7f013..15d5b3ab 100644
--- a/wqflask/utility/helper_functions.py
+++ b/wqflask/utility/helper_functions.py
@@ -10,7 +10,6 @@ import logging
logger = logging.getLogger(__name__ )
def get_species_dataset_trait(self, start_vars):
- #assert type(read_genotype) == type(bool()), "Expecting boolean value for read_genotype"
if "temp_trait" in list(start_vars.keys()):
if start_vars['temp_trait'] == "True":
self.dataset = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = start_vars['group'])
@@ -27,9 +26,6 @@ def get_species_dataset_trait(self, start_vars):
get_qtl_info=True)
logger.debug("After creating trait")
- #if read_genotype:
- #self.dataset.group.read_genotype_file()
- #self.genotype = self.dataset.group.genotype
def get_trait_db_obs(self, trait_db_list):
if isinstance(trait_db_list, str):
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 6892f02b..ed55d473 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -138,17 +138,12 @@ class ShowTrait(object):
self.ncbi_summary = get_ncbi_summary(self.this_trait)
- #Get nearest marker for composite mapping
+ # 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":
self.nearest_marker = get_nearest_marker(self.this_trait, self.dataset)
- #self.nearest_marker1 = get_nearest_marker(self.this_trait, self.dataset)[0]
- #self.nearest_marker2 = get_nearest_marker(self.this_trait, self.dataset)[1]
else:
self.nearest_marker = ""
- #self.nearest_marker1 = ""
- #self.nearest_marker2 = ""
-
self.make_sample_lists()
@@ -168,16 +163,19 @@ class ShowTrait(object):
categorical_var_list = []
if not self.temp_trait:
- categorical_var_list = get_categorical_variables(self.this_trait, self.sample_groups[0]) #ZS: Only using first samplelist, since I think mapping only uses those samples
+ # ZS: Only using first samplelist, since I think mapping only uses those samples
+ categorical_var_list = get_categorical_variables(self.this_trait, self.sample_groups[0])
- #ZS: Get list of chromosomes to select for mapping
+ # ZS: Get list of chromosomes to select for mapping
self.chr_list = [["All", -1]]
for i, this_chr in enumerate(self.dataset.species.chromosomes.chromosomes):
self.chr_list.append([self.dataset.species.chromosomes.chromosomes[this_chr].name, i])
self.genofiles = self.dataset.group.get_genofiles()
- if "QTLReaper" or "R/qtl" in dataset.group.mapping_names: #ZS: No need to grab scales from .geno file unless it's using a mapping method that reads .geno files
+ # ZS: No need to grab scales from .geno file unless it's using
+ # a mapping method that reads .geno files
+ if "QTLReaper" or "R/qtl" in dataset.group.mapping_names:
if self.genofiles:
self.scales_in_geno = get_genotype_scales(self.genofiles)
else:
@@ -187,10 +185,15 @@ class ShowTrait(object):
self.has_num_cases = has_num_cases(self.this_trait)
- #ZS: Needed to know whether to display bar chart + get max sample name length in order to set table column width
+ # ZS: Needed to know whether to display bar chart + get max
+ # sample name length in order to set table column width
self.num_values = 0
- self.binary = "true" #ZS: So it knows whether to display the Binary R/qtl mapping method, which doesn't work unless all values are 0 or 1
- self.negative_vals_exist = "false" #ZS: Since we don't want to show log2 transform option for situations where it doesn't make sense
+ # ZS: So it knows whether to display the Binary R/qtl mapping
+ # method, which doesn't work unless all values are 0 or 1
+ self.binary = "true"
+ # ZS: Since we don't want to show log2 transform option for
+ # situations where it doesn't make sense
+ self.negative_vals_exist = "false"
max_samplename_width = 1
for group in self.sample_groups:
for sample in group.sample_list:
@@ -203,7 +206,8 @@ class ShowTrait(object):
if sample.value < 0:
self.negative_vals_exist = "true"
- #ZS: Check whether any attributes have few enough distinct values to show the "Block samples by group" option
+ # ZS: Check whether any attributes have few enough distinct
+ # values to show the "Block samples by group" option
self.categorical_attr_exists = "false"
for attribute in self.sample_groups[0].attributes:
if len(self.sample_groups[0].attributes[attribute].distinct_values) <= 10:
@@ -258,7 +262,6 @@ class ShowTrait(object):
if not self.temp_trait:
if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish":
hddn['control_marker'] = self.nearest_marker
- #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2
hddn['do_control'] = False
hddn['maf'] = 0.05
hddn['mapping_scale'] = "physic"
@@ -268,7 +271,8 @@ class ShowTrait(object):
if len(self.scales_in_geno) < 2:
hddn['mapping_scale'] = self.scales_in_geno[list(self.scales_in_geno.keys())[0]][0][0]
- # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self
+ # We'll need access to this_trait and hddn in the Jinja2
+ # Template, so we put it inside self
self.hddn = hddn
js_data = dict(trait_id = self.trait_id,
@@ -294,7 +298,8 @@ class ShowTrait(object):
self.js_data = js_data
def get_external_links(self):
- #ZS: There's some weirdness here because some fields don't exist while others are empty strings
+ # ZS: There's some weirdness here because some fields don't
+ # exist while others are empty strings
self.pubmed_link = webqtlConfig.PUBMEDLINK_URL % self.this_trait.pubmed_id if check_if_attr_exists(self.this_trait, 'pubmed_id') else None
self.ncbi_gene_link = webqtlConfig.NCBI_LOCUSID % self.this_trait.geneid if check_if_attr_exists(self.this_trait, 'geneid') else None
self.omim_link = webqtlConfig.OMIM_ID % self.this_trait.omim if check_if_attr_exists(self.this_trait, 'omim') else None
@@ -320,7 +325,6 @@ class ShowTrait(object):
self.panther_link = webqtlConfig.PANTHER_URL % self.this_trait.symbol
self.ebi_gwas_link = webqtlConfig.EBIGWAS_URL % self.this_trait.symbol
self.protein_atlas_link = webqtlConfig.PROTEIN_ATLAS_URL % self.this_trait.symbol
- #self.open_targets_link = webqtlConfig.OPEN_TARGETS_URL % self.this_trait.symbol
if self.dataset.group.species == "mouse" or self.dataset.group.species == "human":
self.rgd_link = webqtlConfig.RGD_URL % (self.this_trait.symbol, self.dataset.group.species.capitalize())
@@ -429,7 +433,9 @@ class ShowTrait(object):
all_samples_ordered.append(sample)
other_sample_names.append(sample)
- #ZS: CFW is here because the .geno file doesn't properly contain its full list of samples. This should probably be fixed.
+ # ZS: CFW is here because the .geno file doesn't properly
+ # contain its full list of samples. This should probably
+ # be fixed.
if self.dataset.group.species == "human" or (set(primary_sample_names) == set(parent_f1_samples)) or self.dataset.group.name == "CFW":
primary_sample_names += other_sample_names
other_sample_names = []
@@ -445,7 +451,8 @@ class ShowTrait(object):
sample_group_type='primary',
header=primary_header)
- #if other_sample_names and self.dataset.group.species != "human" and self.dataset.group.name != "CFW":
+ # if other_sample_names and self.dataset.group.species !=
+ # "human" and self.dataset.group.name != "CFW":
if len(other_sample_names) > 0:
other_sample_names.sort() #Sort other samples
if parent_f1_samples:
@@ -539,7 +546,8 @@ def get_z_scores(sample_groups):
def get_nearest_marker(this_trait, this_db):
this_chr = this_trait.locus_chr
this_mb = this_trait.locus_mb
- #One option is to take flanking markers, another is to take the two (or one) closest
+ # One option is to take flanking markers, another is to take the
+ # two (or one) closest
query = """SELECT Geno.Name
FROM Geno, GenoXRef, GenoFreeze
WHERE Geno.Chr = '{}' AND
@@ -552,7 +560,6 @@ def get_nearest_marker(this_trait, this_db):
if result == []:
return ""
- #return "", ""
else:
return result[0][0]
@@ -617,7 +624,8 @@ def check_if_attr_exists(the_trait, id_type):
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
+ # 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)
summary = json.loads(response.content)['result'][this_trait.geneid]['summary']
@@ -661,8 +669,8 @@ def get_genotype_scales(genofiles):
def get_scales_from_genofile(file_location):
geno_path = locate_ignore_error(file_location, 'genotype')
-
- if not geno_path: #ZS: This is just to allow the code to run when
+ # ZS: This is just to allow the code to run when
+ if not geno_path:
return [["physic", "Mb"]]
cm_and_mb_cols_exist = True
cm_column = None
@@ -670,7 +678,9 @@ def get_scales_from_genofile(file_location):
with open(geno_path, "r") as geno_fh:
for i, line in enumerate(geno_fh):
if line[0] == "#" or line[0] == "@":
- if "@scale" in line: #ZS: If the scale is made explicit in the metadata, use that
+ # ZS: If the scale is made explicit in the metadata,
+ # use that
+ if "@scale" in line:
scale = line.split(":")[1].strip()
if scale == "morgan":
return [["morgan", "cM"]]
@@ -690,12 +700,16 @@ def get_scales_from_genofile(file_location):
mb_column = 3
break
- #ZS: This attempts to check whether the cM and Mb columns are 'real', since some .geno files have one column be a copy of the other column, or have one column that is all 0s
+ # ZS: This attempts to check whether the cM and Mb columns are
+ # 'real', since some .geno files have one column be a copy of
+ # the other column, or have one column that is all 0s
cm_all_zero = True
mb_all_zero = True
cm_mb_all_equal = True
for i, line in enumerate(geno_fh):
- if first_marker_line <= i < first_marker_line + 10: #ZS: I'm assuming there won't be more than 10 markers where the position is listed as 0
+ # ZS: I'm assuming there won't be more than 10 markers
+ # where the position is listed as 0
+ if first_marker_line <= i < first_marker_line + 10:
if cm_column:
cm_val = line.split("\t")[cm_column].strip()
if cm_val != "0":
@@ -711,8 +725,8 @@ def get_scales_from_genofile(file_location):
if i > first_marker_line + 10:
break
-
- #ZS: This assumes that both won't be all zero, since if that's the case mapping shouldn't be an option to begin with
+ # ZS: This assumes that both won't be all zero, since if that's
+ # the case mapping shouldn't be an option to begin with
if mb_all_zero:
return [["morgan", "cM"]]
elif cm_mb_all_equal:
diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html
index 7f82b35c..87cf1b45 100755
--- a/wqflask/wqflask/templates/index_page_orig.html
+++ b/wqflask/wqflask/templates/index_page_orig.html
@@ -7,16 +7,6 @@
{% endblock %}
{% block content %}
-
-
-
Paste or Type Multiple Values: You can enter data by pasting a series of numbers representing trait values into this area.
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 2c0ba586..c4b510d4 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -156,12 +156,6 @@ def index_page():
import_collections = params['import_collections']
if import_collections == "true":
g.user_session.import_traits_to_user(params['anon_id'])
- #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)
@@ -343,14 +337,10 @@ def intro():
@app.route("/tutorials")
def tutorials():
- #doc = Docs("links", request.args)
- #return render_template("docs.html", **doc.__dict__)
return render_template("tutorials.html")
@app.route("/credits")
def credits():
- #doc = Docs("links", request.args)
- #return render_template("docs.html", **doc.__dict__)
return render_template("credits.html")
@app.route("/update_text", methods=('POST',))
@@ -368,12 +358,9 @@ def submit_trait_form():
@app.route("/create_temp_trait", methods=('POST',))
def create_temp_trait():
logger.info(request.url)
-
- #template_vars = submit_trait.SubmitTrait(request.form)
-
doc = Docs("links")
return render_template("links.html", **doc.__dict__)
- #return render_template("show_trait.html", **template_vars.__dict__)
+
@app.route('/export_trait_excel', methods=('POST',))
def export_trait_excel():
@@ -487,21 +474,17 @@ def export_perm_data():
mimetype='text/csv',
headers={"Content-Disposition":"attachment;filename=" + file_name + ".csv"})
+
@app.route("/show_temp_trait", methods=('POST',))
def show_temp_trait_page():
logger.info(request.url)
template_vars = show_trait.ShowTrait(request.form)
- #logger.info("js_data before dump:", template_vars.js_data)
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
indent=" ")
- # Sorting the keys messes up the ordered dictionary, so don't do that
- #sort_keys=True)
-
- #logger.info("js_data after dump:", template_vars.js_data)
- #logger.info("show_trait template_vars:", pf(template_vars.__dict__))
return render_template("show_trait.html", **template_vars.__dict__)
+
@app.route("/show_trait")
def show_trait_page():
logger.info(request.url)
--
cgit v1.2.3
From 4534daa6fb07c23b90e024560ca64091fc330eed Mon Sep 17 00:00:00 2001
From: BonfaceKilz
Date: Mon, 19 Apr 2021 17:46:38 +0300
Subject: Move looped sql query into one statement in "get_species_groups"
It's in-efficient to have a sql query executed in a loop. As data
grows, the query becomes slower. It's better to let sql handle such
queries.
---
wqflask/utility/helper_functions.py | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py
index 15d5b3ab..4ba92ed5 100644
--- a/wqflask/utility/helper_functions.py
+++ b/wqflask/utility/helper_functions.py
@@ -47,19 +47,18 @@ def get_trait_db_obs(self, trait_db_list):
if trait_ob:
self.trait_list.append((trait_ob, dataset_ob))
-def get_species_groups():
-
- species_query = "SELECT SpeciesId, MenuName FROM Species"
- species_ids_and_names = g.db.execute(species_query).fetchall()
-
- species_and_groups = []
- for species_id, species_name in species_ids_and_names:
- this_species_groups = {}
- this_species_groups['species'] = species_name
- groups_query = "SELECT InbredSetName FROM InbredSet WHERE SpeciesId = %s" % (species_id)
- groups = [group[0] for group in g.db.execute(groups_query).fetchall()]
- this_species_groups['groups'] = groups
- species_and_groups.append(this_species_groups)
-
- return species_and_groups
+def get_species_groups():
+ """Group each species into a group"""
+ _menu = {}
+ for species, group_name in g.db.execute(
+ "SELECT s.MenuName, i.InbredSetName FROM InbredSet i "
+ "INNER JOIN Species s ON s.SpeciesId = i.SpeciesId "
+ "ORDER BY i.SpeciesId ASC, i.Name ASC").fetchall():
+ if _menu.get(species):
+ _menu = _menu[species].append(group_name)
+ else:
+ _menu[species] = [group_name]
+ return [{"species": key,
+ "groups": value} for key, value in
+ list(_menu.items())]
--
cgit v1.2.3
From d2e2046a3ce1af0ca97ea1b6d9ccb3a4c9aecf7c Mon Sep 17 00:00:00 2001
From: BonfaceKilz
Date: Fri, 23 Apr 2021 17:21:12 +0300
Subject: Add full link to genetic data collected as part of WebQTL project
---
wqflask/wqflask/templates/submit_trait.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/submit_trait.html b/wqflask/wqflask/templates/submit_trait.html
index 334a608d..2cc18240 100644
--- a/wqflask/wqflask/templates/submit_trait.html
+++ b/wqflask/wqflask/templates/submit_trait.html
@@ -14,7 +14,7 @@
Introduction
The trait values that you enter are statistically compared with verified genotypes collected at a set of microsatellite markers in each RI set. The markers are drawn from a set of over 750, but for each set redundant markers have been removed, preferentially retaining those that are most informative.
-
These error-checked RI mapping data match theoretical expectations for RI strain sets. The cumulative adjusted length of the RI maps are approximately 1400 cM, a value that matches those of both MIT maps and Chromosome Committee Report maps. See our full description of the genetic data collected as part of the WebQTL project.
+
These error-checked RI mapping data match theoretical expectations for RI strain sets. The cumulative adjusted length of the RI maps are approximately 1400 cM, a value that matches those of both MIT maps and Chromosome Committee Report maps. See our full description of the genetic data collected as part of the WebQTL project.