aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorzsloan2016-11-02 20:00:04 +0000
committerzsloan2016-11-02 20:00:04 +0000
commit717677b0c09f6ba08268db12d4889503cc2606d9 (patch)
treee362121714dcffec39c68b22e1780fd0a4125aba /wqflask/base
parent684f461b815e3920419874fccb036c359cae35d8 (diff)
downloadgenenetwork2-717677b0c09f6ba08268db12d4889503cc2606d9.tar.gz
Added Scroller functionality to regular (but not global) search, which increases table load speed
In order to implement Scroller (and make table look nicer), all rows are the same height and excess description/authors text is shown in a tooltip Increased table width for non-Geno DBs Fixed issue where Genotype traits did not fetch their location_repr (text for displaying location), causing that column to be blank in searches Fixed issue causing Correlation Matrix cells to not be colored corresponding with their correlation and also increased cell font a little Fixed issue where dataset link in the Correlation Page did not correctly point to corresponding GN1 page
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/data_set.py17
-rw-r--r--wqflask/base/trait.py103
2 files changed, 107 insertions, 13 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index fddfce58..04436a2e 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -271,7 +271,8 @@ class DatasetGroup(object):
self.f1list = None
self.parlist = None
self.get_f1_parent_strains()
- #logger.debug("parents/f1s: {}:{}".format(self.parlist, self.f1list))
+
+ self.accession_id = self.get_accession_id()
self.species = webqtlDatabaseFunction.retrieve_species(self.name)
@@ -279,6 +280,20 @@ class DatasetGroup(object):
self.allsamples = None
self._datasets = None
+ def get_accession_id(self):
+ results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where
+ InbredSet.Name = %s and
+ PublishFreeze.InbredSetId = InbredSet.Id and
+ InfoFiles.InfoPageName = PublishFreeze.Name and
+ PublishFreeze.public > 0 and
+ PublishFreeze.confidentiality < 1 order by
+ PublishFreeze.CreateTime desc""", (self.name)).fetchone()
+
+ if results != None:
+ return str(results[0])
+ else:
+ return "None"
+
def get_specified_markers(self, markers = []):
self.markers = HumanMarkers(self.name, markers)
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 276c624a..8788d983 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -91,16 +91,27 @@ class GeneralTrait(object):
additive=self.additive
)
elif self.dataset.type == "Publish":
- return dict(name=self.name,
- dataset=self.dataset.name,
- description=self.description_display,
- authors=self.authors,
- pubmed_text=self.pubmed_text,
- pubmed_link=self.pubmed_link,
- lrs_score=self.LRS_score_repr,
- lrs_location=self.LRS_location_repr,
- additive=self.additive
- )
+ if self.pubmed_id:
+ return dict(name=self.name,
+ dataset=self.dataset.name,
+ description=self.description_display,
+ authors=self.authors,
+ pubmed_text=self.pubmed_text,
+ pubmed_link=self.pubmed_link,
+ lrs_score=self.LRS_score_repr,
+ lrs_location=self.LRS_location_repr,
+ additive=self.additive
+ )
+ else:
+ return dict(name=self.name,
+ dataset=self.dataset.name,
+ description=self.description_display,
+ authors=self.authors,
+ pubmed_text=self.pubmed_text,
+ lrs_score=self.LRS_score_repr,
+ lrs_location=self.LRS_location_repr,
+ additive=self.additive
+ )
elif self.dataset.type == "Geno":
return dict(name=self.name,
dataset=self.dataset.name,
@@ -109,6 +120,62 @@ class GeneralTrait(object):
else:
return dict()
+ def jsonable_table_row(self, index, search_type):
+ """Return a list suitable for json and intended to be displayed in a table
+
+ Actual turning into json doesn't happen here though"""
+
+ if self.dataset.type == "ProbeSet":
+ if self.mean == "":
+ mean = "N/A"
+ else:
+ mean = "%.3f" % round(float(self.additive), 2)
+ if self.additive == "":
+ additive = "N/A"
+ else:
+ additive = "%.3f" % round(float(self.additive), 2)
+ return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" value="{{ data_hmac(\'{}:{}\'.format(' + str(self.name) + ',' + self.dataset.name + ')) }}">',
+ index,
+ '<a href="/show_trait?trait_id='+str(self.name)+'&dataset='+self.dataset.name+'">'+str(self.name)+'</a>',
+ self.symbol,
+ self.description_display,
+ self.location_repr,
+ mean,
+ self.LRS_score_repr,
+ self.LRS_location_repr,
+ additive]
+ elif self.dataset.type == "Publish":
+ if self.additive == "":
+ additive = "N/A"
+ else:
+ additive = "%.2f" % round(float(self.additive), 2)
+ if self.pubmed_id:
+ return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" value="{{ data_hmac(\'{}:{}\'.format(' + str(self.name) + ',' + self.dataset.name + ')) }}">',
+ index,
+ '<a href="/show_trait?trait_id='+str(self.name)+'&dataset='+self.dataset.name+'">'+str(self.name)+'</a>',
+ self.description_display,
+ self.authors,
+ '<a href="' + self.pubmed_link + '">' + self.pubmed_text + '</href>',
+ self.LRS_score_repr,
+ self.LRS_location_repr,
+ additive]
+ else:
+ return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" value="{{ data_hmac(\'{}:{}\'.format(' + str(self.name) + ',' + self.dataset.name + ')) }}">',
+ index,
+ '<a href="/show_trait?trait_id='+str(self.name)+'&dataset='+self.dataset.name+'">'+str(self.name)+'</a>',
+ self.description_display,
+ self.authors,
+ self.pubmed_text,
+ self.LRS_score_repr,
+ self.LRS_location_repr,
+ additive]
+ elif self.dataset.type == "Geno":
+ return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" value="{{ data_hmac(\'{}:{}\'.format(' + str(self.name) + ',' + self.dataset.name + ')) }}">',
+ index,
+ '<a href="/show_trait?trait_id='+str(self.name)+'&dataset='+self.dataset.name+'">'+str(self.name)+'</a>',
+ self.location_repr]
+ else:
+ return dict()
def get_name(self):
stringy = ""
@@ -418,7 +485,7 @@ class GeneralTrait(object):
self.description_display = description_display
#XZ: trait_location_value is used for sorting
- trait_location_repr = 'N/A'
+ self.location_repr = 'N/A'
trait_location_value = 1000000
if self.chr and self.mb:
@@ -438,6 +505,18 @@ class GeneralTrait(object):
self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb))
self.location_value = trait_location_value
+ elif self.dataset.type == "Geno":
+ self.location_repr = 'N/A'
+ trait_location_value = 1000000
+
+ if self.chr and self.mb:
+ #Checks if the chromosome number can be cast to an int (i.e. isn't "X" or "Y")
+ #This is so we can convert the location to a number used for sorting
+ trait_location_value = convert_location_to_value(self.chr, self.mb)
+
+ #ZS: Put this in function currently called "convert_location_to_value"
+ self.location_repr = 'Chr%s: %.6f' % (self.chr, float(self.mb))
+ self.location_value = trait_location_value
if get_qtl_info:
#LRS and its location
@@ -459,7 +538,7 @@ class GeneralTrait(object):
logger.sql(query)
trait_qtl = g.db.execute(query).fetchone()
if trait_qtl:
- self.locus, self.lrs, self.pvalue, self.mean, self.additive= trait_qtl
+ self.locus, self.lrs, self.pvalue, self.mean, self.additive = trait_qtl
if self.locus:
query = """
select Geno.Chr, Geno.Mb from Geno, Species