diff options
Diffstat (limited to 'wqflask/base')
-rwxr-xr-x | wqflask/base/data_set.py | 1 | ||||
-rwxr-xr-x | wqflask/base/trait.py | 43 |
2 files changed, 26 insertions, 18 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index f25e7974..cd8c1ac1 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -224,6 +224,7 @@ class DatasetGroup(object): """ def __init__(self, dataset): """This sets self.group and self.group_id""" + print("dataset name:", dataset.name) self.name, self.id = g.db.execute(dataset.query_for_group).fetchone() if self.name == 'BXD300': self.name = "BXD" diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 6a64eeaf..731f99eb 100755 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -33,6 +33,7 @@ class GeneralTrait(object): assert bool(kw.get('dataset')) != bool(kw.get('dataset_name')), "Needs dataset ob. or name"; if kw.get('dataset_name'): self.dataset = create_dataset(kw.get('dataset_name')) + print(" in GeneralTrait created dataset:", self.dataset) else: self.dataset = kw.get('dataset') self.name = kw.get('name') # Trait ID, ProbeSet ID, Published ID, etc. @@ -41,14 +42,14 @@ class GeneralTrait(object): self.haveinfo = kw.get('haveinfo', False) self.sequence = kw.get('sequence') # Blat sequence, available for ProbeSet self.data = kw.get('data', {}) - + # Sets defaultst self.locus = None self.lrs = None self.pvalue = None self.mean = None self.num_overlap = None - + if kw.get('fullname'): name2 = value.split("::") @@ -57,13 +58,17 @@ class GeneralTrait(object): # self.cellid is set to None above elif len(name2) == 3: self.dataset, self.name, self.cellid = name2 - + # Todo: These two lines are necessary most of the time, but perhaps not all of the time # So we could add a simple if statement to short-circuit this if necessary self.retrieve_info(get_qtl_info=get_qtl_info) self.retrieve_sample_data() - + def get_info(self): + """For lots of traits just use get_trait_info in dataset instead...that will be way + more efficient""" + self.dataset.get_trait_info([self], + webqtlDatabaseFunction.retrieve_species(self.dataset.group.name)) def get_name(self): stringy = "" @@ -77,20 +82,20 @@ class GeneralTrait(object): def get_given_name(self): - """ + """ when user enter a trait or GN generate a trait, user want show the name not the name that generated by GN randomly, the two follow function are used to give the real name and the database. displayName() will show the database also, getGivenName() just show the name. For other trait, displayName() as same as getName(), getGivenName() as same as self.name - + Hongqiang 11/29/07 - + """ stringy = self.name if self.dataset and self.name: - desc = self.dataset.get_desc() + desc = self.dataset.get_desc() if desc: #desc = self.handle_pca(desc) stringy = desc @@ -132,7 +137,7 @@ class GeneralTrait(object): """ export data according to samplelist mostly used in calculating correlation - + """ result = [] for sample in samplelist: @@ -153,7 +158,7 @@ class GeneralTrait(object): """ export informative sample mostly used in qtl regression - + """ samples = [] vals = [] @@ -198,9 +203,9 @@ class GeneralTrait(object): def retrieve_sample_data(self, samplelist=None): if samplelist == None: samplelist = [] - + #assert self.dataset - + #if self.cellid: # #Probe Data # query = ''' @@ -223,7 +228,7 @@ class GeneralTrait(object): # Order BY # Strain.Name # ''' % (self.cellid, self.name, self.dataset.name) - # + # #else: results = self.dataset.retrieve_sample_data(self.name) @@ -330,7 +335,7 @@ class GeneralTrait(object): self.confidential = 1 self.homologeneid = None - + #print("self.geneid is:", self.geneid) #print(" type:", type(self.geneid)) #print("self.dataset.group.name is:", self.dataset.group.name) @@ -382,6 +387,7 @@ class GeneralTrait(object): #trait_qtl = self.cursor.fetchone() if trait_qtl: self.locus, self.lrs, self.pvalue, self.mean = trait_qtl + print("self.locus:", self.locus) if self.locus: query = """ select Geno.Chr, Geno.Mb from Geno, Species @@ -390,12 +396,13 @@ class GeneralTrait(object): Geno.SpeciesId = Species.Id """.format(self.dataset.group.species, self.locus) result = g.db.execute(query).fetchone() - self.locus_chr = result[0] - self.locus_mb = result[1] + if result: + self.locus_chr = result[0] + self.locus_mb = result[1] else: self.locus = self.locus_chr = self.locus_mb = self.lrs = self.pvalue = self.mean = "" - - + + if self.dataset.type == 'Publish': trait_qtl = g.db.execute(""" SELECT |