From 74d803b0de60edf324b1a6ce589d12a055ef312b Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 30 Oct 2013 19:53:09 -0500 Subject: More work on collections --- wqflask/base/trait.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 6a64eeaf..aea1f9a9 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) @@ -394,8 +399,8 @@ class GeneralTrait(object): 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 -- cgit v1.2.3