1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#GoTreePage.py
import string
from htmlgen import HTMLgen2 as HT
from base import webqtlConfig
from base.webqtlTrait import webqtlTrait
from base.templatePage import templatePage
from dbFunction import webqtlDatabaseFunction
#########################################
# GoTree Page
#########################################
class GoTreePage(templatePage):
def __init__(self,fd):
self.theseTraits = []
TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee',valign="middle")
templatePage.__init__(self, fd)
if not self.openMysql():
return
self.searchResult = fd.formdata.getvalue('searchResult', [])
if type("1") == type(self.searchResult):
self.searchResult = [self.searchResult]
#XZ, self.theseTraits holds the "ProbeSet" traits.
for item in self.searchResult:
try:
thisTrait = webqtlTrait(fullname=item, cursor=self.cursor)
thisTrait.retrieveInfo(QTL=1)
if thisTrait.db.type == "ProbeSet":
self.theseTraits.append(thisTrait)
except:
pass
if self.theseTraits:
pass
else:
templatePage.__init__(self, fd)
heading = 'WebGestalt'
detail = ['You need to select at least one microarray trait to submit.']
self.error(heading=heading,detail=detail)
return
chipName = self.testChip(fd)
#XZ, 8/24/2009: the name of arraylist is misleading. It holds the name of traits.
arraylist, geneIdList = self.genGeneIdList(fd)
target_url = "http://bioinfo.vanderbilt.edu/webgestalt/webgestalt.php"
formWebGestalt = HT.Form(cgi=target_url, enctype='multipart/form-data', name='WebGestalt', submit = HT.Input(type='hidden'))
id_type = chipName
hddnWebGestalt = {'id_list':string.join(arraylist, ","),
'id_type':id_type}
hddnWebGestalt['ref_type'] = hddnWebGestalt['id_type']
hddnWebGestalt['analysis_type'] = 'GO'
hddnWebGestalt['significancelevel'] = 'Top10'
hddnWebGestalt['stat'] = 'Hypergeometric'
hddnWebGestalt['mtc'] = 'BH'
hddnWebGestalt['min'] = '2'
hddnWebGestalt['id_value'] = fd.formdata.getvalue('correlation')
species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet)
if species == 'rat':
hddnWebGestalt['org'] = 'Rattus norvegicus'
elif species == 'human':
hddnWebGestalt['org'] = 'Homo sapiens'
elif species == 'mouse':
hddnWebGestalt['org'] = 'Mus musculus'
else:
hddnWebGestalt['org'] = ''
hddnWebGestalt['org'] = hddnWebGestalt['org'].replace(' ','_')
for key in hddnWebGestalt.keys():
formWebGestalt.append(HT.Input(name=key, value=hddnWebGestalt[key], type='hidden'))
TD_LR.append(formWebGestalt)
TD_LR.append(HT.Paragraph("Your selection of %d traits is being submitted to GO Tree" % len(self.theseTraits), Class="cr fs16 fwb", align="Center"))
# updated by NL, moved mixedChipError() to webqtl.js and change it to mixedChipError(methodName)
# moved unknownChipError() to webqtl.js and change it to unknownChipError(chipName)
if chipName == 'mixed':
methodName = "WebGestalt"
self.dict['js1'] = """
<SCRIPT LANGUAGE="JavaScript">
setTimeout("mixedChipError('%s')" ,1000);
</SCRIPT>
""" % methodName
elif chipName.find('_NA') > 0:
chipName = chipName[0:-3]
self.dict['js1'] = """
<SCRIPT LANGUAGE="JavaScript">
setTimeout("unknownChipError('%s')",1000);
</SCRIPT>
""" % chipName
else:
self.dict['js1'] = """
<SCRIPT LANGUAGE="JavaScript">
setTimeout('document.WebGestalt.submit()',1000);
</SCRIPT>
"""
self.dict['body'] = TD_LR
def testChip(self, fd):
chipName0 = ""
for item in self.theseTraits:
self.cursor.execute('SELECT GeneChip.GO_tree_value FROM GeneChip, ProbeFreeze, ProbeSetFreeze WHERE GeneChip.Id = ProbeFreeze.ChipId and ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeSetFreeze.Name = "%s"' % item.db.name)
result = self.cursor.fetchone()
if result:
chipName = result[0]
if chipName:
if chipName != chipName0:
if chipName0:
return 'mixed'
else:
chipName0 = chipName
else:
pass
else:
self.cursor.execute('SELECT GeneChip.Name FROM GeneChip, ProbeFreeze, ProbeSetFreeze WHERE GeneChip.Id = ProbeFreeze.ChipId and ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeSetFreeze.Name = "%s"' % item.db.name)
result = self.cursor.fetchone()
chipName = '%s_NA' % result[0]
return chipName
else:
self.cursor.execute('SELECT GeneChip.Name FROM GeneChip, ProbeFreeze, ProbeSetFreeze WHERE GeneChip.Id = ProbeFreeze.ChipId and ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and ProbeSetFreeze.Name = "%s"' % item.db.name)
result = self.cursor.fetchone()
chipName = '%s_NA' % result[0]
return chipName
return chipName
def genGeneIdList(self, fd):
arrayList = []
geneList = []
for item in self.theseTraits:
arrayList.append(item.name)
item.retrieveInfo()
geneList.append(str(item.geneid))
return arrayList, geneList
|