-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.cgi
More file actions
157 lines (131 loc) · 5.95 KB
/
array.cgi
File metadata and controls
157 lines (131 loc) · 5.95 KB
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
#!/usr/bin/python
"""
Microarray Analysis cgi script
BY Xiaoji Sun
"""
##################################################################################################
# import modules and functions
import cgi
from array_functions import database_query
# this helps to display errors to the screen when submitting the web form.
import cgitb
cgitb.enable()
##################################################################################################
# construct the variables
title = 'Hochwagen Lab Microarray Analysis'
form = cgi.FieldStorage()
message = ''
##################################################################################################
# content added into the body
# the program only runs when inputs are provided
# dropdown menu for the database search
if form.getvalue('dropdown'):
if form.getvalue('dropdown') == 'strain':
"""
If the user queries for a specific strain number, it returns a list of all the experiments
on that strain.
"""
# gets the input from the web form
strain = form.getvalue('input')
# if submit without entering anything, print error message
if strain == None:
message += 'STRAIN NUMBER CAN NOT BE EMPTY, PLEASE ENTER ONE!'
else:
# runs the query
output = database_query(strain=strain)
# if strain not found, print error message
if output == []:
message += 'THE STRAIN YOU ENTERED IS NOT FOUND, PLEASE TRY ANOTHER ONE!'
else:
message += '<font color=\"blue\">Here are the experiments found done on strain '
message += strain
message += ':</font>'
message += '<BR>\n'
message += '<BR>\n'
message += '<table border=2">'
message += '<tr><td><b>Record ID</b></td><td><b>Experiment Folder</b></td><td><b>Array</b></td><td><b>Strain</b></td><td><b>Experiment</b></td><td><b>Replicate</b></td><td><b>Spot File</b></td><td><b>Description</b></td></tr>'
for line in output:
message += '<tr><td>'
message += '</td><td>'.join([i for i in line])
message += '</tr>'
message += '</table>'
if form.getvalue('dropdown') == 'keyword':
"""
If the user queries for a keyword, it returns a list of all the experiments that have this keyword in
Experiment column.
"""
# gets the input from the web form
keyword = form.getvalue('input')
# if submit without entering anything, print error message
if keyword == None:
message += 'KEYWORD CAN NOT BE EMPTY, PLEASE ENTER ONE!'
else:
# runs the query
output = database_query(keyword=keyword)
# if keyword not found, print error message
if output == []:
message += 'THE KEYWORD YOU ENTERED IS NOT FOUND, PLEASE TRY ANOTHER ONE!'
else:
message += '<font color=\"blue\">Here are the experiments found containing keyword '
message += keyword
message += ':</font>'
message += '<BR>\n'
message += '<BR>\n'
message += '<table border=2">'
message += '<tr><td><b>Record ID</b></td><td><b>Experiment Folder</b></td><td><b>Array</b></td><td><b>Strain</b></td><td><b>Experiment</b></td><td><b>Replicate</b></td><td><b>Spot File</b></td><td><b>Description</b></td></tr>'
for line in output:
message += '<tr><td>'
message += '</td><td>'.join([i for i in line])
message += '</tr>'
message += '</table>'
##################################################################################################
# basic construction
text = 'Content-type: text/html\n\n'
text += '<html>\n'
text += '<head>\n'
text += '<style type=\"text/css\"> #button {background-color:#eeeeee;border-top:2px solid #dbdbdb;border-right:2px solid #dbdbdb;border-bottom:4px solid #dbdbdb;border-left:2px solid #ccc8cc;padding:5px;color: #666;font-size:16px;font-weight:bold;cursor:hand;}</style>'
text += '<title>' + title + '</title>\n'
text += '</head>\n'
text += '<body>\n'
text += '<h1>MICROARRAY DATABASE OF HOCHWAGEN LAB</h1>\n'
text += '<BR>\n'
text += '<h3><font color=\"red\">PLEASE ENTER A STRAIN NUMBER OR A KEYWORD TO START YOUR SEARCH:</font></h3>\n'
text += '1. Strain numbers are from FileMaker database.'
text += '<BR>\n'
text += '2. Keyword can be any word describing the experiment.'
text += '<BR>\n'
text += '3. Experiments in this database can be viewed using PLOT VIEWER.</b>'
text += '<BR>\n'
text += '<BR>\n'
##################################################################################################
# content added into the body to create the web form
# basic form
text += '<FORM ACTION=\"array.cgi\", METHOD=\"GET\">\n'
text += '<SELECT NAME=\"dropdown\">\n'
text += '<OPTION VALUE=\"strain\" SELECTED>STRAIN</OPTION>\n'
text += '<OPTION VALUE=\"keyword\">KEYWORD</OPTION>\n'
text += '</SELECT>\n'
text += '<INPUT TYPE=\"TEXT\" name=\"input\">\n'
text += '<BR>\n'
text += '<BR>\n'
text += '<INPUT id=\"button\" TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Search!\">\n'
text += '</FORM>\n'
text += '<BR>\n'
text += '<HR>\n'
text += '<BR>\n'
text += '<a href=\"http://hochwagen-lab3.bio.nyu.edu/cgi-bin/array_plot.cgi\"><b><font color=\"red\">GO TO PLOT VIEWER!</font></b></a>'
text += '<BR>\n'
text += '<BR>\n'
##################################################################################################
# content added into the body to display the results
text += message
# close the body etc.
text += '<br><br><br>'
text += '<hr>'
text += 'Last update: 8/22/2013'
text += '<br>'
text += 'questions or suggestions to: xs338@nyu.edu'
text += '</body>\n'
text += '</html>'
# display the form or blast results
print text