aboutsummaryrefslogtreecommitdiff
path: root/web/webqtl/externalResource
diff options
context:
space:
mode:
authorroot2012-05-08 18:39:56 -0500
committerroot2012-05-08 18:39:56 -0500
commitea46f42ee640928b92947bfb204c41a482d80937 (patch)
tree9b27a4eb852d12539b543c3efee9d2a47ef470f3 /web/webqtl/externalResource
parent056b5253fc3857b0444382aa39944f6344dc1ceb (diff)
downloadgenenetwork2-ea46f42ee640928b92947bfb204c41a482d80937.tar.gz
Add all the source codes into the github.
Diffstat (limited to 'web/webqtl/externalResource')
-rwxr-xr-xweb/webqtl/externalResource/GCATPage.py101
-rwxr-xr-xweb/webqtl/externalResource/GoTreePage.py154
-rwxr-xr-xweb/webqtl/externalResource/ODEPage.py143
-rwxr-xr-xweb/webqtl/externalResource/__init__.py0
4 files changed, 398 insertions, 0 deletions
diff --git a/web/webqtl/externalResource/GCATPage.py b/web/webqtl/externalResource/GCATPage.py
new file mode 100755
index 00000000..7e22f168
--- /dev/null
+++ b/web/webqtl/externalResource/GCATPage.py
@@ -0,0 +1,101 @@
+# Copyright (C) University of Tennessee Health Science Center, Memphis, TN.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# This program is available from Source Forge: at GeneNetwork Project
+# (sourceforge.net/projects/genenetwork/).
+#
+# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
+# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
+#
+#
+#
+# This module is used by GeneNetwork project (www.genenetwork.org)
+#
+# Created by GeneNetwork Core Team 2010/08/10
+#
+# Last updated by GeneNetwork Core Team 2010/10/20
+
+#GCATPage.py
+
+from htmlgen import HTMLgen2 as HT
+
+from base.webqtlTrait import webqtlTrait
+from base.templatePage import templatePage
+
+
+#Implemented by Xiaodong
+class GCATPage(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]
+
+ 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 = 'GCAT'
+ detail = ['You need to select at least one microarray trait to submit to GCAT.']
+ self.error(heading=heading,detail=detail)
+ return
+
+ geneSymbolList = self.getGeneSymbolList()
+
+ geneSymbolSet = set(geneSymbolList)
+
+ if ( len(geneSymbolSet) < 500 ):
+ temp = '+'.join(geneSymbolSet)
+ GCATurl = "http://binf1.memphis.edu/gcat/?organism=mouse&subset=all&year=2010&geneInput=%s" % temp
+
+ self.dict['js1'] = """
+ <SCRIPT LANGUAGE="JavaScript">
+ setTimeout( 'window.location = "%s"', 2000 );
+ </SCRIPT>
+ """ % GCATurl
+
+ TD_LR.append(HT.Paragraph("Your selection of %d genes is being submitted to GCAT" % len(geneSymbolSet), Class="cr fs16 fwb", align="Center"))
+ else:
+ TD_LR.append(HT.Paragraph("Your selection of %d genes exceeds the limit of 500. Please reduce your gene number to below the limit." % len(geneSymbolSet), Class="cr fs16 fwb", align="Center"))
+
+
+ self.dict['body'] = TD_LR
+
+
+ def getGeneSymbolList(self):
+ geneList = []
+
+ for item in self.theseTraits:
+ item.retrieveInfo()
+ geneList.append(str(item.symbol))
+
+ return geneList
+
+
diff --git a/web/webqtl/externalResource/GoTreePage.py b/web/webqtl/externalResource/GoTreePage.py
new file mode 100755
index 00000000..07144a23
--- /dev/null
+++ b/web/webqtl/externalResource/GoTreePage.py
@@ -0,0 +1,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
+
diff --git a/web/webqtl/externalResource/ODEPage.py b/web/webqtl/externalResource/ODEPage.py
new file mode 100755
index 00000000..f02fe5aa
--- /dev/null
+++ b/web/webqtl/externalResource/ODEPage.py
@@ -0,0 +1,143 @@
+# Copyright (C) University of Tennessee Health Science Center, Memphis, TN.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# This program is available from Source Forge: at GeneNetwork Project
+# (sourceforge.net/projects/genenetwork/).
+#
+# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
+# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
+#
+#
+#
+# This module is used by GeneNetwork project (www.genenetwork.org)
+#
+# Created by GeneNetwork Core Team 2010/08/10
+#
+# Last updated by GeneNetwork Core Team 2010/10/20
+
+#ODEPage.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
+
+class ODEPage(templatePage):
+
+ def __init__(self,fd):
+
+ templatePage.__init__(self, fd)
+
+ if not self.openMysql():
+ return
+
+ #XZ, self.theseTraits holds the "ProbeSet" traits.
+ self.theseTraits = []
+
+ self.searchResult = fd.formdata.getvalue('searchResult', [])
+ if type("1") == type(self.searchResult):
+ self.searchResult = [self.searchResult]
+
+ 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:
+ heading = 'ODE'
+ detail = ['You need to select at least one microarray trait to submit.']
+ self.error(heading=heading,detail=detail)
+ return
+
+ chipName = self.getChipName(fd)
+ species = webqtlDatabaseFunction.retrieveSpecies(cursor=self.cursor, RISet=fd.RISet)
+
+ if species == 'rat':
+ species = 'Rattus norvegicus'
+ elif species == 'human':
+ species = 'Homo sapiens'
+ elif species == 'mouse':
+ species = 'Mus musculus'
+ else:
+ species = ''
+
+ probesetNameList = self.getProbesetNameList(fd)
+
+ TD_LR = HT.TD(height=200,width="100%",bgColor='#eeeeee',valign="middle")
+
+ formODE = HT.Form(cgi="http://ontologicaldiscovery.org/index.php?action=manage&cmd=importGeneSet", enctype='multipart/form-data', name='formODE', submit = HT.Input(type='hidden'))
+
+ hddnODE = {}
+
+ hddnODE['client'] = 'genenetwork'
+ hddnODE['species'] = species
+ hddnODE['idtype'] = chipName
+ hddnODE['list'] = string.join(probesetNameList, ",")
+
+ for key in hddnODE.keys():
+ formODE.append(HT.Input(name=key, value=hddnODE[key], type='hidden'))
+
+ TD_LR.append(formODE)
+
+ TD_LR.append(HT.Paragraph("Your selections of %d traits is being exported to the ODE" % len(self.theseTraits), Class="cr fs16 fwb", align="Center"))
+ # updated by NL, moved mixedChipError() to webqtl.js and change it to mixedChipError(methodName)
+ if chipName == 'mixed':
+ methodName = "ODE"
+ self.dict['js1'] = """
+ <SCRIPT LANGUAGE="JavaScript">
+ setTimeout("mixedChipError('%s')",1000);
+ </SCRIPT>
+ """ % methodName
+ else:
+ self.dict['js1'] = """
+ <SCRIPT LANGUAGE="JavaScript">
+ setTimeout('document.formODE.submit()',1000);
+ </SCRIPT>
+ """
+
+ self.dict['body'] = TD_LR
+
+
+
+ def getProbesetNameList(self, fd):
+ probesetNameList = []
+
+ for item in self.theseTraits:
+ probesetNameList.append(item.name)
+
+ return probesetNameList
+
+
+
+ def getChipName(self, fd):
+ chipName0 = ""
+ for item in self.theseTraits:
+ 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)
+ chipName = self.cursor.fetchone()[0]
+ if chipName != chipName0:
+ if chipName0:
+ return 'mixed'
+ else:
+ chipName0 = chipName
+ else:
+ pass
+
+ return chipName
diff --git a/web/webqtl/externalResource/__init__.py b/web/webqtl/externalResource/__init__.py
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/web/webqtl/externalResource/__init__.py