about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--wqflask/base/data_set.py11
-rw-r--r--wqflask/utility/helper_functions.py4
-rw-r--r--wqflask/wqflask/show_trait/show_trait.py72
-rwxr-xr-xwqflask/wqflask/templates/index_page_orig.html10
-rw-r--r--wqflask/wqflask/templates/submit_trait.html12
-rw-r--r--wqflask/wqflask/views.py23
6 files changed, 46 insertions, 86 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 178234fe..cc5a428c 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -262,8 +262,6 @@ class Markers(object):
         elif isinstance(p_values, dict):
             filtered_markers = []
             for marker in self.markers:
-                #logger.debug("marker[name]", marker['name'])
-                #logger.debug("p_values:", p_values)
                 if marker['name'] in p_values:
                     #logger.debug("marker {} IS in p_values".format(i))
                     marker['p_value'] = p_values[marker['name']]
@@ -276,10 +274,6 @@ class Markers(object):
                         marker['lrs_value'] = - \
                             math.log10(marker['p_value']) * 4.61
                     filtered_markers.append(marker)
-                # else:
-                    #logger.debug("marker {} NOT in p_values".format(i))
-                    # self.markers.remove(marker)
-                    #del self.markers[i]
             self.markers = filtered_markers
 
 
@@ -306,7 +300,6 @@ class HumanMarkers(Markers):
                 marker['Mb'] = float(splat[3]) / 1000000
             self.markers.append(marker)
 
-        #logger.debug("markers is: ", pf(self.markers))
 
     def add_pvalues(self, p_values):
         super(HumanMarkers, self).add_pvalues(p_values)
@@ -520,7 +513,6 @@ def datasets(group_name, this_group=None):
                     break
 
             if tissue_already_exists:
-                #logger.debug("dataset_menu:", dataset_menu[i]['datasets'])
                 dataset_menu[i]['datasets'].append((dataset, dataset_short))
             else:
                 dataset_menu.append(dict(tissue=tissue_name,
@@ -735,9 +727,6 @@ class PhenotypeDataSet(DataSet):
     DS_NAME_MAP['Publish'] = 'PhenotypeDataSet'
 
     def setup(self):
-
-        #logger.debug("IS A PHENOTYPEDATASET")
-
         # Fields in the database table
         self.search_fields = ['Phenotype.Post_publication_description',
                               'Phenotype.Pre_publication_description',
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py
index 7eb7f013..15d5b3ab 100644
--- a/wqflask/utility/helper_functions.py
+++ b/wqflask/utility/helper_functions.py
@@ -10,7 +10,6 @@ import logging
 logger = logging.getLogger(__name__ )
 
 def get_species_dataset_trait(self, start_vars):
-    #assert type(read_genotype) == type(bool()), "Expecting boolean value for read_genotype"
     if "temp_trait" in list(start_vars.keys()):
       if start_vars['temp_trait'] == "True":
         self.dataset = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = start_vars['group'])
@@ -27,9 +26,6 @@ def get_species_dataset_trait(self, start_vars):
                                    get_qtl_info=True)
     logger.debug("After creating trait")
 
-    #if read_genotype:
-    #self.dataset.group.read_genotype_file()
-    #self.genotype = self.dataset.group.genotype
 
 def get_trait_db_obs(self, trait_db_list):
     if isinstance(trait_db_list, str):
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 6892f02b..ed55d473 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -138,17 +138,12 @@ class ShowTrait(object):
 
         self.ncbi_summary = get_ncbi_summary(self.this_trait)
 
-        #Get nearest marker for composite mapping
+        # Get nearest marker for composite mapping
         if not self.temp_trait:
             if check_if_attr_exists(self.this_trait, 'locus_chr') and self.dataset.type != "Geno" and self.dataset.type != "Publish":
                 self.nearest_marker = get_nearest_marker(self.this_trait, self.dataset)
-                #self.nearest_marker1 = get_nearest_marker(self.this_trait, self.dataset)[0]
-                #self.nearest_marker2 = get_nearest_marker(self.this_trait, self.dataset)[1]
             else:
                 self.nearest_marker = ""
-                #self.nearest_marker1 = ""
-                #self.nearest_marker2 = ""
-
 
         self.make_sample_lists()
 
@@ -168,16 +163,19 @@ class ShowTrait(object):
 
         categorical_var_list = []
         if not self.temp_trait:
-            categorical_var_list = get_categorical_variables(self.this_trait, self.sample_groups[0]) #ZS: Only using first samplelist, since I think mapping only uses those samples
+            # ZS: Only using first samplelist, since I think mapping only uses those samples
+            categorical_var_list = get_categorical_variables(self.this_trait, self.sample_groups[0])
 
-        #ZS: Get list of chromosomes to select for mapping
+        # ZS: Get list of chromosomes to select for mapping
         self.chr_list = [["All", -1]]
         for i, this_chr in enumerate(self.dataset.species.chromosomes.chromosomes):
             self.chr_list.append([self.dataset.species.chromosomes.chromosomes[this_chr].name, i])
 
         self.genofiles = self.dataset.group.get_genofiles()
 
-        if "QTLReaper" or "R/qtl" in dataset.group.mapping_names: #ZS: No need to grab scales from .geno file unless it's using a mapping method that reads .geno files
+        # ZS: No need to grab scales from .geno file unless it's using
+        # a mapping method that reads .geno files
+        if "QTLReaper" or "R/qtl" in dataset.group.mapping_names: 
             if self.genofiles:
                 self.scales_in_geno = get_genotype_scales(self.genofiles)
             else:
@@ -187,10 +185,15 @@ class ShowTrait(object):
 
         self.has_num_cases = has_num_cases(self.this_trait)
 
-        #ZS: Needed to know whether to display bar chart + get max sample name length in order to set table column width
+        # ZS: Needed to know whether to display bar chart + get max
+        # sample name length in order to set table column width
         self.num_values = 0
-        self.binary = "true" #ZS: So it knows whether to display the Binary R/qtl mapping method, which doesn't work unless all values are 0 or 1
-        self.negative_vals_exist = "false" #ZS: Since we don't want to show log2 transform option for situations where it doesn't make sense
+        # ZS: So it knows whether to display the Binary R/qtl mapping
+        # method, which doesn't work unless all values are 0 or 1
+        self.binary = "true"
+        # ZS: Since we don't want to show log2 transform option for
+        # situations where it doesn't make sense
+        self.negative_vals_exist = "false"
         max_samplename_width = 1
         for group in self.sample_groups:
             for sample in group.sample_list:
@@ -203,7 +206,8 @@ class ShowTrait(object):
                     if sample.value < 0:
                         self.negative_vals_exist = "true"
 
-        #ZS: Check whether any attributes have few enough distinct values to show the "Block samples by group" option
+        # ZS: Check whether any attributes have few enough distinct
+        # values to show the "Block samples by group" option
         self.categorical_attr_exists = "false"
         for attribute in self.sample_groups[0].attributes:
             if len(self.sample_groups[0].attributes[attribute].distinct_values) <= 10:
@@ -258,7 +262,6 @@ class ShowTrait(object):
         if not self.temp_trait:
             if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish":
                 hddn['control_marker'] = self.nearest_marker
-                #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2
         hddn['do_control'] = False
         hddn['maf'] = 0.05
         hddn['mapping_scale'] = "physic"
@@ -268,7 +271,8 @@ class ShowTrait(object):
         if len(self.scales_in_geno) < 2:
             hddn['mapping_scale'] = self.scales_in_geno[list(self.scales_in_geno.keys())[0]][0][0]
 
-        # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self
+        # We'll need access to this_trait and hddn in the Jinja2
+        # Template, so we put it inside self
         self.hddn = hddn
 
         js_data = dict(trait_id = self.trait_id,
@@ -294,7 +298,8 @@ class ShowTrait(object):
         self.js_data = js_data
 
     def get_external_links(self):
-        #ZS: There's some weirdness here because some fields don't exist while others are empty strings
+        # ZS: There's some weirdness here because some fields don't
+        # exist while others are empty strings
         self.pubmed_link = webqtlConfig.PUBMEDLINK_URL % self.this_trait.pubmed_id if check_if_attr_exists(self.this_trait, 'pubmed_id') else None
         self.ncbi_gene_link = webqtlConfig.NCBI_LOCUSID % self.this_trait.geneid if check_if_attr_exists(self.this_trait, 'geneid') else None
         self.omim_link = webqtlConfig.OMIM_ID % self.this_trait.omim if check_if_attr_exists(self.this_trait, 'omim') else None
@@ -320,7 +325,6 @@ class ShowTrait(object):
             self.panther_link = webqtlConfig.PANTHER_URL % self.this_trait.symbol
             self.ebi_gwas_link = webqtlConfig.EBIGWAS_URL % self.this_trait.symbol
             self.protein_atlas_link = webqtlConfig.PROTEIN_ATLAS_URL % self.this_trait.symbol
-            #self.open_targets_link = webqtlConfig.OPEN_TARGETS_URL % self.this_trait.symbol
 
             if self.dataset.group.species == "mouse" or self.dataset.group.species == "human":
                 self.rgd_link = webqtlConfig.RGD_URL % (self.this_trait.symbol, self.dataset.group.species.capitalize())
@@ -429,7 +433,9 @@ class ShowTrait(object):
                     all_samples_ordered.append(sample)
                     other_sample_names.append(sample)
 
-            #ZS: CFW is here because the .geno file doesn't properly contain its full list of samples. This should probably be fixed.
+            # ZS: CFW is here because the .geno file doesn't properly
+            # contain its full list of samples. This should probably
+            # be fixed.
             if self.dataset.group.species == "human" or (set(primary_sample_names) == set(parent_f1_samples)) or self.dataset.group.name == "CFW":
                 primary_sample_names += other_sample_names
                 other_sample_names = []
@@ -445,7 +451,8 @@ class ShowTrait(object):
                                             sample_group_type='primary',
                                             header=primary_header)
 
-            #if other_sample_names and self.dataset.group.species != "human" and self.dataset.group.name != "CFW":
+            # if other_sample_names and self.dataset.group.species !=
+            # "human" and self.dataset.group.name != "CFW":
             if len(other_sample_names) > 0:
                 other_sample_names.sort() #Sort other samples
                 if parent_f1_samples:
@@ -539,7 +546,8 @@ def get_z_scores(sample_groups):
 def get_nearest_marker(this_trait, this_db):
     this_chr = this_trait.locus_chr
     this_mb = this_trait.locus_mb
-    #One option is to take flanking markers, another is to take the two (or one) closest
+    # One option is to take flanking markers, another is to take the
+    # two (or one) closest
     query = """SELECT Geno.Name
                FROM Geno, GenoXRef, GenoFreeze
                WHERE Geno.Chr = '{}' AND
@@ -552,7 +560,6 @@ def get_nearest_marker(this_trait, this_db):
 
     if result == []:
         return ""
-        #return "", ""
     else:
         return result[0][0]
 
@@ -617,7 +624,8 @@ def check_if_attr_exists(the_trait, id_type):
 
 def get_ncbi_summary(this_trait):
     if check_if_attr_exists(this_trait, 'geneid'):
-        #ZS: Need to switch this try/except to something that checks the output later
+        # ZS: Need to switch this try/except to something that checks
+        # the output later
         try:
             response = requests.get("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=%s&retmode=json" % this_trait.geneid)
             summary = json.loads(response.content)['result'][this_trait.geneid]['summary']
@@ -661,8 +669,8 @@ def get_genotype_scales(genofiles):
 
 def get_scales_from_genofile(file_location):
     geno_path = locate_ignore_error(file_location, 'genotype')
-
-    if not geno_path: #ZS: This is just to allow the code to run when
+    # ZS: This is just to allow the code to run when
+    if not geno_path:
         return [["physic", "Mb"]]
     cm_and_mb_cols_exist = True
     cm_column = None
@@ -670,7 +678,9 @@ def get_scales_from_genofile(file_location):
     with open(geno_path, "r") as geno_fh:
         for i, line in enumerate(geno_fh):
             if line[0] == "#" or line[0] == "@":
-                if "@scale" in line: #ZS: If the scale is made explicit in the metadata, use that
+                # ZS: If the scale is made explicit in the metadata,
+                # use that
+                if "@scale" in line:
                     scale = line.split(":")[1].strip()
                     if scale == "morgan":
                         return [["morgan", "cM"]]
@@ -690,12 +700,16 @@ def get_scales_from_genofile(file_location):
                     mb_column = 3
                 break
 
-        #ZS: This attempts to check whether the cM and Mb columns are 'real', since some .geno files have one column be a copy of the other column, or have one column that is all 0s
+        # ZS: This attempts to check whether the cM and Mb columns are
+        # 'real', since some .geno files have one column be a copy of
+        # the other column, or have one column that is all 0s
         cm_all_zero = True
         mb_all_zero = True
         cm_mb_all_equal = True
         for i, line in enumerate(geno_fh):
-            if first_marker_line <= i < first_marker_line + 10: #ZS: I'm assuming there won't be more than 10 markers where the position is listed as 0
+            # ZS: I'm assuming there won't be more than 10 markers
+            # where the position is listed as 0
+            if first_marker_line <= i < first_marker_line + 10:
                 if cm_column:
                     cm_val = line.split("\t")[cm_column].strip()
                     if cm_val != "0":
@@ -711,8 +725,8 @@ def get_scales_from_genofile(file_location):
                 if i > first_marker_line + 10:
                     break
 
-
-    #ZS: This assumes that both won't be all zero, since if that's the case mapping shouldn't be an option to begin with
+    # ZS: This assumes that both won't be all zero, since if that's
+    # the case mapping shouldn't be an option to begin with
     if mb_all_zero:
         return [["morgan", "cM"]]
     elif cm_mb_all_equal:
diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html
index 7f82b35c..87cf1b45 100755
--- a/wqflask/wqflask/templates/index_page_orig.html
+++ b/wqflask/wqflask/templates/index_page_orig.html
@@ -7,16 +7,6 @@
 {% endblock %}
 {% block content %}
 <!-- Start of body -->
-
-<!--
-    <header class="jumbotron subhead" id="overview">
-        <div class="container">
-            <h1>GeneNetwork</h1>
-            <p class="lead">Open source bioinformatics for systems genetics</p>
-        </div>
-    </header>
--->
-
     <div class="container-fluid" style="min-width: 1210px;">
 
         {{ flash_me() }}
diff --git a/wqflask/wqflask/templates/submit_trait.html b/wqflask/wqflask/templates/submit_trait.html
index 68b06f55..334a608d 100644
--- a/wqflask/wqflask/templates/submit_trait.html
+++ b/wqflask/wqflask/templates/submit_trait.html
@@ -61,18 +61,6 @@
                             <img src="/static/new/images/step2.gif">
                           </div>
                           <div class="col-xs-10">
-                            <!--
-                            <div class="form-group" style="padding-left: 15px;">
-                              <p>
-                                 <b>From a File:</b> You can enter data by entering a file name here. The file should contain a series of numbers representing trait values. 
-                                 The values can be on one line separated by spaces or tabs, or they can be on separate lines. Include one value for each progeny individual
-	                         or recombinant inbred line. Represent missing values with a non-numeric character such as "x". If you have chosen a recombinant inbred set,
-                                 when you submit your data will be displayed in a form where you can confirm and/or edit them. If you enter a file name here, any data that
-                                 you paste into the next section will be ignored.
-                              </p>
-                              <input type="file" name="trait_file" style="border-width: 1px; border-style: solid; border-color: #999999;">
-                            </div>
-                            -->
                             <div class="form-group" style="padding-left: 15px;">
                               <p>
                                  <b>Paste or Type Multiple Values:</b> You can enter data by pasting a series of numbers representing trait values into this area. 
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 2c0ba586..c4b510d4 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -156,12 +156,6 @@ def index_page():
         import_collections = params['import_collections']
         if import_collections == "true":
             g.user_session.import_traits_to_user(params['anon_id'])
-    #if USE_GN_SERVER:
-    #    # The menu is generated using GN_SERVER
-    #    return render_template("index_page.html", gn_server_url = GN_SERVER_URL, version=GN_VERSION)
-    #else:
-
-    # Old style static menu (OBSOLETE)
     return render_template("index_page_orig.html", version=GN_VERSION)
 
 
@@ -343,14 +337,10 @@ def intro():
 
 @app.route("/tutorials")
 def tutorials():
-    #doc = Docs("links", request.args)
-    #return render_template("docs.html", **doc.__dict__)
     return render_template("tutorials.html")
 
 @app.route("/credits")
 def credits():
-    #doc = Docs("links", request.args)
-    #return render_template("docs.html", **doc.__dict__)
     return render_template("credits.html")
 
 @app.route("/update_text", methods=('POST',))
@@ -368,12 +358,9 @@ def submit_trait_form():
 @app.route("/create_temp_trait", methods=('POST',))
 def create_temp_trait():
     logger.info(request.url)
-
-    #template_vars = submit_trait.SubmitTrait(request.form)
-
     doc = Docs("links")
     return render_template("links.html", **doc.__dict__)
-    #return render_template("show_trait.html", **template_vars.__dict__)
+
 
 @app.route('/export_trait_excel', methods=('POST',))
 def export_trait_excel():
@@ -487,21 +474,17 @@ def export_perm_data():
                     mimetype='text/csv',
                     headers={"Content-Disposition":"attachment;filename=" + file_name + ".csv"})
 
+
 @app.route("/show_temp_trait", methods=('POST',))
 def show_temp_trait_page():
     logger.info(request.url)
     template_vars = show_trait.ShowTrait(request.form)
-    #logger.info("js_data before dump:", template_vars.js_data)
     template_vars.js_data = json.dumps(template_vars.js_data,
                                        default=json_default_handler,
                                        indent="   ")
-    # Sorting the keys messes up the ordered dictionary, so don't do that
-                                       #sort_keys=True)
-
-    #logger.info("js_data after dump:", template_vars.js_data)
-    #logger.info("show_trait template_vars:", pf(template_vars.__dict__))
     return render_template("show_trait.html", **template_vars.__dict__)
 
+
 @app.route("/show_trait")
 def show_trait_page():
     logger.info(request.url)