From e7142c0785a9680b56d789f1db0a738d6172de55 Mon Sep 17 00:00:00 2001
From: Zachary Sloan
Date: Mon, 25 Nov 2013 22:53:46 +0000
Subject: Got the interval mapping results into a table
---
wqflask/base/data_set.py | 12 +++++++++---
wqflask/base/trait.py | 26 +++++++++++++++++---------
2 files changed, 26 insertions(+), 12 deletions(-)
(limited to 'wqflask/base')
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index cd8c1ac1..8296adea 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -318,12 +318,17 @@ class DatasetGroup(object):
#determine default genotype object
if self.incparentsf1 and genotype_1.type != "intercross":
- self.genotype = genotype_2
+ #self.genotype = genotype_2
+ genotype = genotype_2
else:
self.incparentsf1 = 0
- self.genotype = genotype_1
+ #self.genotype = genotype_1
+ genotype = genotype_1
- self.samplelist = list(self.genotype.prgy)
+ #self.samplelist = list(self.genotype.prgy)
+ self.samplelist = list(genotype.prgy)
+
+ return genotype
#class DataSets(object):
@@ -1084,6 +1089,7 @@ class MrnaAssayDataSet(DataSet):
Strain.Name
""" % (escape(trait), escape(self.name))
results = g.db.execute(query).fetchall()
+ print("RETRIEVED RESULTS HERE:", results)
return results
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 731f99eb..74bc07bb 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -154,7 +154,7 @@ class GeneralTrait(object):
result.append(None)
return result
- def export_informative(self, incVar=0):
+ def export_informative(self, include_variance=0):
"""
export informative sample
mostly used in qtl regression
@@ -163,12 +163,12 @@ class GeneralTrait(object):
samples = []
vals = []
the_vars = []
- for sample, value in self.data.items():
- if value.val != None:
- if not incVar or value.var != None:
- samples.append(sample)
- vals.append(value.val)
- the_vars.append(value.var)
+ for sample_name, sample_data in self.data.items():
+ if sample_data.value != None:
+ if not include_variance or sample_data.variance != None:
+ samples.append(sample_name)
+ vals.append(sample_data.value)
+ the_vars.append(sample_data.variance)
return samples, vals, the_vars
@@ -235,11 +235,19 @@ class GeneralTrait(object):
# Todo: is this necessary? If not remove
self.data.clear()
+ if self.dataset.group.parlist:
+ all_samples_ordered = (self.dataset.group.parlist +
+ self.dataset.group.f1list +
+ self.dataset.group.samplelist)
+ elif self.dataset.group.f1list:
+ all_samples_ordered = self.dataset.group.f1list + self.dataset.group.samplelist
+ else:
+ all_samples_ordered = self.dataset.group.samplelist
+
if results:
for item in results:
- #name, value, variance, num_cases = item
+ name, value, variance, num_cases = item
if not samplelist or (samplelist and name in samplelist):
- name = item[0]
self.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases)
#def keys(self):
--
cgit 1.4.1
From 8f91205970bfbce7bbe049889a31dfa98c9ef168 Mon Sep 17 00:00:00 2001
From: Zachary Sloan
Date: Tue, 26 Nov 2013 00:09:26 +0000
Subject: Made some progress towards getting the traits inside a collection to
display on hover
---
wqflask/base/data_set.py | 2 +-
wqflask/base/trait.py | 12 +++++++++++-
wqflask/wqflask/collect.py | 11 +++++++++--
.../new/javascript/get_traits_from_collection.coffee | 12 ++++++++++--
.../static/new/javascript/get_traits_from_collection.js | 15 +++++++++++++--
.../wqflask/static/new/javascript/scientific_notation.js | 13 -------------
6 files changed, 44 insertions(+), 21 deletions(-)
delete mode 100644 wqflask/wqflask/static/new/javascript/scientific_notation.js
(limited to 'wqflask/base')
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 8296adea..fbe78d5d 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -629,7 +629,7 @@ class PhenotypeDataSet(DataSet):
description = this_trait.pre_publication_description
- this_trait.description_display = description
+ this_trait.description_display = description.strip()
if not this_trait.year.isdigit():
this_trait.pubmed_text = "N/A"
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 74bc07bb..9e4f0944 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -43,7 +43,7 @@ class GeneralTrait(object):
self.sequence = kw.get('sequence') # Blat sequence, available for ProbeSet
self.data = kw.get('data', {})
- # Sets defaultst
+ # Sets defaults
self.locus = None
self.lrs = None
self.pvalue = None
@@ -63,6 +63,16 @@ class GeneralTrait(object):
# So we could add a simple if statement to short-circuit this if necessary
self.retrieve_info(get_qtl_info=get_qtl_info)
self.retrieve_sample_data()
+
+
+ def jsonable(self):
+ """Return a dict suitable for using as json
+
+ Actual turning into json doesn't happen here though"""
+ return dict(name=self.name,
+ description=self.description_display,
+ mean=self.mean)
+
def get_info(self):
"""For lots of traits just use get_trait_info in dataset instead...that will be way
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 991d281c..48b4b4da 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -150,8 +150,15 @@ def view_collection():
trait_ob.get_info()
trait_obs.append(trait_ob)
- json_version.append(dict(name=trait_ob.name))
- #dis=trait_ob.description))
+ json_version.append(trait_ob.jsonable())
+ #json_version.append(dict(name=trait_ob.name,
+ # description=trait_ob.description_display,
+ # location=trait_ob.location_repr,
+ # mean=trait_ob.mean,
+ # lrs_score=trait_ob.LRS_score_repr,
+ # lrs_location=trait_ob.LRS_location_repr))
+ # dis=trait_ob.description))
+ #json_version.append(trait_ob.__dict__th)
collection_info = dict(trait_obs=trait_obs,
uc = uc)
diff --git a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
index 6854dda5..8566b804 100644
--- a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
+++ b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
@@ -7,9 +7,17 @@ collection_hover = () ->
this_collection_url = $(this).find('.collection_name').prop("href")
this_collection_url += "&json"
console.log("this_collection_url", this_collection_url)
+ $.ajax(
+ dataType: "json",
+ url: this_collection_url,
+ success: process_traits
+ )
+
+process_traits = (trait_data, textStatus, jqXHR) ->
+ console.log('in process_traits with trait_data:', trait_data)
+ html = "
"
+
$ ->
console.log("inside get_traits_from_collection")
$(document).on("mouseover", ".collection_line", collection_hover)
-
-
\ No newline at end of file
diff --git a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
index 9ef31088..57f42a38 100644
--- a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
+++ b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.6.1
(function() {
- var collection_hover;
+ var collection_hover, process_traits;
console.log("before get_traits_from_collection");
@@ -9,7 +9,18 @@
console.log("Hovering over:", $(this));
this_collection_url = $(this).find('.collection_name').prop("href");
this_collection_url += "&json";
- return console.log("this_collection_url", this_collection_url);
+ console.log("this_collection_url", this_collection_url);
+ return $.ajax({
+ dataType: "json",
+ url: this_collection_url,
+ success: process_traits
+ });
+ };
+
+ process_traits = function(trait_data, textStatus, jqXHR) {
+ var html;
+ console.log('in process_traits with trait_data:', trait_data);
+ return html = "";
};
$(function() {
diff --git a/wqflask/wqflask/static/new/javascript/scientific_notation.js b/wqflask/wqflask/static/new/javascript/scientific_notation.js
deleted file mode 100644
index 82c55fda..00000000
--- a/wqflask/wqflask/static/new/javascript/scientific_notation.js
+++ /dev/null
@@ -1,13 +0,0 @@
-jQuery.extend( jQuery.fn.dataTableExt.oSort, {
- "scientific-pre": function ( a ) {
- return parseFloat(a);
- },
-
- "scientific-asc": function ( a, b ) {
- return ((a < b) ? -1 : ((a > b) ? 1 : 0));
- },
-
- "scientific-desc": function ( a, b ) {
- return ((a < b) ? 1 : ((a > b) ? -1 : 0));
- }
-} );
\ No newline at end of file
--
cgit 1.4.1
From 467502356717c50b6cb3311facca501217092a6f Mon Sep 17 00:00:00 2001
From: Zachary Sloan
Date: Wed, 27 Nov 2013 23:21:51 +0000
Subject: Clicking a trait in "color by trait" now gets all of its sample
values that will be used to color the bar graph
---
wqflask/base/trait.py | 25 +++++++++++++-
.../javascript/get_traits_from_collection.coffee | 39 ++++++++++++++--------
.../new/javascript/get_traits_from_collection.js | 39 ++++++++++++++++------
3 files changed, 77 insertions(+), 26 deletions(-)
(limited to 'wqflask/base')
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 9e4f0944..712d9af5 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -12,10 +12,13 @@ from base.data_set import create_dataset
from dbFunction import webqtlDatabaseFunction
from utility import webqtlUtil
+from wqflask import app
+
+import simplejson as json
from MySQLdb import escape_string as escape
from pprint import pformat as pf
-from flask import Flask, g
+from flask import Flask, g, request
def print_mem(stage=""):
mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
@@ -70,6 +73,7 @@ class GeneralTrait(object):
Actual turning into json doesn't happen here though"""
return dict(name=self.name,
+ dataset=self.dataset.name,
description=self.description_display,
mean=self.mean)
@@ -626,3 +630,22 @@ class GeneralTrait(object):
ZValue = 0.5*log((1.0+self.correlation)/(1.0-self.correlation))
ZValue = ZValue*sqrt(self.overlap-3)
self.p_value = 2.0*(1.0 - reaper.normp(abs(ZValue)))
+
+
+
+@app.route("/trait/get_sample_data")
+def get_sample_data():
+ params = request.args
+ trait = params['trait']
+ dataset = params['dataset']
+
+ trait_ob = GeneralTrait(name=trait, dataset_name=dataset)
+
+ return json.dumps({key: value.value for key, value in trait_ob.data.iteritems() })
+
+ #jsonable_sample_data = {}
+ #for sample in trait_ob.data.iteritems():
+ # jsonable_sample_data[sample] = trait_ob.data[sample].value
+ #
+ #return jsonable_sample_data
+
\ No newline at end of file
diff --git a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
index c178d60d..f1d41cbe 100644
--- a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
+++ b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.coffee
@@ -1,50 +1,60 @@
console.log("before get_traits_from_collection")
+# Going to be used to hold collection list
+# So we can repopulate it when the back button is clicked
+collection_list = null
collection_click = () ->
console.log("Clicking on:", $(this))
this_collection_url = $(this).find('.collection_name').prop("href")
this_collection_url += "&json"
console.log("this_collection_url", this_collection_url)
+ collection_list = $("#collections_holder").html()
$.ajax(
dataType: "json",
url: this_collection_url,
success: process_traits
)
+
+trait_click = () ->
+ console.log("Clicking on:", $(this))
+ trait = $(this).find('.trait').text()
+ dataset = $(this).find('.dataset').text()
+ this_trait_url = "/trait/get_sample_data?trait="+trait+"&dataset="+dataset
+ console.log("this_trait_url", this_trait_url)
+ $.ajax(
+ dataType: "json",
+ url: this_trait_url,
+ success: color_by_trait
+ )
-# Going to be used to hold collection list
-# So we can repopulate it when the back button is clicked
-collection_list = null
+color_by_trait = (trait_sample_data, textStatus, jqXHR) ->
+ console.log('in color_by_trait:', trait_sample_data)
process_traits = (trait_data, textStatus, jqXHR) ->
console.log('in process_traits with trait_data:', trait_data)
- the_html = ""
-
- the_html += "
"
- collection_list = $("#collections_holder").html()
- $("#collections_holder").replaceWith(the_html)
+ $("#collections_holder").html(the_html)
$('#collections_holder').colorbox.resize()
back_to_collections = () ->
console.log("collection_list:", collection_list)
- $("#collections_holder").replaceWith(collection_list)
-
- $("#trait_table").wrap("")
+ $("#collections_holder").html(collection_list)
$(document).on("click", ".collection_line", collection_click)
$('#collections_holder').colorbox.resize()
@@ -53,4 +63,5 @@ $ ->
console.log("inside get_traits_from_collection")
$(document).on("click", ".collection_line", collection_click)
+ $(document).on("click", ".trait_line", trait_click)
$(document).on("click", "#back_to_collections", back_to_collections)
diff --git a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
index c0fb7c54..104c411d 100644
--- a/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
+++ b/wqflask/wqflask/static/new/javascript/get_traits_from_collection.js
@@ -1,15 +1,18 @@
// Generated by CoffeeScript 1.6.1
(function() {
- var back_to_collections, collection_click, collection_list, process_traits;
+ var back_to_collections, collection_click, collection_list, color_by_trait, process_traits, trait_click;
console.log("before get_traits_from_collection");
+ collection_list = null;
+
collection_click = function() {
var this_collection_url;
console.log("Clicking on:", $(this));
this_collection_url = $(this).find('.collection_name').prop("href");
this_collection_url += "&json";
console.log("this_collection_url", this_collection_url);
+ collection_list = $("#collections_holder").html();
return $.ajax({
dataType: "json",
url: this_collection_url,
@@ -17,35 +20,48 @@
});
};
- collection_list = null;
+ trait_click = function() {
+ var dataset, this_trait_url, trait;
+ console.log("Clicking on:", $(this));
+ trait = $(this).find('.trait').text();
+ dataset = $(this).find('.dataset').text();
+ this_trait_url = "/trait/get_sample_data?trait=" + trait + "&dataset=" + dataset;
+ console.log("this_trait_url", this_trait_url);
+ return $.ajax({
+ dataType: "json",
+ url: this_trait_url,
+ success: color_by_trait
+ });
+ };
+
+ color_by_trait = function(trait_sample_data, textStatus, jqXHR) {
+ return console.log('in color_by_trait:', trait_sample_data);
+ };
process_traits = function(trait_data, textStatus, jqXHR) {
var the_html, trait, _i, _len;
console.log('in process_traits with trait_data:', trait_data);
- the_html = "";
- the_html += "
";
+ the_html = "";
the_html += " Back ";
the_html += "";
- the_html += "| Record | Description | Mean |
";
+ the_html += "| Record | Data Set | Description | Mean |
";
the_html += "";
for (_i = 0, _len = trait_data.length; _i < _len; _i++) {
trait = trait_data[_i];
- the_html += "| " + trait.name + " | ";
+ the_html += "
| " + trait.name + " | ";
+ the_html += "" + trait.dataset + " | ";
the_html += "" + trait.description + " | ";
the_html += "" + (trait.mean || ' ') + " |
";
}
the_html += "";
the_html += "
";
- the_html += " ";
- collection_list = $("#collections_holder").html();
- $("#collections_holder").replaceWith(the_html);
+ $("#collections_holder").html(the_html);
return $('#collections_holder').colorbox.resize();
};
back_to_collections = function() {
console.log("collection_list:", collection_list);
- $("#collections_holder").replaceWith(collection_list);
- $("#trait_table").wrap("");
+ $("#collections_holder").html(collection_list);
$(document).on("click", ".collection_line", collection_click);
return $('#collections_holder').colorbox.resize();
};
@@ -53,6 +69,7 @@
$(function() {
console.log("inside get_traits_from_collection");
$(document).on("click", ".collection_line", collection_click);
+ $(document).on("click", ".trait_line", trait_click);
return $(document).on("click", "#back_to_collections", back_to_collections);
});
--
cgit 1.4.1