about summary refs log tree commit diff
path: root/wqflask/base
diff options
context:
space:
mode:
authorZachary Sloan2013-01-03 18:15:32 -0600
committerZachary Sloan2013-01-03 18:15:32 -0600
commit91ed29ef68e8ad29b728f7f574ccc83730d9f7ab (patch)
tree14ab5e3014f5c0a1d8197d2a5587b627e97133ea /wqflask/base
parentfb1c44d09f47fa2e72a90df286ff8bb2a3107f2c (diff)
downloadgenenetwork2-91ed29ef68e8ad29b728f7f574ccc83730d9f7ab.tar.gz
Began working on marker_regression.py and created Chromosomes class
in species.py
Diffstat (limited to 'wqflask/base')
-rwxr-xr-xwqflask/base/data_set.py6
-rw-r--r--wqflask/base/species.py52
2 files changed, 45 insertions, 13 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 36d4acaf..50ef8f57 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -85,8 +85,8 @@ class DatasetGroup(object):
         self.f1list = None
         self.parlist = None
         self.allsamples = None
-            
-            
+
+
     #def read_genotype(self):
     #    self.read_genotype_file()
     #
@@ -158,8 +158,8 @@ class DataSet(object):
 
         self.retrieve_other_names()
         
-        self.species = species.TheSpecies(self)
         self.group = DatasetGroup(self)   # sets self.group and self.group_id and gets genotype
+        self.species = species.TheSpecies(self)
     
        
         
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index 98941ce5..1fd76772 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -1,16 +1,48 @@
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
+import collections
+
+from flask import Flask, g
+
+#from MySQLdb import escape_string as escape
+
+from pprint import pformat as pf
 
 class TheSpecies(object):
     def __init__(self, dataset):
         self.dataset = dataset
+        print("self.dataset is:", pf(self.dataset.__dict__))
+        self.chromosomes = Chromosomes(self.dataset.group.name)
+
+    #@property
+    #def chromosomes(self):
+    #    chromosomes = [("All", -1)]
+    #
+    #    for counter, genotype in enumerate(self.dataset.group.genotype):
+    #        if len(genotype) > 1:
+    #            chromosomes.append((genotype.name, counter))
+    #            
+    #    print("chromosomes is: ", pf(chromosomes))       
+    #            
+    #    return chromosomes
+
+
+
+class Chromosomes(object):
+    def __init__(self, group_name):
+        self.chromosomes = collections.OrderedDict()
+        
+        results = g.db.execute("""
+                Select
+                        Chr_Length.Name, Length from Chr_Length, InbredSet
+                where
+                        Chr_Length.SpeciesId = InbredSet.SpeciesId AND
+                        InbredSet.Name = %s
+                Order by OrderId
+                """, group_name).fetchall()
+        print("bike:", results)
+
+        for item in results:
+            self.chromosomes[item.Name] = item.Length
 
-    @property
-    def chromosomes(self):
-        chromosomes = [("All", -1)]
-  
-        for counter, genotype in enumerate(self.dataset.group.genotype):
-            if len(genotype) > 1:
-                chromosomes.append((genotype.name, counter))
-                
-        return chromosomes
+        print("self.chromosomes:", self.chromosomes)