about summary refs log tree commit diff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/other_config/wqflask-nginx.conf2
-rw-r--r--wqflask/utility/temp_data.py1
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py9
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/lmm.py15
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee42
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js36
-rw-r--r--wqflask/wqflask/templates/show_trait_progress_bar.html2
7 files changed, 86 insertions, 21 deletions
diff --git a/wqflask/other_config/wqflask-nginx.conf b/wqflask/other_config/wqflask-nginx.conf
index f0076f54..50f9d73c 100644
--- a/wqflask/other_config/wqflask-nginx.conf
+++ b/wqflask/other_config/wqflask-nginx.conf
@@ -36,7 +36,7 @@ server {
             proxy_set_header   X-Real-IP        $remote_addr;
             proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
             
-            proxy_read_timeout 20m;
+            proxy_read_timeout 40m;
      }
 
 }
diff --git a/wqflask/utility/temp_data.py b/wqflask/utility/temp_data.py
index 0df79e54..004d45c6 100644
--- a/wqflask/utility/temp_data.py
+++ b/wqflask/utility/temp_data.py
@@ -11,7 +11,6 @@ class TempData(object):
         self.key = "tempdata:{}".format(self.temp_uuid)
         
     def store(self, field, value):
-        print("Storing...")
         self.redis.hset(self.key, field, value)
         self.redis.expire(self.key, 60*15)  # Expire in 15 minutes
         
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 5f4f9be8..545c8162 100755
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -71,7 +71,7 @@ class MarkerRegression(object):
             p_values, t_stats = self.gen_human_results(pheno_vector, tempdata)
         else:
             genotype_data = [marker['genotypes'] for marker in self.dataset.group.markers.markers]
-            
+
             no_val_samples = self.identify_empty_samples()
             trimmed_genotype_data = self.trim_genotypes(genotype_data, no_value_samples=[])
             pdb.set_trace()
@@ -90,7 +90,12 @@ class MarkerRegression(object):
         
         self.dataset.group.markers.add_pvalues(p_values)
 
-        self.qtl_results = self.dataset.group.markers.markers
+        self.qtl_results = []
+        for marker in self.dataset.group.markers.markers:
+            if marker['p_value'] < 0.2:
+                self.qtl_results.append(marker)
+        
+        #self.qtl_results = self.dataset.group.markers.markers
 
 
     def gen_human_results(self, pheno_vector, tempdata):
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
index 4de77173..0e965c8e 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
@@ -62,17 +62,18 @@ def run_human(pheno_vector,
     
     plink_input.getSNPIterator()
     total_snps = plink_input.numSNPs
-    
-    count = 0
+
     with Bench("snp iterator loop"):
+        count = 0
         for snp, this_id in plink_input:
-            #if count > 1000:
+            #if count > 5000:
             #    break
             count += 1
 
+            
             percent_complete = (float(count) / total_snps) * 100
-            print("percent_complete: ", pf(percent_complete))
-            temp_data.store("percent_complete", percent_complete)        
+            #print("percent_complete: ", percent_complete)
+            temp_data.store("percent_complete", percent_complete)
 
             x = snp[keep].reshape((n,1))
             #x[[1,50,100,200,3000],:] = np.nan
@@ -113,11 +114,9 @@ def run_human(pheno_vector,
                 if refit:
                     lmm_ob.fit(X=x)
                 ts, ps, beta, betaVar = lmm_ob.association(x)
-                
+            
             p_values.append(ps)
             t_stats.append(ts)
-            
-    print("p_values: ", pf(p_values))        
     
     return p_values, t_stats
 
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
index 22427e4f..bc176ab9 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
@@ -1,3 +1,6 @@
+# http://stackoverflow.com/a/4215132/1175849
+root = exports ? this
+
 $ ->
     submit_special = ->
         # Add submit_special class plus a data-url field to any button
@@ -10,7 +13,29 @@ $ ->
         console.log("url is:", url)
         $("#trait_data_form").attr("action", url);
         $("#trait_data_form").submit()
+
+    #update_time_remaining = (percent_complete) ->
+    #    seconds_remaining = 1 / (percent_complete - root.previous_percent) * (100 - percent_complete)
+    #    minutes_remaining = seconds_remaining  / 60
+    #    $('#time_remaining').text(Math.round(minutes_remaining) + " minutes remaining")
+    #    root.previous_percent = percent_complete
         
+    update_time_remaining = (percent_complete) ->
+        now = new Date()
+        period = now.getTime() - root.start_time
+        console.log("period is:", period)
+        if period > 8000
+            total_seconds_remaining = (period / percent_complete * (100 - percent_complete))/1000
+            minutes_remaining = Math.round(total_seconds_remaining / 60)
+            #seconds_remaining = Math.round(total_seconds_remaining % 60)
+            #console.log("seconds_remaining:", seconds_remaining)
+            if minutes_remaining < 3
+                $('#time_remaining').text(Math.round(total_seconds_remaining) + " seconds remaining")
+            else
+                $('#time_remaining').text(minutes_remaining + " minutes remaining")
+        #else
+        #    $('#time_remaining').text("period too small")
+
     get_progress = ->
         console.log("temp_uuid:", $("#temp_uuid").val())
         temp_uuid = $("#temp_uuid").val()
@@ -22,9 +47,16 @@ $ ->
             type: "GET"
             url: url
             success: (progress_data) =>
+                percent_complete = progress_data['percent_complete']
                 console.log("in get_progress data:", progress_data)
-                console.log(progress_data['percent_complete'] + "%")
-                $('#marker_regression_progress').css("width", progress_data['percent_complete'] + "%")
+
+                $('#marker_regression_progress').css("width", percent_complete + "%")
+                
+                if root.start_time
+                    unless isNaN(percent_complete)
+                        update_time_remaining(percent_complete)
+                else
+                    root.start_time = new Date().getTime()
         )
         return false
 
@@ -38,17 +70,19 @@ $ ->
             url: url
             data: form_data
             error: (xhr, ajaxOptions, thrownError) =>
-                alert("some error occurred")
+                alert("Sorry, an error occurred")
                 console.log(xhr)
                 clearInterval(this.my_timer)
                 $('#progress_bar_container').modal('hide')
-                $("body").html("error")        
+                $("body").html("We got an error.")        
             success: (data) =>
                 clearInterval(this.my_timer)
                 $('#progress_bar_container').modal('hide')
                 $("body").html(data)
         )
         console.log("settingInterval")
+
+        #root.start_time = new Date().getTime()
         this.my_timer = setInterval(get_progress, 1000)
         return false
     )
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
index daf9b273..b017257a 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
@@ -1,8 +1,11 @@
 // Generated by CoffeeScript 1.4.0
 (function() {
+  var root;
+
+  root = typeof exports !== "undefined" && exports !== null ? exports : this;
 
   $(function() {
-    var composite_mapping_fields, get_progress, submit_special, toggle_enable_disable,
+    var composite_mapping_fields, get_progress, submit_special, toggle_enable_disable, update_time_remaining,
       _this = this;
     submit_special = function() {
       var url;
@@ -14,6 +17,21 @@
       $("#trait_data_form").attr("action", url);
       return $("#trait_data_form").submit();
     };
+    update_time_remaining = function(percent_complete) {
+      var minutes_remaining, now, period, total_seconds_remaining;
+      now = new Date();
+      period = now.getTime() - root.start_time;
+      console.log("period is:", period);
+      if (period > 8000) {
+        total_seconds_remaining = (period / percent_complete * (100 - percent_complete)) / 1000;
+        minutes_remaining = Math.round(total_seconds_remaining / 60);
+        if (minutes_remaining < 3) {
+          return $('#time_remaining').text(Math.round(total_seconds_remaining) + " seconds remaining");
+        } else {
+          return $('#time_remaining').text(minutes_remaining + " minutes remaining");
+        }
+      }
+    };
     get_progress = function() {
       var params, params_str, temp_uuid, url,
         _this = this;
@@ -29,9 +47,17 @@
         type: "GET",
         url: url,
         success: function(progress_data) {
+          var percent_complete;
+          percent_complete = progress_data['percent_complete'];
           console.log("in get_progress data:", progress_data);
-          console.log(progress_data['percent_complete'] + "%");
-          return $('#marker_regression_progress').css("width", progress_data['percent_complete'] + "%");
+          $('#marker_regression_progress').css("width", percent_complete + "%");
+          if (root.start_time) {
+            if (!isNaN(percent_complete)) {
+              return update_time_remaining(percent_complete);
+            }
+          } else {
+            return root.start_time = new Date().getTime();
+          }
         }
       });
       return false;
@@ -47,11 +73,11 @@
         url: url,
         data: form_data,
         error: function(xhr, ajaxOptions, thrownError) {
-          alert("some error occurred");
+          alert("Sorry, an error occurred");
           console.log(xhr);
           clearInterval(_this.my_timer);
           $('#progress_bar_container').modal('hide');
-          return $("body").html("error");
+          return $("body").html("We got an error.");
         },
         success: function(data) {
           clearInterval(_this.my_timer);
diff --git a/wqflask/wqflask/templates/show_trait_progress_bar.html b/wqflask/wqflask/templates/show_trait_progress_bar.html
index eff5c391..0c3f0e6e 100644
--- a/wqflask/wqflask/templates/show_trait_progress_bar.html
+++ b/wqflask/wqflask/templates/show_trait_progress_bar.html
@@ -6,5 +6,7 @@
         <div class="progress active">
             <div id="marker_regression_progress" class="bar"></div>
         </div>
+        <div id="time_remaining">
+        </div>
     </div>
 </div>
\ No newline at end of file