aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Sloan2012-12-07 15:04:44 -0600
committerZachary Sloan2012-12-07 15:04:44 -0600
commitef26532ba2792afdcca65d5f5f3c03f93a33f1ae (patch)
tree6415b02060d25e9d2641f0fd8939b2c41a5d0d2b
parent8aa6cc5c1cf85ae9f3ac6c87ff0c354af5c947c7 (diff)
downloadgenenetwork2-ef26532ba2792afdcca65d5f5f3c03f93a33f1ae.tar.gz
Got basic statistics in show_trait to display the correct number
of samples for each group Got show_trait page to display for genotype traits
-rwxr-xr-xwqflask/base/trait.py102
-rw-r--r--wqflask/wqflask/do_search.py18
-rw-r--r--wqflask/wqflask/parser.py17
-rw-r--r--wqflask/wqflask/search_results.py23
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py50
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.coffee22
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js12
7 files changed, 72 insertions, 172 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index d0158ebd..8c9e3b10 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -258,113 +258,15 @@ class GeneralTrait:
#else:
results = self.dataset.retrieve_sample_data(self)
- #if self.dataset.type == 'Temp':
- # query = '''
- # SELECT
- # Strain.Name, TempData.value, TempData.SE, TempData.NStrain, TempData.Id
- # FROM
- # TempData, Temp, Strain
- # WHERE
- # TempData.StrainId = Strain.Id AND
- # TempData.Id = Temp.DataId AND
- # Temp.name = '%s'
- # Order BY
- # Strain.Name
- # ''' % self.name
- ##XZ, 03/02/2009: Xiaodong changed Data to PublishData, SE to PublishSE
- #elif self.dataset.type == 'Publish':
- # query = '''
- # SELECT
- # Strain.Name, PublishData.value, PublishSE.error, NStrain.count, PublishData.Id
- # FROM
- # (PublishData, Strain, PublishXRef, PublishFreeze)
- # left join PublishSE on
- # (PublishSE.DataId = PublishData.Id AND PublishSE.StrainId = PublishData.StrainId)
- # left join NStrain on
- # (NStrain.DataId = PublishData.Id AND
- # NStrain.StrainId = PublishData.StrainId)
- # WHERE
- # PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND
- # PublishData.Id = PublishXRef.DataId AND PublishXRef.Id = %s AND
- # PublishFreeze.Id = %d AND PublishData.StrainId = Strain.Id
- # Order BY
- # Strain.Name
- # ''' % (self.name, self.dataset.id)
-
- #XZ, 03/02/2009: Xiaodong changed Data to ProbeData, SE to ProbeSE
- #elif self.cellid:
-
- #XZ, 03/02/2009: Xiaodong added this block for ProbeSetData and ProbeSetSE
- #elif self.dataset.type == 'ProbeSet':
- # #ProbeSet Data
- # query = '''
- # SELECT
- # Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id
- # FROM
- # (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef)
- # left join ProbeSetSE on
- # (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId)
- # WHERE
- # ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND
- # ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND
- # ProbeSetFreeze.Name = '%s' AND
- # ProbeSetXRef.DataId = ProbeSetData.Id AND
- # ProbeSetData.StrainId = Strain.Id
- # Order BY
- # Strain.Name
- # ''' % (self.name, self.dataset.name)
- ##XZ, 03/02/2009: Xiaodong changeded Data to GenoData, SE to GenoSE
- #else:
- # #Geno Data
- # #XZ: The SpeciesId is not necessary, but it's nice to keep it to speed up database search.
- # query = '''
- # SELECT
- # Strain.Name, GenoData.value, GenoSE.error, GenoData.Id
- # FROM
- # (GenoData, GenoFreeze, Strain, Geno, GenoXRef)
- # left join GenoSE on
- # (GenoSE.DataId = GenoData.Id AND GenoSE.StrainId = GenoData.StrainId)
- # WHERE
- # Geno.SpeciesId = %s AND Geno.Name = '%s' AND GenoXRef.GenoId = Geno.Id AND
- # GenoXRef.GenoFreezeId = GenoFreeze.Id AND
- # GenoFreeze.Name = '%s' AND
- # GenoXRef.DataId = GenoData.Id AND
- # GenoData.StrainId = Strain.Id
- # Order BY
- # Strain.Name
- # ''' % (webqtlDatabaseFunction.retrieveSpeciesId(self.cursor, self.dataset.group), self.name, self.dataset.name)
-
-
- #self.cursor.execute(query)
- #results = self.cursor.fetchall()
-
# Todo: is this necessary? If not remove
self.data.clear()
if results:
- #self.mysqlid = results[0][-1]
- #if samplelist:
for item in results:
#name, value, variance, num_cases = item
if not samplelist or (samplelist and name in samplelist):
- #if value != None:
- # num_cases = None
- # if self.dataset.type in ('Publish', 'Temp'):
- # ndata = item[3]
name = item[0]
self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases)
- #end for
- # else:
- # for item in results:
- # val = item[1]
- # if val != None:
- # var = item[2]
- # ndata = None
- # if self.dataset.type in ('Publish', 'Temp'):
- # ndata = item[3]
- # self.data[item[0]] = webqtlCaseData(val, var, ndata)
- # #end for
- # #end if
#def keys(self):
# return self.__dict__.keys()
@@ -429,7 +331,9 @@ class GeneralTrait:
GenoXRef.GenoId = Geno.Id AND
GenoFreeze.Name = '%s' AND
Geno.Name = '%s'
- """ % (escape(display_fields_string), escape(self.dataset.name), escape(self.name))
+ """ % (escape(display_fields_string),
+ escape(self.dataset.name),
+ escape(self.name))
traitInfo = g.db.execute(query).fetchone()
print("traitInfo is: ", pf(traitInfo))
else: #Temp type
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index 3ce613e9..fc45395c 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -60,7 +60,7 @@ class DoSearch(object):
return cls.search_types[search_type]
-class ProbeSetSearch(DoSearch):
+class MrnaAssaySearch(DoSearch):
"""A search within an mRNA expression dataset"""
DoSearch.search_types['ProbeSet'] = "ProbeSetSearch"
@@ -265,7 +265,7 @@ class GenotypeSearch(DoSearch):
return self.execute(self.query)
-class RifSearch(ProbeSetSearch):
+class RifSearch(MrnaAssaySearch):
"""Searches for traits with a Gene RIF entry including the search term."""
DoSearch.search_types['RIF'] = "RifSearch"
@@ -280,7 +280,7 @@ class RifSearch(ProbeSetSearch):
return self.execute(query)
-class WikiSearch(ProbeSetSearch):
+class WikiSearch(MrnaAssaySearch):
"""Searches GeneWiki for traits other people have annotated"""
DoSearch.search_types['WIKI'] = "WikiSearch"
@@ -298,7 +298,7 @@ class WikiSearch(ProbeSetSearch):
return self.execute(query)
-class GoSearch(ProbeSetSearch):
+class GoSearch(MrnaAssaySearch):
"""Searches for synapse-associated genes listed in the Gene Ontology."""
DoSearch.search_types['GO'] = "GoSearch"
@@ -323,7 +323,7 @@ class GoSearch(ProbeSetSearch):
return self.execute(query)
#ZS: Not sure what the best way to deal with LRS searches is
-class LrsSearch(ProbeSetSearch):
+class LrsSearch(MrnaAssaySearch):
"""Searches for genes with a QTL within the given LRS values
LRS searches can take 3 different forms:
@@ -484,7 +484,7 @@ class TransLrsSearch(CisTransLrsSearch):
return self.real_run(">")
-class MeanSearch(ProbeSetSearch):
+class MeanSearch(MrnaAssaySearch):
"""Searches for genes expressed within an interval (log2 units) determined by the user"""
DoSearch.search_types['MEAN'] = "MeanSearch"
@@ -514,7 +514,7 @@ class MeanSearch(ProbeSetSearch):
return self.execute(self.query)
-class RangeSearch(ProbeSetSearch):
+class RangeSearch(MrnaAssaySearch):
"""Searches for genes with a range of expression varying between two values"""
DoSearch.search_types['RANGE'] = "RangeSearch"
@@ -571,7 +571,7 @@ class PositionSearch(DoSearch):
return self.execute(self.query)
-class MrnaPositionSearch(ProbeSetSearch, PositionSearch):
+class MrnaPositionSearch(MrnaAssaySearch, PositionSearch):
"""Searches for genes located within a specified range on a specified chromosome"""
def run(self):
@@ -591,7 +591,7 @@ class GenotypePositionSearch(GenotypeSearch, PositionSearch):
return self.execute(self.query)
-class PvalueSearch(ProbeSetSearch):
+class PvalueSearch(MrnaAssaySearch):
"""Searches for traits with a permutationed p-value between low and high"""
def run(self):
diff --git a/wqflask/wqflask/parser.py b/wqflask/wqflask/parser.py
index f991d8c7..be92014d 100644
--- a/wqflask/wqflask/parser.py
+++ b/wqflask/wqflask/parser.py
@@ -73,6 +73,23 @@ def parse(pstring):
print("* items are:", pf(items) + "\n")
return(items)
+ #def encregexp(self,str):
+ # if not str:
+ # return []
+ # else:
+ # wildcardkeyword = str.strip()
+ # wildcardkeyword = string.replace(wildcardkeyword,',',' ')
+ # wildcardkeyword = string.replace(wildcardkeyword,';',' ')
+ # wildcardkeyword = wildcardkeyword.split()
+ # NNN = len(wildcardkeyword)
+ # for i in range(NNN):
+ # keyword = wildcardkeyword[i]
+ # keyword = string.replace(keyword,"*",".*")
+ # keyword = string.replace(keyword,"?",".")
+ # wildcardkeyword[i] = keyword#'[[:<:]]'+ keyword+'[[:>:]]'
+ # return wildcardkeyword
+
+
if __name__ == '__main__':
parse("foo=[3 2 1]")
parse("WIKI=ho*")
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 5cb8e314..d986a2e0 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -54,11 +54,6 @@ class SearchResultPage(templatePage):
# change back to self.dataset
#if not self.dataset or self.dataset == 'spacer':
# #Error, No dataset selected
- # heading = "Search Result"
- # detail = ['''No dataset was selected for this search, please
- # go back and SELECT at least one dataset.''']
- # self.error(heading=heading,detail=detail,error="No dataset Selected")
- # return
###########################################
# Names and IDs of group / F2 set
@@ -144,21 +139,3 @@ class SearchResultPage(templatePage):
print("in the search results are:", self.results)
self.header_fields = the_search.header_fields
-
-
- #ZS: This should be handled in the parser
- def encregexp(self,str):
- if not str:
- return []
- else:
- wildcardkeyword = str.strip()
- wildcardkeyword = string.replace(wildcardkeyword,',',' ')
- wildcardkeyword = string.replace(wildcardkeyword,';',' ')
- wildcardkeyword = wildcardkeyword.split()
- NNN = len(wildcardkeyword)
- for i in range(NNN):
- keyword = wildcardkeyword[i]
- keyword = string.replace(keyword,"*",".*")
- keyword = string.replace(keyword,"?",".")
- wildcardkeyword[i] = keyword#'[[:<:]]'+ keyword+'[[:>:]]'
- return wildcardkeyword
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 0f593216..836d37ea 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -828,35 +828,34 @@ class ShowTrait(object):
elif this_trait and this_trait.dataset and this_trait.dataset.type == 'Geno': #Check if trait is genotype
- GenoInfo = HT.Paragraph()
if this_trait.chr and this_trait.mb:
location = ' Chr %s @ %s Mb' % (this_trait.chr,this_trait.mb)
else:
location = "not available"
- if this_trait.sequence and len(this_trait.sequence) > 100:
- if _Species == "rat":
- UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', this_trait.sequence)
- UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('rat', 'rn3', this_trait.sequence)
- elif _Species == "mouse":
- UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', this_trait.sequence)
- UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', this_trait.sequence)
- elif _Species == "human":
- UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence)
- UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('human', 'hg19', this_trait.sequence)
- else:
- UCSC_BLAT_URL = ""
- UTHSC_BLAT_URL = ""
- if UCSC_BLAT_URL:
- #verifyButton = HT.Href(url="#", onClick="openNewWin('%s')" % UCSC_BLAT_URL)
- verifyButton = HT.Href(url="#")
- verifyButtonImg = HT.Image("/images/verify_icon.jpg", name="verify", alt=" Check probe locations at UCSC ", title=" Check probe locations at UCSC ", style="border:none;")
- verifyButton.append(verifyButtonImg)
- verifyText = "Verify"
- rnaseqButton = HT.Href(url="#", onClick="openNewWin('%s')" % UTHSC_BLAT_URL)
- rnaseqButtonImg = HT.Image("/images/rnaseq_icon.jpg", name="rnaseq", alt=" View probes, SNPs, and RNA-seq at UTHSC ", title=" View probes, SNPs, and RNA-seq at UTHSC ", style="border:none;")
- rnaseqButton.append(rnaseqButtonImg)
- rnaseqText = "RNA-seq"
+ #if this_trait.sequence and len(this_trait.sequence) > 100:
+ # if _Species == "rat":
+ # UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn3', this_trait.sequence)
+ # UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('rat', 'rn3', this_trait.sequence)
+ # elif _Species == "mouse":
+ # UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm9', this_trait.sequence)
+ # UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm9', this_trait.sequence)
+ # elif _Species == "human":
+ # UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg19', blatsequence)
+ # UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('human', 'hg19', this_trait.sequence)
+ # else:
+ # UCSC_BLAT_URL = ""
+ # UTHSC_BLAT_URL = ""
+ # if UCSC_BLAT_URL:
+ # #verifyButton = HT.Href(url="#", onClick="openNewWin('%s')" % UCSC_BLAT_URL)
+ # verifyButton = HT.Href(url="#")
+ # verifyButtonImg = HT.Image("/images/verify_icon.jpg", name="verify", alt=" Check probe locations at UCSC ", title=" Check probe locations at UCSC ", style="border:none;")
+ # verifyButton.append(verifyButtonImg)
+ # verifyText = "Verify"
+ # rnaseqButton = HT.Href(url="#", onClick="openNewWin('%s')" % UTHSC_BLAT_URL)
+ # rnaseqButtonImg = HT.Image("/images/rnaseq_icon.jpg", name="rnaseq", alt=" View probes, SNPs, and RNA-seq at UTHSC ", title=" View probes, SNPs, and RNA-seq at UTHSC ", style="border:none;")
+ # rnaseqButton.append(rnaseqButtonImg)
+ # rnaseqText = "RNA-seq"
#tbl.append(HT.TR(
# HT.TD('Location: ', Class="fs13 fwb",
@@ -872,7 +871,7 @@ class ShowTrait(object):
# valign="top", width=740)
# ))
- menuTable = HT.TableLite(cellpadding=2, Class="collap", width="275", id="target1")
+ #menuTable = HT.TableLite(cellpadding=2, Class="collap", width="275", id="target1")
#menuTable.append(HT.TR(HT.TD(addSelectionButton, align="center"),HT.TD(verifyButton, align="center"),HT.TD(rnaseqButton, align="center"), HT.TD(updateButton, align="center"), colspan=3, height=50, style="vertical-align:bottom;"))
#menuTable.append(HT.TR(HT.TD(addSelectionText, align="center"),HT.TD(verifyText, align="center"),HT.TD(rnaseqText, align="center"), HT.TD(updateText, align="center"), colspan=3, height=50, style="vertical-align:bottom;"))
@@ -1629,7 +1628,6 @@ class ShowTrait(object):
header="%s Only" % (self.dataset.group.name))
print("primary_samples is: ", pf(primary_samples))
-
other_sample_names = []
for sample in this_trait.data.keys():
if sample not in all_samples_ordered:
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee
index 278a134b..04d55be7 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee
@@ -110,6 +110,7 @@ $ ->
change_stats_value(sample_sets, category, row.vn, row.digits)
edit_data_change = ->
+ already_seen = {}
sample_sets =
samples_primary: new Stats([])
samples_other: new Stats([])
@@ -117,21 +118,14 @@ $ ->
console.log("at beginning:", sample_sets)
- # ##########
- # Bug here #value_table doesn't exist and why is it a class?
- # ##########
-
- #values = $('.value_table').find(".edit_sample_value")
-
-
tables = ['samples_primary', 'samples_other']
for table in tables
rows = $("#" + table).find('tr')
console.log("[fuji3] rows:", rows)
for row in rows
+ name = $(row).find('.edit_sample_sample_name').html()
+ name = $.trim(name)
real_value = $(row).find('.edit_sample_value').val()
- #row = $(value).closest("tr")
- #category = row[0].id
console.log("real_value:", real_value)
checkbox = $(row).find(".edit_sample_checkbox")
checked = $(checkbox).attr('checked')
@@ -139,11 +133,13 @@ $ ->
if checked and is_number(real_value) and real_value != ""
console.log("in the iffy if")
real_value = parseFloat(real_value)
- #if _(category).startsWith("Primary")
+
sample_sets[table].add_value(real_value)
- #else if _(category).startsWith("Other")
- # sample_sets.other_only.add_value(real_value)
- sample_sets['samples_all'].add_value(real_value)
+ console.log("checking name of:", name)
+ if not (name of already_seen)
+ console.log("haven't seen")
+ sample_sets['samples_all'].add_value(real_value)
+ already_seen[name] = true
console.log("towards end:", sample_sets)
update_stat_values(sample_sets)
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 3a7bc387..1037c890 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -115,7 +115,8 @@
return _results;
};
edit_data_change = function() {
- var checkbox, checked, real_value, row, rows, sample_sets, table, tables, _i, _j, _len, _len1;
+ var already_seen, checkbox, checked, name, real_value, row, rows, sample_sets, table, tables, _i, _j, _len, _len1;
+ already_seen = {};
sample_sets = {
samples_primary: new Stats([]),
samples_other: new Stats([]),
@@ -129,6 +130,8 @@
console.log("[fuji3] rows:", rows);
for (_j = 0, _len1 = rows.length; _j < _len1; _j++) {
row = rows[_j];
+ name = $(row).find('.edit_sample_sample_name').html();
+ name = $.trim(name);
real_value = $(row).find('.edit_sample_value').val();
console.log("real_value:", real_value);
checkbox = $(row).find(".edit_sample_checkbox");
@@ -137,7 +140,12 @@
console.log("in the iffy if");
real_value = parseFloat(real_value);
sample_sets[table].add_value(real_value);
- sample_sets['samples_all'].add_value(real_value);
+ console.log("checking name of:", name);
+ if (!(name in already_seen)) {
+ console.log("haven't seen");
+ sample_sets['samples_all'].add_value(real_value);
+ already_seen[name] = true;
+ }
}
}
}