diff options
Diffstat (limited to 'wqflask')
-rwxr-xr-x | wqflask/base/data_set.py | 45 | ||||
-rw-r--r-- | wqflask/base/species.py | 2 | ||||
-rw-r--r-- | wqflask/utility/helper_functions.py | 4 | ||||
-rwxr-xr-x | wqflask/wqflask/show_trait/show_trait.py | 10 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/marker_regression.coffee | 32 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/marker_regression.js | 28 | ||||
-rw-r--r-- | wqflask/wqflask/templates/marker_regression.html | 11 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait_mapping_tools.html | 18 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 29 |
9 files changed, 83 insertions, 96 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index d474302c..10f047f8 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -95,11 +95,14 @@ class DatasetGroup(object): if self.name == 'BXD300': self.name = "BXD" + self.f1list = None + self.parlist = None + self.get_f1_parent_strains() + print("parents/f1s: {}:{}".format(self.parlist, self.f1list)) + self.species = webqtlDatabaseFunction.retrieve_species(self.name) self.incparentsf1 = False - self.f1list = None - self.parlist = None self.allsamples = None self.markers = Markers(self.name) @@ -117,6 +120,18 @@ class DatasetGroup(object): # markers = json.load(json_data) # + def get_f1_parent_strains(self): + try: + # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; + f1, f12, maternal, paternal = webqtlUtil.ParInfo[self.name] + except KeyError: + f1 = f12 = maternal = paternal = None + + if f1 and f12: + self.f1list = [f1, f12] + if maternal and paternal: + self.parlist = [maternal, paternal] + def read_genotype_file(self): '''Read genotype from .geno file instead of database''' #if self.group == 'BXD300': @@ -128,38 +143,24 @@ class DatasetGroup(object): #genotype_2 is Dataset Object with parents and f1 (not for intercross) genotype_1 = reaper.Dataset() - + # reaper barfs on unicode filenames, so here we ensure it's a string full_filename = str(os.path.join(webqtlConfig.GENODIR, self.name + '.geno')) genotype_1.read(full_filename) - print("Got to after read") - - try: - # NL, 07/27/2010. ParInfo has been moved from webqtlForm.py to webqtlUtil.py; - f1, f12, maternal, paternal = webqtlUtil.ParInfo[self.name] - except KeyError: - f1 = f12 = maternal = paternal = None - - - if genotype_1.type == "group" and maternal and paternal: - genotype_2 = genotype_1.add(Mat=maternal, Pat=paternal) #, F1=_f1) + if genotype_1.type == "group" and self.parlist: + genotype_2 = genotype_1.add(Mat=self.parlist[0], Pat=self.parlist[1]) #, F1=_f1) else: genotype_2 = genotype_1 #determine default genotype object if self.incparentsf1 and genotype_1.type != "intercross": - self.genotype = genotype_2 + genotype = genotype_2 else: self.incparentsf1 = 0 - self.genotype = genotype_1 - - self.samplelist = list(self.genotype.prgy) + genotype = genotype_1 - if f1 and f12: - self.f1list = [f1, f12] - if maternal and paternal: - self.parlist = [maternal, paternal] + self.samplelist = list(genotype.prgy) class DataSet(object): diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 9d4cac4c..689e5c05 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -62,7 +62,7 @@ class Chromosomes(object): self.chromosomes[item.Name] = IndChromosome(item.Length) self.set_mb_graph_interval() - self.get_cm_length_list() + #self.get_cm_length_list() def set_mb_graph_interval(self): diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py index 56b409e6..28242c27 100644 --- a/wqflask/utility/helper_functions.py +++ b/wqflask/utility/helper_functions.py @@ -12,7 +12,7 @@ def get_species_dataset_trait(self, start_vars): self.this_trait = GeneralTrait(dataset=self.dataset.name, name=start_vars['trait_id'], cellid=None) - + #if read_genotype: self.dataset.group.read_genotype_file() - self.genotype = self.dataset.group.genotype + #self.genotype = self.dataset.group.genotype diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 16aec827..12d512b2 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -51,10 +51,10 @@ class ShowTrait(object): # cellid=None) # # - #self.dataset.group.read_genotype_file() + self.dataset.group.read_genotype_file() - if not self.dataset.group.genotype: - self.read_data(include_f1=True) + #if not self.dataset.group.genotype: + # self.read_data(include_f1=True) # Todo: Add back in the ones we actually need from below, as we discover we need them @@ -163,8 +163,8 @@ class ShowTrait(object): #if incf1 == None: # incf1 = [] - if not self.genotype: - self.dataset.read_genotype_file() + #if not self.genotype: + # self.dataset.read_genotype_file() if not samplelist: if include_f1: samplelist = self.f1list + self.samplelist diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee index ef56dc99..ebd96b19 100644 --- a/wqflask/wqflask/static/new/javascript/marker_regression.coffee +++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee @@ -10,10 +10,11 @@ $ -> @x_coords = [] @y_coords = [] - @marker_names = [] + @marker_names = [] + console.time('Create coordinates') @create_coordinates() + console.timeEnd('Create coordinates') [@chr_lengths, @cumulative_chr_lengths] = @get_chr_lengths() - console.log("cumulative_chr_len: ", @cumulative_chr_lengths) # Buffer to allow for the ticks/labels to be drawn @x_buffer = @plot_width/30 @@ -25,15 +26,17 @@ $ -> @svg = @create_svg() @plot_coordinates = _.zip(@x_coords, @y_coords, @marker_names) + @plot_height -= @y_buffer @create_scales() + console.time('Create graph') @create_graph() + console.timeEnd('Create graph') get_max_chr: () -> max_chr = 0 for result in @qtl_results chr = parseInt(result.chr) - console.log("foo:", chr, typeof(chr)) if not _.isNaN(chr) if chr > max_chr max_chr = chr @@ -56,7 +59,7 @@ $ -> cumulative_chr_lengths.push(total_length + this_length) total_length += this_length - console.log("total length is:", total_length) + #console.log("total length is:", total_length) return [chr_lengths, cumulative_chr_lengths] @@ -70,13 +73,13 @@ $ -> chr_lengths.push(chr_length) if result.chr != "1" @total_length += chr_lengths[chr_lengths.length - 2] - console.log("total_length is:", @total_length) @x_coords.push(@total_length + parseFloat(result.Mb)) @y_coords.push(result.lod_score) @marker_names.push(result.name) @total_length += chr_lengths[chr_lengths.length-1] show_marker_in_table: (marker_info) -> + console.log("in show_marker_in_table") ### Searches for the select marker in the results table below ### if marker_info marker_name = marker_info[2] @@ -148,11 +151,10 @@ $ -> tick_val = parseInt(@cumulative_chr_lengths[i-1]) for tick in [0..(tick_count-1)] tick_val += 25 - console.log("tick_val is:", tick_val) chr_ticks.push(tick_val) Array::push.apply tick_vals, chr_ticks - console.log("tick_vals:", tick_vals) + #console.log("tick_vals:", tick_vals) return tick_vals add_x_axis: () -> @@ -176,7 +178,6 @@ $ -> else tmp_tick_val += 25 tick_val = tmp_tick_val - console.log("tick_val: ", tick_val) return (tick_val) ) @@ -242,7 +243,6 @@ $ -> for key of @chromosomes chr_names.push(key) chr_info = _.zip(chr_names, @chr_lengths, @cumulative_chr_lengths) - console.log("chr_info is", chr_info) @svg.selectAll("text") .data(chr_info, (d) => return d @@ -250,7 +250,6 @@ $ -> .enter() .append("text") .text((d) => - console.log("d[0] is ", d[0]) return d[0] ) .attr("x", (d) => @@ -263,9 +262,7 @@ $ -> .attr("font-size", "18px") .attr("fill", "grey") - add_plot_points: () -> - console.log("x_max is:", @x_max) @svg.selectAll("circle") .data(@plot_coordinates) .enter() @@ -279,16 +276,21 @@ $ -> .attr("r", 2) .classed("circle", true) .on("mouseover", (d) => - d3.select(d3.event.target).classed("d3_highlight", true) + console.log("this:", this) + console.log("d3.event is:", d3.event) + console.log("d is:", d) + d3.select(d3.event) .attr("r", 5) .attr("fill", "yellow") .call(@show_marker_in_table(d)) ) .on("mouseout", () => - d3.select(d3.event.target).classed("d3_highlight", false) + d3.select(d3.event) .attr("r", 2) .attr("fill", "black") .call(@show_marker_in_table()) ) - new Manhattan_Plot(600, 1200)
\ No newline at end of file + console.time('Create manhattan plot') + new Manhattan_Plot(600, 1200) + console.timeEnd('Create manhattan plot')
\ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js index efe6f508..25a8d5b5 100644 --- a/wqflask/wqflask/static/new/javascript/marker_regression.js +++ b/wqflask/wqflask/static/new/javascript/marker_regression.js @@ -17,9 +17,10 @@ this.x_coords = []; this.y_coords = []; this.marker_names = []; + console.time('Create coordinates'); this.create_coordinates(); + console.timeEnd('Create coordinates'); _ref = this.get_chr_lengths(), this.chr_lengths = _ref[0], this.cumulative_chr_lengths = _ref[1]; - console.log("cumulative_chr_len: ", this.cumulative_chr_lengths); this.x_buffer = this.plot_width / 30; this.y_buffer = this.plot_height / 20; this.x_max = this.total_length; @@ -28,7 +29,9 @@ this.plot_coordinates = _.zip(this.x_coords, this.y_coords, this.marker_names); this.plot_height -= this.y_buffer; this.create_scales(); + console.time('Create graph'); this.create_graph(); + console.timeEnd('Create graph'); } Manhattan_Plot.prototype.get_max_chr = function() { @@ -38,7 +41,6 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { result = _ref[_i]; chr = parseInt(result.chr); - console.log("foo:", chr, typeof chr); if (!_.isNaN(chr)) { if (chr > max_chr) { max_chr = chr; @@ -65,7 +67,6 @@ cumulative_chr_lengths.push(total_length + this_length); total_length += this_length; } - console.log("total length is:", total_length); return [chr_lengths, cumulative_chr_lengths]; }; @@ -82,7 +83,6 @@ chr_lengths.push(chr_length); if (result.chr !== "1") { this.total_length += chr_lengths[chr_lengths.length - 2]; - console.log("total_length is:", this.total_length); } } this.x_coords.push(this.total_length + parseFloat(result.Mb)); @@ -93,10 +93,11 @@ }; Manhattan_Plot.prototype.show_marker_in_table = function(marker_info) { + var marker_name; + console.log("in show_marker_in_table"); /* Searches for the select marker in the results table below */ - var marker_name; if (marker_info) { marker_name = marker_info[2]; } else { @@ -160,12 +161,10 @@ tick_val = parseInt(this.cumulative_chr_lengths[i - 1]); for (tick = _k = 0, _ref2 = tick_count - 1; 0 <= _ref2 ? _k <= _ref2 : _k >= _ref2; tick = 0 <= _ref2 ? ++_k : --_k) { tick_val += 25; - console.log("tick_val is:", tick_val); chr_ticks.push(tick_val); } Array.prototype.push.apply(tick_vals, chr_ticks); } - console.log("tick_vals:", tick_vals); return tick_vals; }; @@ -191,7 +190,6 @@ tick_val = tmp_tick_val; } } - console.log("tick_val: ", tick_val); return tick_val; }); return this.svg.append("g").attr("class", "x_axis").attr("transform", "translate(0," + this.plot_height + ")").call(xAxis).selectAll("text").attr("text-anchor", "right").attr("dx", "-1.6em").attr("transform", function(d) { @@ -235,11 +233,9 @@ chr_names.push(key); } chr_info = _.zip(chr_names, this.chr_lengths, this.cumulative_chr_lengths); - console.log("chr_info is", chr_info); return this.svg.selectAll("text").data(chr_info, function(d) { return d; }).enter().append("text").text(function(d) { - console.log("d[0] is ", d[0]); return d[0]; }).attr("x", function(d) { return _this.x_scale(d[2] - d[1] / 2); @@ -248,22 +244,26 @@ Manhattan_Plot.prototype.add_plot_points = function() { var _this = this; - console.log("x_max is:", this.x_max); return this.svg.selectAll("circle").data(this.plot_coordinates).enter().append("circle").attr("cx", function(d) { return _this.x_buffer + ((_this.plot_width - _this.x_buffer) * d[0] / _this.x_max); }).attr("cy", function(d) { return _this.plot_height - ((_this.plot_height - _this.y_buffer) * d[1] / _this.y_max); }).attr("r", 2).classed("circle", true).on("mouseover", function(d) { - return d3.select(d3.event.target).classed("d3_highlight", true).attr("r", 5).attr("fill", "yellow").call(_this.show_marker_in_table(d)); + console.log("this:", _this); + console.log("d3.event is:", d3.event); + console.log("d is:", d); + return d3.select(d3.event).attr("r", 5).attr("fill", "yellow").call(_this.show_marker_in_table(d)); }).on("mouseout", function() { - return d3.select(d3.event.target).classed("d3_highlight", false).attr("r", 2).attr("fill", "black").call(_this.show_marker_in_table()); + return d3.select(d3.event).attr("r", 2).attr("fill", "black").call(_this.show_marker_in_table()); }); }; return Manhattan_Plot; })(); - return new Manhattan_Plot(600, 1200); + console.time('Create manhattan plot'); + new Manhattan_Plot(600, 1200); + return console.timeEnd('Create manhattan plot'); }); }).call(this); diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html index fc068d21..afbbb7c9 100644 --- a/wqflask/wqflask/templates/marker_regression.html +++ b/wqflask/wqflask/templates/marker_regression.html @@ -69,18 +69,18 @@ <!--[if lt IE 9]> <script language="javascript" type="text/javascript" src="/static/packages/jqplot/excanvas.js"></script> <![endif]--> - <script language="javascript" type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script> + <script language="javascript" type="text/javascript" src="http://d3js.org/d3.v3.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/marker_regression.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> - - + <script type="text/javascript" charset="utf-8"> $(document).ready( function () { + console.time("Creating table"); $('#qtl_results').dataTable( { //"sDom": "<<'span3'l><'span3'T><'span4'f>'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>", "sDom": "lTftipr", @@ -97,8 +97,11 @@ "sSwfPath": "/static/packages/TableTools/media/swf/copy_csv_xls_pdf.swf" }, "iDisplayLength": 50, - "bLengthChange": true + "bLengthChange": true, + "bDeferRender": true, + "bSortClasses": false } ); + console.timeEnd("Creating table"); }); </script> {% endblock %}
\ No newline at end of file diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 58174c78..a98a75c7 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -41,23 +41,7 @@ <input name="mapping_bootstraps" value="2000" type="text" /> </div> </div> - - - {% if dataset.group.genotype.Mbmap %} - <div class="control-group"> - <label class="control-label">Scale</label> - <div class="controls"> - <label class="radio inline"> - <input type="radio" name="scale" id="scale" value="megabase" checked> - Megabase - </label> - <label class="radio inline"> - <input type="radio" name="scale" id="scale" value="centimorgan"> - Centimorgan - </label> - </div> - </div> - {% endif %} + <div class="control-group"> <label class="control-label"><b>Composite Mapping</b></label> diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index c8432877..46433430 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -31,6 +31,7 @@ from utility import temp_data from wqflask.dataSharing import SharingInfo, SharingInfoPage from base import webqtlFormData +from utility.benchmark import Bench from pprint import pformat as pf @@ -168,25 +169,18 @@ def marker_regression_page(): start_vars[key] = value version = "v5" - print("version is:", version) key = "marker_regression:{}:".format(version) + json.dumps(start_vars, sort_keys=True) - result = Redis.get(key) + with Bench("Loading cache"): + result = Redis.get(key) - print("************************ Starting result *****************") + #print("************************ Starting result *****************") #print("result is [{}]: {}".format(type(result), result)) - print("************************ Ending result ********************") + #print("************************ Ending result ********************") if result: - with open("/tmp/result", "w") as fh: - fh.write(result) print("Cache hit!!!") - import __builtin__ - import reaper - __builtin__.Dataset = reaper.Dataset - #result = yaml.load(result) - result = pickle.loads(result) - print("Done loading yaml") - + with Bench("Loading results"): + result = pickle.loads(result) else: print("Cache miss!!!") template_vars = marker_regression.MarkerRegression(start_vars, temp_uuid) @@ -197,14 +191,17 @@ def marker_regression_page(): result = template_vars.__dict__ - for item in template_vars.__dict__.keys(): - print(" ---**--- {}: {}".format(type(item), item)) + #for item in template_vars.__dict__.keys(): + # print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item)) #causeerror Redis.set(key, pickle.dumps(result)) Redis.expire(key, 60*60) + + with Bench("Rendering template"): + rendered_template = render_template("marker_regression.html", **result) - return render_template("marker_regression.html", **result) + return rendered_template @app.route("/corr_compute", methods=('POST',)) |