aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2012-11-27 14:44:14 -0600
committerZachary Sloan2012-11-27 14:44:14 -0600
commit0931212bc692177cfc0ebcf016bc869dd4f88fd8 (patch)
treef238113134c33ab87d9fa7eafa104c8f32981878 /wqflask
parent1749c660a7e71f10bbdec04f8bf7bb77df3f3eef (diff)
downloadgenenetwork2-0931212bc692177cfc0ebcf016bc869dd4f88fd8.tar.gz
Renamed webqtlDataSet.py to data_set.py
Renamed the class webqtlDataset to DataSet Finished cisLRS and transLRS search types in d_search.py Fixed parent/f1 issue in show_trait.py
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/data_set.py (renamed from wqflask/base/webqtlDataset.py)23
-rw-r--r--wqflask/wqflask/do_search.py137
-rw-r--r--wqflask/wqflask/search_results.py34
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py11
4 files changed, 99 insertions, 106 deletions
diff --git a/wqflask/base/webqtlDataset.py b/wqflask/base/data_set.py
index 933077fd..992c673e 100755
--- a/wqflask/base/webqtlDataset.py
+++ b/wqflask/base/data_set.py
@@ -30,7 +30,7 @@ import webqtlConfig
-class webqtlDataset:
+class DataSet(object):
"""
Dataset class defines a dataset in webqtl, can be either Microarray,
Published phenotype, genotype, or user input dataset(temp)
@@ -55,14 +55,7 @@ class webqtlDataset:
self.fullname = 'Temporary Storage'
self.shortname = 'Temp'
elif dbName.find('Publish') >= 0:
- self.searchfield = ['name','post_publication_description','abstract','title','authors']
- self.disfield = ['name','pubmed_id',
- 'pre_publication_description', 'post_publication_description', 'original_description',
- 'pre_publication_abbreviation', 'post_publication_abbreviation',
- 'lab_code', 'submitter', 'owner', 'authorized_users',
- 'authors','title','abstract', 'journal','volume','pages','month',
- 'year','sequence', 'units', 'comments']
- self.type = 'Publish'
+ pass
elif dbName.find('Geno') >= 0:
self.searchfield = ['name','chr']
self.disfield = ['name','chr','mb', 'source2', 'sequence']
@@ -155,3 +148,15 @@ class webqtlDataset:
def genHTML(self, Class='c0dd'):
return HT.Href(text = HT.Span('%s Database' % self.fullname, Class= "fwb " + Class),
url= webqtlConfig.INFOPAGEHREF % self.name,target="_blank")
+
+class PhenotypeDataSet(DataSet):
+
+ def __init__(self):
+ self.searchfield = ['name','post_publication_description','abstract','title','authors']
+ self.disfield = ['name','pubmed_id',
+ 'pre_publication_description', 'post_publication_description', 'original_description',
+ 'pre_publication_abbreviation', 'post_publication_abbreviation',
+ 'lab_code', 'submitter', 'owner', 'authorized_users',
+ 'authors','title','abstract', 'journal','volume','pages','month',
+ 'year','sequence', 'units', 'comments']
+ self.type = 'Publish' \ No newline at end of file
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index fd03f359..e2bafb3a 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -49,65 +49,6 @@ class DoSearch(object):
return cls.search_types[search_type]
-class ProbeSetSearch(DoSearch):
- """A search within an mRNA expression dataset"""
-
- DoSearch.search_types['ProbeSet'] = "ProbeSetSearch"
-
- base_query = """SELECT ProbeSet.Name as TNAME,
- 0 as thistable,
- ProbeSetXRef.Mean as TMEAN,
- ProbeSetXRef.LRS as TLRS,
- ProbeSetXRef.PVALUE as TPVALUE,
- ProbeSet.Chr_num as TCHR_NUM,
- ProbeSet.Mb as TMB,
- ProbeSet.Symbol as TSYMBOL,
- ProbeSet.name_num as TNAME_NUM
- FROM ProbeSetXRef, ProbeSet """
-
-
- def compile_final_query(self, from_clause = '', where_clause = ''):
- """Generates the final query string"""
-
- from_clause = ''
- from_clause = self.normalize_spaces(from_clause)
-
- query = (self.base_query +
- """%s
- WHERE %s
- and ProbeSet.Id = ProbeSetXRef.ProbeSetId
- and ProbeSetXRef.ProbeSetFreezeId = %s
- """ % (self.escape(from_clause),
- where_clause,
- self.escape(self.dataset.id)))
-
- print("query is:", pf(query))
-
- return query
-
- def run(self):
- """Generates and runs a simple search of an mRNA expression dataset"""
-
- print("Running ProbeSetSearch")
- query = (self.base_query +
- """WHERE (MATCH (ProbeSet.Name,
- ProbeSet.description,
- ProbeSet.symbol,
- alias,
- GenbankId,
- UniGeneId,
- Probe_Target_Description)
- AGAINST ('%s' IN BOOLEAN MODE))
- and ProbeSet.Id = ProbeSetXRef.ProbeSetId
- and ProbeSetXRef.ProbeSetFreezeId = %s
- """ % (self.escape(self.search_term),
- self.escape(self.dataset.id)))
-
- print("final query is:", pf(query))
-
- return self.execute(query)
-
-
class PhenotypeSearch(DoSearch):
"""A search within a phenotype dataset"""
@@ -212,6 +153,65 @@ class GenotypeSearch(DoSearch):
return self.execute(query)
+
+class ProbeSetSearch(DoSearch):
+ """A search within an mRNA expression dataset"""
+
+ DoSearch.search_types['ProbeSet'] = "ProbeSetSearch"
+
+ base_query = """SELECT ProbeSet.Name as TNAME,
+ 0 as thistable,
+ ProbeSetXRef.Mean as TMEAN,
+ ProbeSetXRef.LRS as TLRS,
+ ProbeSetXRef.PVALUE as TPVALUE,
+ ProbeSet.Chr_num as TCHR_NUM,
+ ProbeSet.Mb as TMB,
+ ProbeSet.Symbol as TSYMBOL,
+ ProbeSet.name_num as TNAME_NUM
+ FROM ProbeSetXRef, ProbeSet """
+
+
+ def compile_final_query(self, from_clause, where_clause):
+ """Generates the final query string"""
+
+ from_clause = self.normalize_spaces(from_clause)
+
+ query = (self.normalize_spaces(self.base_query) +
+ """%s
+ WHERE %s
+ and ProbeSet.Id = ProbeSetXRef.ProbeSetId
+ and ProbeSetXRef.ProbeSetFreezeId = %s
+ """ % (self.escape(from_clause),
+ where_clause,
+ self.escape(self.dataset.id)))
+
+ print("query is:", pf(query))
+
+ return query
+
+ def run(self):
+ """Generates and runs a simple search of an mRNA expression dataset"""
+
+ print("Running ProbeSetSearch")
+ query = (self.base_query +
+ """WHERE (MATCH (ProbeSet.Name,
+ ProbeSet.description,
+ ProbeSet.symbol,
+ alias,
+ GenbankId,
+ UniGeneId,
+ Probe_Target_Description)
+ AGAINST ('%s' IN BOOLEAN MODE))
+ and ProbeSet.Id = ProbeSetXRef.ProbeSetId
+ and ProbeSetXRef.ProbeSetFreezeId = %s
+ """ % (self.escape(self.search_term),
+ self.escape(self.dataset.id)))
+
+ print("final query is:", pf(query))
+
+ return self.execute(query)
+
+
class RifSearch(ProbeSetSearch):
"""Searches for traits with a Gene RIF entry including the search term."""
@@ -283,7 +283,7 @@ class LrsSearch(ProbeSetSearch):
DoSearch.search_types['LRS'] = 'LrsSearch'
-class CisLrsSearch(LrsSearch):
+class CisLrsSearch(ProbeSetSearch):
"""Searches for genes on a particular chromosome with a cis-eQTL within the given LRS values
A cisLRS search can take 2 forms:
@@ -305,9 +305,12 @@ class CisLrsSearch(LrsSearch):
DoSearch.search_types['CISLRS'] = "CisLrsSearch"
def run(self):
+
+ from_clause = ", Geno "
+
if len(self.search_term) == 3:
lower_limit, upper_limit, min_threshold = [int(value) for value in self.search_term]
-
+
where_clause = """ %sXRef.LRS > %s and
%sXRef.LRS < %s and
%sXRef.Locus = Geno.name and
@@ -327,7 +330,7 @@ class CisLrsSearch(LrsSearch):
else:
NeedSomeErrorHere
- query = self.compile_final_query(where_clause)
+ query = self.compile_final_query(from_clause, where_clause)
return self.execute(query)
@@ -353,6 +356,8 @@ class TransLrsSearch(LrsSearch):
DoSearch.search_types['TRANSLRS'] = "TransLrsSearch"
def run(self):
+ from_clause = ", Geno "
+
if len(self.search_term) == 3:
lower_limit, upper_limit, min_threshold = [int(value) for value in self.search_term]
@@ -374,9 +379,11 @@ class TransLrsSearch(LrsSearch):
)
else:
- NeedSomeErrorHere
+ NeedSomeErrorHere
- return None
+ query = self.compile_final_query(from_clause, where_clause)
+
+ return self.execute(query)
#itemCmd = item[0]
@@ -447,7 +454,7 @@ if __name__ == "__main__":
#results = ProbeSetSearch("salt", dataset, cursor, db_conn).run()
#results = RifSearch("diabetes", dataset, cursor, db_conn).run()
#results = WikiSearch("nicotine", dataset, cursor, db_conn).run()
- results = CisLrsSearch(['9','99','10'], dataset, cursor, db_conn).run()
+ results = TransLrsSearch(['25','99','10'], dataset, cursor, db_conn).run()
#results = TransLrsSearch(['9', '999', '10'], dataset, cursor, db_conn).run()
#results = PhenotypeSearch("brain", dataset, cursor, db_conn).run()
#results = GenotypeSearch("rs13475699", dataset, cursor, db_conn).run()
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index dc3c72fc..05f062fc 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -84,16 +84,7 @@ class SearchResultPage(templatePage):
print("self.dataset is:", pf(self.dataset))
self.dataset = webqtlDataset(self.dataset, self.cursor)
print("self.dataset is now:", pf(self.dataset))
- #self.dataset = map(lambda x: webqtlDataset(x, self.cursor), self.dataset)
- #currently, webqtl won't allow multiple crosses
- #for other than multiple publish db search
- #so we can use the first dataset as example
- #if self.dataset.type=="Publish":
- # pass
if self.dataset.type in ("Geno", "ProbeSet"):
-
- #userExist = None
- # Can't use paramater substitution for table names apparently
db_type = self.dataset.type + "Freeze"
print("db_type [%s]: %s" % (type(db_type), db_type))
@@ -124,11 +115,8 @@ class SearchResultPage(templatePage):
# access_to_confidential_dataset = 1
#
#if not access_to_confidential_dataset:
- # #Error, No dataset selected
- # heading = "Search Result"
- # detail = ["The %s dataset you selected is not open to the public at this time, please go back and SELECT other dataset." % indFullName]
- # self.error(heading=heading,detail=detail,error="Confidential dataset")
- # return
+ # Some error
+
#else:
# heading = "Search Result"
# detail = ['''The dataset has not been established yet, please
@@ -180,7 +168,8 @@ class SearchResultPage(templatePage):
'Max LRS',
'Max LRS Location']
elif self.dataset.type == "Geno":
- self.search_fields = ['Name','Chr']
+ self.search_fields = ['Name',
+ 'Chr']
self.header_fields = ['',
'ID',
'Location']
@@ -241,7 +230,6 @@ class SearchResultPage(templatePage):
# This is throwing an error when a_search['key'] is None, so I changed above
#search_type = string.upper(a_search['key'])
#if not search_type:
- # # We fall back to the dataset type as the key to get the right object
# search_type = self.dataset.type
search_ob = do_search.DoSearch.get_search(search_type)
@@ -273,7 +261,6 @@ class SearchResultPage(templatePage):
def getTraitInfoForGeno(self, trait_list):
-
for this_trait in trait_list:
if not this_trait.haveinfo:
this_trait.retrieveInfo()
@@ -295,8 +282,7 @@ class SearchResultPage(templatePage):
this_trait.location_value = trait_location_value
- def getTraitInfoForPublish(self, trait_list, species=''):
-
+ def getTraitInfoForPublish(self, trait_list, species = ''):
for this_trait in trait_list:
if not this_trait.haveinfo:
this_trait.retrieveInfo(QTL=1)
@@ -307,18 +293,16 @@ class SearchResultPage(templatePage):
description = this_trait.pre_publication_description
this_trait.description_display = description
- try:
- this_trait.pubmed_text = int(this_trait.year)
- except:
+ if not this_trait.year.isdigit():
this_trait.pubmed_text = "N/A"
if this_trait.pubmed_id:
this_trait.pubmed_link = webqtlConfig.PUBMEDLINK_URL % this_trait.pubmed_id
#LRS and its location
- this_trait.LRS_score_repr = 'N/A'
+ this_trait.LRS_score_repr = "N/A"
this_trait.LRS_score_value = 0
- this_trait.LRS_location_repr = 'N/A'
+ this_trait.LRS_location_repr = "N/A"
this_trait.LRS_location_value = 1000000
if this_trait.lrs:
@@ -408,7 +392,7 @@ class SearchResultPage(templatePage):
ProbeSet.Name = '%s'
""" % (self.db_conn.escape_string(str(this_trait.db.id)),
self.db_conn.escape_string(this_trait.name)))
-
+
print("query is:", pf(query))
self.cursor.execute(query)
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 19e67c43..3dac5933 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -1509,10 +1509,10 @@ class ShowTrait(templatePage):
def make_sample_lists(self, fd, variance_data_page, this_trait):
- if fd.genotype.type == "riset":
- all_samples_ordered = fd.f1list + fd.samplelist
- else:
+ if fd.parlist:
all_samples_ordered = fd.parlist + fd.f1list + fd.samplelist
+ else:
+ all_samples_ordered = fd.f1list + fd.samplelist
this_trait_samples = set(this_trait.data.keys())
@@ -1527,8 +1527,6 @@ class ShowTrait(templatePage):
this_trait=this_trait,
sample_group_type='primary',
header="%s Only" % (fd.RISet))
-
- print("primary_samples.attributes:", pf(primary_samples.attributes))
other_sample_names = []
for sample in this_trait.data.keys():
@@ -1538,8 +1536,7 @@ class ShowTrait(templatePage):
other_sample_names.append(sample)
if other_sample_names:
- unappended_par_f1 = fd.f1list + fd.parlist
- par_f1_samples = ["_2nd_" + sample for sample in unappended_par_f1]
+ par_f1_samples = fd.parlist + fd.f1list
other_sample_names.sort() #Sort other samples
other_sample_names = par_f1_samples + other_sample_names