about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzsloan2019-04-03 11:39:30 -0500
committerzsloan2019-04-03 11:39:30 -0500
commit05ede8b20b88284dae97d632da6e57248053cefd (patch)
treef983a6fff8bf22d93e922d8dceaaaaacda33a95e
parent9169c421251cf8a371bfec9edcdd021c269fa459 (diff)
downloadgenenetwork2-05ede8b20b88284dae97d632da6e57248053cefd.tar.gz
Fixed issue where strains could be added twice in the SNP browser, causing some wonky behavior
-rw-r--r--wqflask/wqflask/snp_browser/snp_browser.py4
-rw-r--r--wqflask/wqflask/templates/snp_browser.html15
2 files changed, 12 insertions, 7 deletions
diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py
index 820551eb..1e28add8 100644
--- a/wqflask/wqflask/snp_browser/snp_browser.py
+++ b/wqflask/wqflask/snp_browser/snp_browser.py
@@ -479,7 +479,7 @@ class SnpBrowser(object):
 
                 the_bases = []
                 for j, item in enumerate(allele_value_list):
-                    if item:
+                    if item and isinstance(item, str):
                         this_base = [item, base_color_dict[item]]
                     else:
                         this_base = ""
@@ -614,7 +614,7 @@ class SnpBrowser(object):
             this_allele_list = []
 
             for item in self.allele_list:
-                if item and (item.lower() not in this_allele_list) and (item != "-"):
+                if item and isinstance(item, str) and (item.lower() not in this_allele_list) and (item != "-"):
                     this_allele_list.append(item.lower())
 
             total_allele_count = len(this_allele_list)
diff --git a/wqflask/wqflask/templates/snp_browser.html b/wqflask/wqflask/templates/snp_browser.html
index 9c549ab5..9d85f767 100644
--- a/wqflask/wqflask/templates/snp_browser.html
+++ b/wqflask/wqflask/templates/snp_browser.html
@@ -454,17 +454,22 @@
 
     $("input[name=add_strain]").click(function() {
       var selected_strain = $("select[name=strains] option:selected").val();
-      $("#chosen_strains_select").append("<option value='" + selected_strain + "'>" + selected_strain + "</option>");
 
       var current_species = $("#species_select").val();
       if (current_species == "Mouse") {
           stored_strains = $("input[name=chosen_strains_mouse]").val().split(",")
-          stored_strains.push(selected_strain)
-          $("input[name=chosen_strains_mouse]").val(stored_strains.join(","))
+          if (!(stored_strains.includes(selected_strain))){
+              stored_strains.push(selected_strain)
+              $("input[name=chosen_strains_mouse]").val(stored_strains.join(","))
+              $("#chosen_strains_select").append("<option value='" + selected_strain + "'>" + selected_strain + "</option>");
+          }
       } else if (current_species == "Rat") {
           stored_strains = $("input[name=chosen_strains_rat]").val().split(",")
-          stored_strains.push(selected_strain)
-          $("input[name=chosen_strains_rat]").val(stored_strains.join(","))
+          if (!(stored_strains.includes(selected_strain))){
+              stored_strains.push(selected_strain)
+              $("input[name=chosen_strains_rat]").val(stored_strains.join(","))
+              $("#chosen_strains_select").append("<option value='" + selected_strain + "'>" + selected_strain + "</option>");
+          }
       }
     });