-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgetSequenceInfoGUI.pl
385 lines (321 loc) · 9.76 KB
/
getSequenceInfoGUI.pl
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/usr/bin/perl
##-----------------------------------
# getSequenceInfo GUI version 1
# 2020/07/24
# IP Guadeloupe Vincent Moco, David Couvin
##-----------------------------------
use warnings;
use strict;
use Tk;
use Tk::ProgressBar;
use Tk::Labelframe;
use utf8;
# variable declaration
my $kingdom;
my $species;
my $date;
my $getSummaries;
my $levelAssembly;
my $component;
my $quantity;
my $enaID;
my $output;
my $taxID;
my $fastqID;
my $directoryNcbi;
my $checkChromosome;
my $checkPlasmid;
my $checkContig;
my $checkScaffold;
my $specificComponent = "keyword";
my $components;
my $assemblyPrjID;
my $logFile;
# window creation
my $mw = new MainWindow(
-title => 'getSequenceInfo',
-background => 'white',
);
$mw->minsize(550, 550);
# a Frame you'll never see
my $frame1 = $mw->Labelframe(-background => 'white');
my $frame2 = $mw->Labelframe(-background => 'white', -text => 'NCBI', -relief => 'groove', -borderwidth => '2');
my $firstSubFrame2 = $frame2->Frame(-background => 'white');
my $subSubFrame1 = $firstSubFrame2->Frame(-background => 'white');
my $subSubFrame2 = $firstSubFrame2->Frame(-background => 'white');
my $directoryFrame = $subSubFrame1->Frame(-background => 'white', -borderwidth => '5');
my $kingdomFrame = $subSubFrame2->Frame(-background => 'white', -borderwidth => '5');
my $levelFrame = $subSubFrame2->Frame(-background => 'white', -borderwidth => '5');
my $componentFrame = $subSubFrame1->Frame(-background => 'white', -borderwidth => '5');
my $logFrame = $subSubFrame1->Frame(-background => 'white', -borderwidth => '5');
my $secondSubFrame2 = $frame2->Frame(-background => 'white');
my $frame3 = $mw->Labelframe(-background => 'white', -text => 'ENA');
my $frame4 = $mw->Labelframe(-background => 'white');
my $homeMessage = "Thank you for using getSequenceInfo!\n(Please do not use the tab key)\n";
#Affichage d'un texte
$frame1 = $mw->Label(
-text => $homeMessage,
-background => 'white',
)->pack();
##subframe1
$directoryFrame->Label(
-text => 'Sequence repository: ',
-background => 'white',
)->pack(-expand => 1, -fill => 'x');
my @directoryList = qw/refseq genbank/;
foreach my $directory (@directoryList) {
$directoryFrame->Radiobutton(
-text => $directory,
-value => $directory,
-variable => \$directoryNcbi,
)->pack(-expand => 1, -fill => 'x');
}
#label and entry for representation
$levelFrame->Label(
-text => 'Assembly level: ',
-background => 'white',
)->pack(-expand => 1, -fill => 'x');
my @levelList = ("Complete Genome", "All");
foreach my $level (@levelList) {
$levelFrame->Radiobutton(
-text => $level,
-value => $level,
-variable => \$levelAssembly,
)->pack(-expand => 1, -fill => 'x');
}
# label and listbox for kingdom
$kingdomFrame->Label(
-text => 'Select the kingdom: ',
-background => 'white',
)->pack(-expand => 1, -fill => 'x');
my $lst = $kingdomFrame->Scrolled("Listbox", -scrollbars => 'oe')->pack(-expand => 1, -fill => 'x');
$lst->configure(-height => 5);
my @kingdomList = qw/archaea bacteria fungi invertebrate plant protozoa
vertebrate_mammalian vertebrate_other viral/;
$lst->insert('end', @kingdomList);
# label and entry for componenents
$componentFrame->Label(
-text => 'Component: ',
-background => 'white',
)->pack(-expand => 1, -fill => 'x');
my %checkComponentHash = (
chromosome => $checkChromosome,
plasmid => $checkPlasmid,
contig => $checkContig,
scaffold => $checkScaffold,
);
foreach my $component (keys %checkComponentHash) {
$componentFrame->Checkbutton(
-text => $component,
-onvalue => 1,
-offvalue => 0,
-relief => 'raised',
-width => 17,
-variable => \$checkComponentHash{$component},
)->pack(-expand => 1, -fill => 'x');
}
$componentFrame->Entry(
-textvariable => \$specificComponent,
)->pack(-expand => 1, -fill => 'x');
# log frame
$logFrame->Label(
-text => 'Obtain log file: ',
-background => 'white',
)->pack(-expand => 1, -fill => 'x');
my %logFileHash = (
Yes => 1,
No => 0,
);
foreach my $logKey (keys %logFileHash) {
$logFrame->Radiobutton(
-text => $logKey,
-value => $logFileHash{$logKey},
-variable => \$logFile,
)->pack(-expand => 1, -fill => 'x');
}
## subframe2
# label and entry for species
$secondSubFrame2->Label(
-text => 'Species: ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$species),
-sticky => 'nsew');
#label and entry for date
$secondSubFrame2->Label(
-text => 'Assemblies from this date (yyyy-mm-dd): ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$date),
-sticky=> 'nsew');
#label and entry for taxid
$secondSubFrame2->Label(
-text => 'Taxonomy ID (taxID): ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$taxID),
-sticky =>'nsew');
# label and entry to rename the output
$secondSubFrame2->Label(
-text => 'Output folder name: ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$output),
-sticky => 'nsew');
# label and entry for quantity
$secondSubFrame2->Label(
-text => 'Number of assemblies (limit): ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$quantity),
-sticky => 'nsew');
# label and entry for quantity
$secondSubFrame2->Label(
-text => 'Assembly or Project ID: ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$assemblyPrjID),
-sticky => 'nsew');
# label and entry for database
$secondSubFrame2->Label(
-text => 'Get the latest assembly_summary for kingdoms: ',
-background => 'white',
)->grid($secondSubFrame2->Entry(-textvariable => \$getSummaries),
-sticky => 'nsew');
## ENA frame
# label and entry for ena
$frame3->Label(
-text => 'ENA sequence ID (enaID): ',
-background => 'white',
)->grid($frame3->Entry(-textvariable => \$enaID),
-sticky => 'nsew');
$frame3->Label(
-text => 'FASTQ run accession: ',
-background => 'white',
)->grid( $frame3->Entry(-textvariable => \$fastqID),
-sticky => 'nsew');
## bottom frame
# start search button
$frame4->Button(
-text => 'Search',
-command => \&search,
)->grid(my $progress = $frame4->ProgressBar(
-from => 0,
-to => 100,
-length => 300,
-colors => [ 0, 'blue',]),
-sticky => "nsew"
);
my @frameList = (
$frame3,
$frame4,
$secondSubFrame2
);
foreach my $frame (@frameList) {
my ($columns, $rows) = $frame->gridSize();
for (my $i = 0; $i < $columns; $i++) {
$frame->gridColumnconfigure($i, -weight => 1);
}
for (my $i = 0; $i < $rows; $i++) {
$frame->gridRowconfigure($i, -weight => 1);
}
}
$frame1->pack(-expand => 1, -fill => 'x');
$frame2->pack(-expand => 1, -fill => 'x');
$firstSubFrame2->pack(-expand => 1, -fill => 'x');
$subSubFrame1->pack(-side => 'left', -expand => 1, -fill => 'both');
$subSubFrame2->pack(-side => 'right', -expand => 1, -fill => 'both');
$directoryFrame->pack(-expand => 1, -fill => 'x');
$kingdomFrame->pack(-expand => 1, -fill => 'x');
$levelFrame->pack(-expand => 1, -fill => 'x');
$componentFrame->pack(-expand => 1, -fill => 'x');
$logFrame->pack(-expand => 1, -fill => 'x');
$secondSubFrame2->pack(-expand => 1, -fill => 'x');
$frame3->pack(-expand => 1, -fill => 'x');
$frame4->pack(-expand => 1, -fill => 'x');
MainLoop;
sub search {
my $i = 0;
my $scriptName = $0;
$scriptName =~ s/GUI//;
my $command = "perl $scriptName"; #my $command = "perl getSequenceInfo.pl";
foreach my $component (keys %checkComponentHash) {
if ($checkComponentHash{$component}) {
$components.= $component . ",";
}
}
if ($levelAssembly && $levelAssembly =~ /all/i) {
$levelAssembly = "Complete Genome,Chromosome,Scaffold,Contig";
}
if ($specificComponent && $specificComponent !~ /keyword/) {$components.= $specificComponent;}
if (defined $enaID) {
$command .= " -ena $enaID";
if ($logFile) {$command .= " -log";}
print "$command\n";
system("$command");
$i += 100;
$progress->value($i);
$mw->update();
sleep 1;
undef $enaID;
}
elsif (defined $fastqID) {
$command .= " -fastq $fastqID";
if ($logFile) {$command .= " -log";}
print "$command\n";
system("$command");
$i += 100;
$progress->value($i);
$mw->update();
sleep 1;
undef $fastqID;
}
elsif (defined $assemblyPrjID) {
$command .= " -assembly_or_project $assemblyPrjID";
if ($logFile) {$command .= " -log";}
print "$command\n";
system("$command");
$i += 100;
$progress->value($i);
$mw->update();
sleep 1;
undef $assemblyPrjID;
}
else {
my @listIndex = $lst->curselection;
foreach (@listIndex) {
$kingdom = $kingdomList[$_];
}
my @optionCharList = ( '-k', '-s', '-taxid', '-n', '-l', '-c', '-o', '-dir', '-date', '-get');
my %optionHash = (
'-k' => $kingdom,
'-s' => $species,
'-taxid' => $taxID,
'-n' => $quantity,
'-l' => $levelAssembly,
'-c' => $components,
'-o' => $output,
'-dir' => $directoryNcbi,
'-date' => $date,
'-get' => $getSummaries
);
foreach my $option (@optionCharList) {
if (defined $optionHash{$option}) { $command .= " $option \"$optionHash{$option}\""; }
$i += 8;
$progress->value($i);
$mw->update();
sleep 1;
}
if ($logFile) {$command .= " -log";}
print "$command\n";
system("$command");
undef $kingdom;
undef $species;
undef $taxID;
undef $quantity;
undef $levelAssembly;
undef $components;
undef $output;
undef $directoryNcbi;
undef $date;
undef $getSummaries;
$i += 20;
$progress->value($i);
$mw->update();
sleep 1;
}
}