diff options
-rwxr-xr-x | wqflask/base/data_set.py | 8 | ||||
-rwxr-xr-x | wqflask/base/mrna_assay_tissue_data.py | 6 | ||||
-rwxr-xr-x | wqflask/base/trait.py | 2 | ||||
-rwxr-xr-x | wqflask/wqflask/do_search.py | 100 | ||||
-rwxr-xr-x | wqflask/wqflask/search_results.py | 1 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/correlation_page.html | 10 | ||||
-rwxr-xr-x | wqflask/wqflask/templates/search_result_page.html | 6 |
7 files changed, 57 insertions, 76 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 706b193d..acfee3d4 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -789,7 +789,7 @@ class PhenotypeDataSet(DataSet): this_trait.LRS_score_repr = LRS_score_repr = '%3.1f' % this_trait.lrs this_trait.LRS_score_value = LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.4f Mb' % (LRS_Chr, float(LRS_Mb)) + this_trait.LRS_location_repr = LRS_location_repr = 'Chr %s: %.6f Mb' % (LRS_Chr, float(LRS_Mb)) def retrieve_sample_data(self, trait): query = """ @@ -880,7 +880,7 @@ class GenotypeDataSet(DataSet): else: trait_location_value = ord(str(this_trait.chr).upper()[0])*1000 + this_trait.mb - this_trait.location_repr = 'Chr%s: %.4f' % (this_trait.chr, float(this_trait.mb) ) + this_trait.location_repr = 'Chr%s: %.6f' % (this_trait.chr, float(this_trait.mb) ) this_trait.location_value = trait_location_value def retrieve_sample_data(self, trait): @@ -1107,7 +1107,7 @@ class MrnaAssayDataSet(DataSet): # this_trait.mb) #ZS: Put this in function currently called "convert_location_to_value" - this_trait.location_repr = 'Chr %s: %.4f Mb' % (this_trait.chr, + this_trait.location_repr = 'Chr %s: %.6f Mb' % (this_trait.chr, float(this_trait.mb)) this_trait.location_value = trait_location_value @@ -1163,7 +1163,7 @@ class MrnaAssayDataSet(DataSet): this_trait.LRS_score_repr = '%3.1f' % this_trait.lrs this_trait.LRS_score_value = this_trait.lrs - this_trait.LRS_location_repr = 'Chr %s: %.4f Mb' % (lrs_chr, float(lrs_mb)) + this_trait.LRS_location_repr = 'Chr %s: %.6f' % (lrs_chr, float(lrs_mb)) def convert_location_to_value(self, chromosome, mb): diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py index 1a05fce7..b2c0448a 100755 --- a/wqflask/base/mrna_assay_tissue_data.py +++ b/wqflask/base/mrna_assay_tissue_data.py @@ -51,15 +51,15 @@ class MrnaAssayTissueData(object): query += ''' Symbol in {} group by Symbol) as x inner join TissueProbeSetXRef as t on t.Symbol = x.Symbol - and t.Mean = x.maxmean; + and t.Mean = x.maxmean;http://docs.python.org/2/library/string.html?highlight=lower#string.lower '''.format(in_clause) results = g.db.execute(query).fetchall() for result in results: symbol = result[0] - if symbol in gene_symbols: - #gene_symbols.append(symbol) + if symbol.lower() in [gene_symbol.lower() for gene_symbol in gene_symbols]: + #gene_symbols.append(symbol) symbol = symbol.lower() self.data[symbol].gene_id = result.GeneId diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 8930c917..7f1170a9 100755 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -423,6 +423,8 @@ class GeneralTrait(object): if result: self.locus_chr = result[0] self.locus_mb = result[1] + else: + self.locus = self.locus_chr = self.locus_mb = "" else: self.locus = self.locus_chr = self.locus_mb = "" else: diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index a3260f34..f966b564 100755 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -442,13 +442,6 @@ class WikiSearch(MrnaAssaySearch): return where_clause def run(self): - #where_clause = """%s.symbol = GeneRIF.symbol - # and GeneRIF.versionId=0 and GeneRIF.display>0 - # and (GeneRIF.comment REGEXP '%s' or GeneRIF.initial = '%s') - # """ % (self.dataset.type, - # "[[:<:]]"+str(self.search_term[0])+"[[:>:]]", - # str(self.search_term[0])) - where_clause = self.get_where_clause() from_clause = ", GeneRIF " @@ -481,7 +474,7 @@ class GoSearch(MrnaAssaySearch): return self.execute(query) #ZS: Not sure what the best way to deal with LRS searches is -class LrsSearch(MrnaAssaySearch): +class LrsSearch(DoSearch): """Searches for genes with a QTL within the given LRS values LRS searches can take 3 different forms: @@ -497,9 +490,11 @@ class LrsSearch(MrnaAssaySearch): def get_from_clause(self): if self.search_operator == "=": - return ", Geno" + from_clause = ", Geno" else: - return "" + from_clause = "" + + return from_clause def get_where_clause(self): self.search_term = [float(value) for value in self.search_term] @@ -537,26 +532,42 @@ class LrsSearch(MrnaAssaySearch): self.search_operator, self.search_term[0]) where_clause = self.sub_clause - - + return where_clause - def get_final_query(self): + + def run(self): + self.from_clause = self.get_from_clause() self.where_clause = self.get_where_clause() + self.query = self.compile_final_query(self.from_clause, self.where_clause) - return self.query + return self.execute(self.query) + +class MrnaLrsSearch(LrsSearch, MrnaAssaySearch): + + DoSearch.search_types['ProbeSet_LRS'] = 'MrnaLrsSearch' def run(self): self.from_clause = self.get_from_clause() self.where_clause = self.get_where_clause() - - self.query = self.compile_final_query(self.from_clause, self.where_clause) + self.query = self.compile_final_query(from_clause = self.from_clause, where_clause = self.where_clause) return self.execute(self.query) +class PhenotypeLrsSearch(LrsSearch, PhenotypeSearch): + + DoSearch.search_types['Publish_LRS'] = 'PhenotypeLrsSearch' + + def run(self): + + self.from_clause = self.get_from_clause() + self.where_clause = self.get_where_clause() + self.query = self.compile_final_query(from_clause = self.from_clause, where_clause = self.where_clause) + + return self.execute(self.query) class CisTransLrsSearch(LrsSearch): @@ -693,24 +704,6 @@ class MeanSearch(MrnaAssaySearch): return self.query def run(self): - - #self.search_term = [float(value) for value in self.search_term] - # - #if self.search_operator == "=": - # assert isinstance(self.search_term, (list, tuple)) - # self.mean_min, self.mean_max = self.search_term[:2] - # - # self.where_clause = """ %sXRef.mean > %s and - # %sXRef.mean < %s """ % self.mescape(self.dataset.type, - # min(self.mean_min, self.mean_max), - # self.dataset.type, - # max(self.mean_min, self.mean_max)) - #else: - # # Deal with >, <, >=, and <= - # self.where_clause = """ %sXRef.mean %s %s """ % self.mescape(self.dataset.type, - # self.search_operator, - # self.search_term[0]) - self.where_clause = self.get_where_clause() print("where_clause is:", pf(self.where_clause)) @@ -747,27 +740,6 @@ class RangeSearch(MrnaAssaySearch): return where_clause def run(self): - - #self.search_term = [float(value) for value in self.search_term] - # - #if self.search_operator == "=": - # assert isinstance(self.search_term, (list, tuple)) - # self.range_min, self.range_max = self.search_term[:2] - # self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) - # FROM ProbeSetData - # WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s AND - # (SELECT Pow(2, max(value) -min(value)) - # FROM ProbeSetData - # WHERE ProbeSetData.Id = ProbeSetXRef.dataId) < %s - # """ % self.mescape(min(self.range_min, self.range_max), - # max(self.range_min, self.range_max)) - #else: - # # Deal with >, <, >=, and <= - # self.where_clause = """ (SELECT Pow(2, max(value) -min(value)) - # FROM ProbeSetData - # WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s - # """ % (escape(self.search_term[0])) - self.where_clause = self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) @@ -781,6 +753,10 @@ class PositionSearch(DoSearch): DoSearch.search_types[search_key] = "PositionSearch" def get_where_clause(self): + self.search_term = [float(value) if is_number(value) else value for value in self.search_term] + self.chr, self.mb_min, self.mb_max = self.search_term[:3] + self.get_chr() + where_clause = """ %s.Chr = %s and %s.Mb > %s and %s.Mb < %s """ % self.mescape(self.dataset.type, @@ -793,12 +769,6 @@ class PositionSearch(DoSearch): return where_clause - def setup(self): - self.search_term = [float(value) if is_number(value) else value for value in self.search_term] - self.chr, self.mb_min, self.mb_max = self.search_term[:3] - self.get_chr() - self.where_clause = self.get_where_clause() - def get_chr(self): try: self.chr = int(self.chr) @@ -807,7 +777,7 @@ class PositionSearch(DoSearch): def run(self): - self.setup() + self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) @@ -820,7 +790,7 @@ class MrnaPositionSearch(PositionSearch, MrnaAssaySearch): def run(self): - self.setup() + self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) @@ -833,7 +803,7 @@ class GenotypePositionSearch(PositionSearch, GenotypeSearch): def run(self): - self.setup() + self.get_where_clause() self.query = self.compile_final_query(where_clause = self.where_clause) return self.execute(self.query) @@ -841,6 +811,8 @@ class GenotypePositionSearch(PositionSearch, GenotypeSearch): class PvalueSearch(MrnaAssaySearch): """Searches for traits with a permutationed p-value between low and high""" + DoSearch.search_types['ProbeSet_PVALUE'] = "PvalueSearch" + def run(self): self.search_term = [float(value) for value in self.search_term] diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 2a1e8bb3..6614520e 100755 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -239,7 +239,6 @@ class SearchResultPage(object): for a_search in self.search_terms: the_search = self.get_search_ob(a_search) self.results.extend(the_search.run()) - #print("in the search results are:", self.results) self.header_fields = the_search.header_fields diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 169371be..74919c88 100755 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -85,8 +85,16 @@ <td>{{ trait.description }} <br><br> <b>Aliases</b>: {{ trait.alias }}</td> <td>Chr{{ trait.chr }}: {{'%0.6f'|format(trait.mb) if trait.mb != None }}</td> <td>{{'%0.3f'|format(trait.mean)}}</td> + {% if trait.lrs == "" or trait.lrs == 0.000 %} + <td>--</td> + {% else %} <td>{{'%0.3f'|format(trait.lrs)}}</td> - <td>Chr{{ trait.locus_chr }}: {{'%0.3f'|format(trait.locus_mb) }}</td> + {% endif %} + {% if trait.locus_mb == "" %} + <td>--</td> + {% else %} + <td>Chr{{ trait.locus_chr if trait.locus_chr != None }}: {{'%0.3f'|format(trait.locus_mb)}}</td> + {% endif %} <td><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{'%0.3f'|format(trait.sample_r)}}</a></td> <td>{{ trait.num_overlap }}</td> <td>{{'%0.3e'|format(trait.sample_p)}}</td> diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index ebae41af..227dec0b 100755 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -82,7 +82,7 @@ <TD>{{ this_trait.mean }}</TD> <TD align="right">{{ this_trait.LRS_score_repr }}</TD> <TD>{{ this_trait.LRS_location_repr }}</TD> - <TD>{{ this_trait.additive }}</TD> + <TD>{{ '%0.3f' % this_trait.additive|float }}</TD> {% elif dataset.type == 'Publish' %} <TD>{{ this_trait.description_display }}</TD> <TD>{{ this_trait.authors }}</TD> @@ -93,7 +93,7 @@ </TD> <TD>{{ this_trait.LRS_score_repr }}</TD> <TD>{{ this_trait.LRS_location_repr }}</TD> - <TD>{{ this_trait.additive }}</TD> + <TD>{{ '%0.3f' % this_trait.additive|float }}</TD> {% elif dataset.type == 'Geno' %} <TD>{{ this_trait.location_repr }}</TD> {% endif %} @@ -183,7 +183,7 @@ { "sType": "natural", "sWidth": "12%" }, { "sType": "natural", - "sWidth": "15%" }, + "sWidth": "20%" }, { "sType": "natural" } ], "sDom": "tir", |