about summary refs log tree commit diff
path: root/wqflask/utility/gen_geno_ob.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/utility/gen_geno_ob.py')
-rw-r--r--wqflask/utility/gen_geno_ob.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/wqflask/utility/gen_geno_ob.py b/wqflask/utility/gen_geno_ob.py
index 23b0b650..e619b7b6 100644
--- a/wqflask/utility/gen_geno_ob.py
+++ b/wqflask/utility/gen_geno_ob.py
@@ -1,9 +1,8 @@
-from __future__ import absolute_import, division, print_function
-
 import utility.logger
-logger = utility.logger.getLogger(__name__ )
+logger = utility.logger.getLogger(__name__)
+
 
-class genotype(object):
+class genotype:
     """
     Replacement for reaper.Dataset so we can remove qtlreaper use while still generating mapping output figure
     """
@@ -20,7 +19,7 @@ class genotype(object):
         self.filler = False
         self.mb_exists = False
 
-        #ZS: This is because I'm not sure if some files switch the column that contains Mb/cM positions; might be unnecessary
+        # ZS: This is because I'm not sure if some files switch the column that contains Mb/cM positions; might be unnecessary
         self.cm_column = 2
         self.mb_column = 3
 
@@ -38,14 +37,16 @@ class genotype(object):
         return len(self.chromosomes)
 
     def read_rdata_output(self, qtl_results):
-        #ZS: This is necessary because R/qtl requires centimorgan marker positions, which it normally gets from the .geno file, but that doesn't exist for HET3-ITP (which only has RData), so it needs to read in the marker cM positions from the results
-        self.chromosomes = [] #ZS: Overwriting since the .geno file's contents are just placeholders
+        # ZS: This is necessary because R/qtl requires centimorgan marker positions, which it normally gets from the .geno file, but that doesn't exist for HET3-ITP (which only has RData), so it needs to read in the marker cM positions from the results
+        # ZS: Overwriting since the .geno file's contents are just placeholders
+        self.chromosomes = []
 
-        this_chr = "" #ZS: This is so it can track when the chromosome changes as it iterates through markers
+        this_chr = ""  # ZS: This is so it can track when the chromosome changes as it iterates through markers
         chr_ob = None
         for marker in qtl_results:
             locus = Locus(self)
-            if (str(marker['chr']) != this_chr) and this_chr != "X": #ZS: This is really awkward but works as a temporary fix
+            # ZS: This is really awkward but works as a temporary fix
+            if (str(marker['chr']) != this_chr) and this_chr != "X":
                 if this_chr != "":
                     self.chromosomes.append(chr_ob)
                 this_chr = str(marker['chr'])
@@ -70,7 +71,7 @@ class genotype(object):
         with open(filename, 'r') as geno_file:
             lines = geno_file.readlines()
 
-            this_chr = "" #ZS: This is so it can track when the chromosome changes as it iterates through markers
+            this_chr = ""  # ZS: This is so it can track when the chromosome changes as it iterates through markers
             chr_ob = None
             for line in lines:
                 if line[0] == "#":
@@ -121,7 +122,8 @@ class genotype(object):
 
             self.chromosomes.append(chr_ob)
 
-class Chr(object):
+
+class Chr:
     def __init__(self, name, geno_ob):
         self.name = name
         self.loci = []
@@ -142,8 +144,9 @@ class Chr(object):
     def add_marker(self, marker_row):
         self.loci.append(Locus(self.geno_ob, marker_row))
 
-class Locus(object):
-    def __init__(self, geno_ob, marker_row = None):
+
+class Locus:
+    def __init__(self, geno_ob, marker_row=None):
         self.chr = None
         self.name = None
         self.cM = None
@@ -155,9 +158,11 @@ class Locus(object):
             try:
                 self.cM = float(marker_row[geno_ob.cm_column])
             except:
-                self.cM = float(marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else 0
+                self.cM = float(
+                    marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else 0
             try:
-                self.Mb = float(marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else None
+                self.Mb = float(
+                    marker_row[geno_ob.mb_column]) if geno_ob.mb_exists else None
             except:
                 self.Mb = self.cM
 
@@ -175,7 +180,7 @@ class Locus(object):
                 start_pos = 3
 
             for allele in marker_row[start_pos:]:
-                if allele in geno_table.keys():
+                if allele in list(geno_table.keys()):
                     self.genotype.append(geno_table[allele])
-                else: #ZS: Some genotype appears that isn't specified in the metadata, make it unknown
-                    self.genotype.append("U")
\ No newline at end of file
+                else:  # ZS: Some genotype appears that isn't specified in the metadata, make it unknown
+                    self.genotype.append("U")