aboutsummaryrefslogtreecommitdiff
path: root/web/webqtl/cmdLine/webqtlCmdLine.py
blob: ebc10e1c1856edce4c85049cf689bf14825f7a6e (about) (plain)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# 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



########################################################
#XZ, Aug 10, 2010
#This part is the temporary solution to make python be able to find other subpackages.
#We can't set global environment because there are many branches on the development machine.

import sys, os

current_file_name = __file__
pathname = os.path.dirname( current_file_name )
abs_path = os.path.abspath(pathname)
sys.path.insert(0, abs_path + '/..')

########################################################



import traceback
import string
import cPickle

from base import webqtlConfig
from base.templatePage import templatePage
from utility import webqtlUtil


if __name__ == "__main__":
	try:
		if len(sys.argv) > 2:
			getID = string.lower(sys.argv[1])
		else:
			raise ValueError
	
		cmdtype = sys.argv[1]
		sessionfile =  sys.argv[2]

		fd = None
		
		fp = open(os.path.join(webqtlConfig.TMPDIR, sessionfile + '.session'), 'rb')
		fd = cPickle.load(fp)
		fp.close()

		if cmdtype == "heatmap":
			from heatmap import heatmapPage
			reload(heatmapPage)
			page = heatmapPage.heatmapPage(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "directplot":
			from pairScan import DirectPlotPage
			reload(DirectPlotPage)
			page = DirectPlotPage.DirectPlotPage(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "networkGraph":
			from networkGraph import networkGraphPage
			reload(networkGraphPage)
			page = networkGraphPage.networkGraphPage(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "interval":
			from intervalMapping import IntervalMappingPage
			reload(IntervalMappingPage)
			page = IntervalMappingPage.IntervalMappingPage(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "correlation":
			from correlation import CorrelationPage
			reload (CorrelationPage)
			page = CorrelationPage.CorrelationPage(fd)
			page.writeFile(sessionfile+'.html')
                elif cmdtype == "partialCorrelation":
                        from correlation import PartialCorrDBPage
			reload(PartialCorrDBPage)
                        page = PartialCorrDBPage.PartialCorrDBPage(fd)
                        page.writeFile(sessionfile+'.html')
		elif cmdtype == "correlationComparison":
			from compareCorrelates import multitrait
			reload(multitrait)
			page = multitrait.compCorrPage(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "genreport": # Generate Report Page
			spacer = '</TR></Table><Table width=900 cellSpacing=0 cellPadding=5><TR>'

			from basicStatistics import BasicStatisticsPage
			reload(BasicStatisticsPage)
			page1 = BasicStatisticsPage.BasicStatisticsPage(fd)

			if not fd.formdata.getvalue('bsCheck'):
				page1.dict['body'] = ""

			if fd.formdata.getvalue('tcCheck'):
				from correlation import CorrelationPage
				reload(CorrelationPage)
				page2 = CorrelationPage.CorrelationPage(fd)
				page1.dict['body'] += spacer + str(page2.dict['body'])
				page1.dict['js1'] +=  page2.dict['js1']

			if fd.formdata.getvalue('imCheck'):
				from intervalMapping import IntervalMappingPage
				reload(IntervalMappingPage)
				page3 = IntervalMappingPage.IntervalMappingPage(fd)
				page1.dict['body'] += spacer + str(page3.dict['body'])

			if fd.formdata.getvalue('mrCheck'):
				from markerRegression import MarkerRegressionPage
				reload(MarkerRegressionPage)
				page4 = MarkerRegressionPage.MarkerRegressionPage(fd)
				page1.dict['body'] += spacer + str(page4.dict['body'])

			if fd.formdata.getvalue('psCheck'):
				from pairScan import DirectPlotPage
				reload(DirectPlotPage)
				page5 = DirectPlotPage.DirectPlotPage(fd)
				page1.dict['body'] += spacer + str(page5.dict['body'])
									 
			page1.writeFile(sessionfile+'.html')
			
		elif cmdtype == "genreport2": # Generate Report Page v2
			spacer = '</TR></Table><Table width=900 cellSpacing=0 cellPadding=5><TR>'

			from basicStatistics import BasicStatisticsPage_alpha
			reload(BasicStatisticsPage_alpha)
			page1 = BasicStatisticsPage_alpha.BasicStatisticsPage_alpha(fd)
			page1.writeFile(sessionfile+'.html')
		elif cmdtype == "snpbrowser":
			from snpBrowser import snpBrowserPage
			reload(snpBrowserPage)
			page = snpBrowserPage.snpBrowserPage(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "QTLminer":
			from qtlminer import QTLminer
			reload(QTLminer)
			page = QTLminer.QTLminer(fd)
			page.writeFile(sessionfile+'.html')
		elif cmdtype == "tissueCorrelation":
			from correlationMatrix import TissueCorrelationPage
			reload(TissueCorrelationPage)
			page = TissueCorrelationPage.TissueCorrelationPage(fd)
			page.writeFile(sessionfile+'.html')	
		elif cmdtype == "markerRegression":
			from markerRegression import MarkerRegressionPage
			reload(MarkerRegressionPage)
			page = MarkerRegressionPage.MarkerRegressionPage(fd)
			page.writeFile(sessionfile+'.html')				
		else:
			raise ValueError
	except:
		fp = open(os.path.join(webqtlConfig.TMPDIR, sessionfile +'.html'), 'wb')
		fp.write('\n\n<pre>')
		traceback.print_exc(file=fp)							
		fp.write('\n</pre>')
		fp.close()