-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforms.py
336 lines (266 loc) · 15.7 KB
/
forms.py
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 23 04:24:44 2022
@author: hill103
this script defines forms used in search and browse page
"""
from preprocess import organism_list
from flask_wtf import FlaskForm
from wtforms import SelectField, SubmitField, RadioField, StringField, BooleanField, TextAreaField
from wtforms.validators import InputRequired
# flask_wtf.file.FileField (https://flask-wtf.readthedocs.io/en/1.0.x/form/#file-uploads) differs from wtforms.fields.FileField(https://wtforms.readthedocs.io/en/3.0.x/fields/#wtforms.fields.FileField)
# flask Uploading Files instructions https://flask.palletsprojects.com/en/2.2.x/patterns/fileuploads/
# Dropzone can handles the file upload process itself, so no need to set up a Flask-WTF form specifically for file uploads
# from flask_wtf.file import FileField, FileRequired
# remember the principle called “never trust user input”, always use this function to secure a filename before storing it directly on the filesystem
# from werkzeug.utils import secure_filename
class form_browse_tRF(FlaskForm):
'''forms used in Browse by tRF page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# multiple checkbox for tRF type
trf_1 = BooleanField("tRF-1 / tsRNA", default=True, false_values=('False', 'false', ''))
trf_3 = BooleanField("tRF-3", default=True, false_values=('False', 'false', ''))
trf_5 = BooleanField("tRF-5", default=True, false_values=('False', 'false', ''))
trf_5u = BooleanField("5'U tRF", default=True, false_values=('False', 'false', ''))
trf_i = BooleanField("i-tRF", default=True, false_values=('False', 'false', ''))
trf_5half = BooleanField("5' tRH / tiR", default=True, false_values=('False', 'false', ''))
trf_3half = BooleanField("3' tRH / tiR", default=True, false_values=('False', 'false', ''))
# multiple checkbox for tRF source
trfdb = BooleanField("tRFdb", default=True, false_values=('False', 'false', ''))
tsrna = BooleanField("tsRNA study", default=True, false_values=('False', 'false', ''))
tsrfun = BooleanField("tsRFun", default=True, false_values=('False', 'false', ''))
tsrbase = BooleanField("tsRBase", default=True, false_values=('False', 'false', ''))
tatdb = BooleanField("tatDB", default=True, false_values=('False', 'false', ''))
mintbase = BooleanField("MINTbase v2.0", default=True, false_values=('False', 'false', ''))
trfexp = BooleanField("tRFexplorer", default=True, false_values=('False', 'false', ''))
oncotrf = BooleanField("OncotRF", default=True, false_values=('False', 'false', ''))
# a button to submit request
submit = SubmitField('Browse')
class form_browse_RNA(FlaskForm):
'''forms used in Browse by RNA page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# multiple checkbox for RNA type
protein_rna = BooleanField("protein_coding", default=True, false_values=('False', 'false', ''))
r_rna = BooleanField("rRNA", default=True, false_values=('False', 'false', ''))
lnc_rna = BooleanField("lncRNA", default=True, false_values=('False', 'false', ''))
# a button to submit request
submit = SubmitField('Browse')
class form_browse_Gene(FlaskForm):
'''forms used in Browse by Gene page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# a button to submit request
submit = SubmitField('Browse')
class form_search_tRF(FlaskForm):
'''forms used in Search by tRF page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# a radio form for prediction tool
search_tool = RadioField('Prediction Tools',
choices=[('RNAhybrid', 'RNAhybrid'),
('IntaRNA', 'IntaRNA'),
('Consensus', 'Consensus Only')],
validators=[InputRequired()],
default='Consensus')
# a text form for RNA ID
# empty checking already conducted in front-end, BTW empty input can also be handled
trf = StringField()
# multiple checkbox for RNA type
protein_rna = BooleanField("protein_coding", default=True, false_values=('False', 'false', ''))
r_rna = BooleanField("rRNA", default=True, false_values=('False', 'false', ''))
lnc_rna = BooleanField("lncRNA", default=True, false_values=('False', 'false', ''))
# multiple checkbox for binding region
utr5 = BooleanField("5' UTR", default=True, false_values=('False', 'false', ''))
cds = BooleanField("CDS", default=True, false_values=('False', 'false', ''))
utr3 = BooleanField("3' UTR", default=True, false_values=('False', 'false', ''))
# a checkbox for whether restrict to binding sites with experimental evidence only
exp_only = BooleanField("Only show binding sites with Experimental Evidence", default=False, false_values=('False', 'false', ''))
# a text form for threshold of free energy
fe_threshold = StringField(default=-10)
# a text form for threshold of MCL
mcl_threshold = StringField(default=6)
# a button to submit request
submit = SubmitField('Search')
class form_search_RNA(FlaskForm):
'''forms used in Search by RNA page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# a radio form for prediction tool
search_tool = RadioField('Prediction Tools',
choices=[('RNAhybrid', 'RNAhybrid'),
('IntaRNA', 'IntaRNA'),
('Consensus', 'Consensus Only')],
validators=[InputRequired()],
default='Consensus')
# a text form for RNA ID
# empty checking already conducted in front-end, BTW empty input can also be handled
transcript = StringField()
# multiple checkbox for tRF type
trf_1 = BooleanField("tRF-1 / tsRNA", default=True, false_values=('False', 'false', ''))
trf_3 = BooleanField("tRF-3", default=True, false_values=('False', 'false', ''))
trf_5 = BooleanField("tRF-5", default=True, false_values=('False', 'false', ''))
trf_5u = BooleanField("5'U tRF", default=True, false_values=('False', 'false', ''))
trf_i = BooleanField("i-tRF", default=True, false_values=('False', 'false', ''))
trf_5half = BooleanField("5' tRH / tiR", default=True, false_values=('False', 'false', ''))
trf_3half = BooleanField("3' tRH / tiR", default=True, false_values=('False', 'false', ''))
# multiple checkbox for tRF source
trfdb = BooleanField("tRFdb", default=True, false_values=('False', 'false', ''))
tsrna = BooleanField("tsRNA study", default=True, false_values=('False', 'false', ''))
tsrfun = BooleanField("tsRFun", default=True, false_values=('False', 'false', ''))
tsrbase = BooleanField("tsRBase", default=True, false_values=('False', 'false', ''))
tatdb = BooleanField("tatDB", default=True, false_values=('False', 'false', ''))
mintbase = BooleanField("MINTbase v2.0", default=True, false_values=('False', 'false', ''))
trfexp = BooleanField("tRFexplorer", default=True, false_values=('False', 'false', ''))
oncotrf = BooleanField("OncotRF", default=True, false_values=('False', 'false', ''))
# multiple checkbox for binding region
utr5 = BooleanField("5' UTR", default=True, false_values=('False', 'false', ''))
cds = BooleanField("CDS", default=True, false_values=('False', 'false', ''))
utr3 = BooleanField("3' UTR", default=True, false_values=('False', 'false', ''))
# a checkbox for whether restrict to binding sites with experimental evidence only
exp_only = BooleanField("Only show binding sites with Experimental Evidence", default=False, false_values=('False', 'false', ''))
# a text form for threshold of free energy
fe_threshold = StringField(default=-10)
# a text form for threshold of MCL
mcl_threshold = StringField(default=6)
# a button to submit request
submit = SubmitField('Search')
class form_search_Gene(FlaskForm):
'''forms used in Search by Gene page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# a radio form for prediction tool
search_tool = RadioField('Prediction Tools',
choices=[('RNAhybrid', 'RNAhybrid'),
('IntaRNA', 'IntaRNA'),
('Consensus', 'Consensus Only')],
validators=[InputRequired()],
default='Consensus')
# a text form for Gene ID
# empty checking already conducted in front-end, BTW empty input can also be handled
gene = StringField()
# multiple checkbox for tRF type
trf_1 = BooleanField("tRF-1 / tsRNA", default=True, false_values=('False', 'false', ''))
trf_3 = BooleanField("tRF-3", default=True, false_values=('False', 'false', ''))
trf_5 = BooleanField("tRF-5", default=True, false_values=('False', 'false', ''))
trf_5u = BooleanField("5'U tRF", default=True, false_values=('False', 'false', ''))
trf_i = BooleanField("i-tRF", default=True, false_values=('False', 'false', ''))
trf_5half = BooleanField("5' tRH / tiR", default=True, false_values=('False', 'false', ''))
trf_3half = BooleanField("3' tRH / tiR", default=True, false_values=('False', 'false', ''))
# multiple checkbox for tRF source
trfdb = BooleanField("tRFdb", default=True, false_values=('False', 'false', ''))
tsrna = BooleanField("tsRNA study", default=True, false_values=('False', 'false', ''))
tsrfun = BooleanField("tsRFun", default=True, false_values=('False', 'false', ''))
tsrbase = BooleanField("tsRBase", default=True, false_values=('False', 'false', ''))
tatdb = BooleanField("tatDB", default=True, false_values=('False', 'false', ''))
mintbase = BooleanField("MINTbase v2.0", default=True, false_values=('False', 'false', ''))
trfexp = BooleanField("tRFexplorer", default=True, false_values=('False', 'false', ''))
oncotrf = BooleanField("OncotRF", default=True, false_values=('False', 'false', ''))
# multiple checkbox for binding region
utr5 = BooleanField("5' UTR", default=True, false_values=('False', 'false', ''))
cds = BooleanField("CDS", default=True, false_values=('False', 'false', ''))
utr3 = BooleanField("3' UTR", default=True, false_values=('False', 'false', ''))
# a checkbox for whether restrict to binding sites with experimental evidence only
exp_only = BooleanField("Only show binding sites with Experimental Evidence", default=False, false_values=('False', 'false', ''))
# a text form for threshold of free energy
fe_threshold = StringField(default=-10)
# a text form for threshold of MCL
mcl_threshold = StringField(default=6)
# a button to submit request
submit = SubmitField('Search')
class form_online_Targets(FlaskForm):
'''forms used in online Targets page
note here we DO NOT need validators
'''
# a radio form for switch paste and upload for query small RNA sequences
query_switch = RadioField('query RNA',
choices=[('paste', 'Paste'),
('upload', 'Upload')],
default='paste')
# a radio form for switch paste and upload for target long RNA sequences
target_switch = RadioField('target RNA',
choices=[('paste', 'Paste'),
('upload', 'Upload')],
default='paste')
# text-area field rather than string field for query small RNA sequences
query_input = TextAreaField()
# text-area field rather than string field for target long RNA sequences
target_input = TextAreaField()
# options for tRFtarget-pipeline
# free energy threshold for RNAhybrid
e_rnahybrid = StringField(default=-15)
# free energy threshold for IntaRNA
e_intarna = StringField(default=0)
# reported number of interaction sites on each target RNA
suboptimal = StringField(default=1)
# MCL threshold
mcl = StringField(default=6)
# email adress
email = StringField()
# a button to submit request
submit = SubmitField('Start')
class form_advanced_search(FlaskForm):
'''forms used in advanced search page
'''
# a select form for organism
search_organism = SelectField('Organism',
choices=[[x, x] for x in organism_list],
validators=[InputRequired()],
default=organism_list[0])
# a radio form for prediction tool
search_tool = RadioField('Prediction Tools',
choices=[('RNAhybrid', 'RNAhybrid'),
('IntaRNA', 'IntaRNA'),
('Consensus', 'Consensus Only')],
validators=[InputRequired()],
default='Consensus')
# a select form for switching RNA and gene
search_target = SelectField('Search Target',
choices=[('RNA', 'RNA'),
('Gene', 'Gene')],
validators=[InputRequired()],
default='RNA')
# a text form for RNA ID or Gene ID
# empty checking already conducted in front-end, BTW empty input can also be handled
target = StringField()
# a text form for RNA ID
# empty checking already conducted in front-end, BTW empty input can also be handled
trf = StringField()
# multiple checkbox for binding region
utr5 = BooleanField("5' UTR", default=True, false_values=('False', 'false', ''))
cds = BooleanField("CDS", default=True, false_values=('False', 'false', ''))
utr3 = BooleanField("3' UTR", default=True, false_values=('False', 'false', ''))
# a checkbox for whether restrict to binding sites with experimental evidence only
exp_only = BooleanField("Only show binding sites with Experimental Evidence", default=False, false_values=('False', 'false', ''))
# a text form for threshold of free energy
fe_threshold = StringField(default=-10)
# a text form for threshold of MCL
mcl_threshold = StringField(default=6)
# a button to submit request
submit = SubmitField('Search')