-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathforms.py
150 lines (140 loc) · 7.43 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
from wtforms import Form, StringField, FileField
from wtforms.validators import URL, Optional, InputRequired, Email
from flask_wtf.file import FileRequired, FileAllowed
ALLOWED_EXTENSIONS = {'fa', 'gff', 'gff3', 'gtf', 'fasta', 'fna', 'tar', 'gz'}
# Use it for production site
class SubmitJob(Form):
email = StringField('Email Address',
description="When job is complete this e-mail will receive the download links",
render_kw={
"autofocus": "",
},
validators=[
InputRequired(),
Email()
])
chrom = StringField('Chromosome',
description="ID of the chromosome to modify. Must match ID in FASTA file.",
validators=[
InputRequired()
])
# POSITION
position = StringField('Position',
description="Position in chromosome at which to insert <in_fasta>. Can use -1 to add to end "
"of chromosome. Note: Position is 0-based",
validators=[Optional()])
# OR
upstream_fasta = FileField('Upstream Sequence',
description="FASTA file with upstream sequence.",
validators=[
Optional()
])
downstream_fasta = FileField('Downstream Sequence',
description="FASTA file with downstream sequence.",
validators=[
Optional()
])
# Uploads
in_fasta = FileField('Inserted Sequence (FASTA)',
description="New sequence to be inserted into reference genome.",
validators=[
Optional(),
FileAllowed([ALLOWED_EXTENSIONS], 'Invalid File Type'),
FileRequired()
])
in_gff = FileField('Inserted Reference (gff3 or gtf)',
description="GFF file describing new FASTA sequence to be inserted.",
validators=[
Optional(),
FileAllowed([ALLOWED_EXTENSIONS], 'Invalid File Type'),
InputRequired()
])
# Downloads
ref_fasta = StringField('Reference Sequence (FASTA)',
description="URL to reference FASTA file. e.g. ftp://ftp.ensembl.org/pub/release-88/fasta/mus_musculus/dna/Mus_musculus.GRCm38.dna.toplevel.fa.gz",
render_kw={
"placeholder": "Enter Reference URL",
},
validators=[
URL(),
InputRequired()
])
ref_gff = StringField('Reference Annotation (gff3 or gtf)',
description="URL to reference gff file. e.g. ftp://ftp.ensembl.org/pub/release-88/gff3/mus_musculus/Mus_musculus.GRCm38.88.gff3.gz",
render_kw={
"placeholder": "Enter Reference URL",
},
validators=[
URL(),
InputRequired()
])
# Use it for test site (test_case_1)
class Testjob(Form):
email = StringField('Email Address',
description="When job is complete this e-mail will receive the download links",
render_kw={
"autofocus": "",
},
validators=[
InputRequired(),
Email()
],
default="[email protected]") # hard code email
chrom = StringField('Chromosome',
description="ID of the chromosome to modify. Must match ID in FASTA file.",
validators=[
InputRequired()
],
default = "X") # Chromosome has been set to X as default
# POSITION
position = StringField('Position',
description="Position in chromosome at which to insert <in_fasta>. Can use -1 to add to end "
"of chromosome. Note: Position is 0-based",
validators=[Optional()])
# OR
upstream_fasta = FileField('Upstream Sequence',
description="FASTA file with upstream sequence. If no file is selected, the system will use 'test-up.fa' as a default.",
validators=[
Optional()
])
downstream_fasta = FileField('Downstream Sequence',
description="FASTA file with downstream sequence. If no file is selected, the system will use 'test-down.fa' as a default.",
validators=[
Optional()
])
# Uploads
in_fasta = FileField('Inserted Sequence (FASTA)',
description="Please upload the new sequence to be inserted into the reference genome. If no file is selected, the system will use 'test-in.fa' as a default.",
validators=[
Optional(),
FileAllowed([ALLOWED_EXTENSIONS], 'Invalid File Type'),
# FileRequired()
])
in_gff = FileField('Inserted Reference (gff3 or gtf)',
description="Please upload the GFF file describing the new FASTA sequence to be inserted. If no file is selected, the system will use 'test-in.gff' as a default.",
validators=[
Optional(),
FileAllowed([ALLOWED_EXTENSIONS], 'Invalid File Type'),
# InputRequired()
])
# Downloads
ref_fasta = StringField('Reference Sequence (FASTA)',
description="URL to reference FASTA file. e.g. ftp://ftp.ensembl.org/pub/release-88/fasta/mus_musculus/dna/Mus_musculus.GRCm38.dna.toplevel.fa.gz",
render_kw={
"placeholder": "Enter Reference URL",
},
validators=[
URL(),
InputRequired()
],
default = "test-ref.fa")
ref_gff = StringField('Reference Annotation (gff3 or gtf)',
description="URL to reference gff file. e.g. ftp://ftp.ensembl.org/pub/release-88/gff3/mus_musculus/Mus_musculus.GRCm38.88.gff3.gz",
render_kw={
"placeholder": "Enter Reference URL",
},
validators=[
URL(),
InputRequired()
],
default = "test-ref.gtf")