forked from ICGC-TCGA-PanCancer/vcf-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnos_download_file.pl
52 lines (40 loc) · 2.01 KB
/
gnos_download_file.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
#!/usr/bin/env perl
use warnings;
use strict;
use feature qw(say);
use autodie;
use Getopt::Long;
use GNOS::Download;
# Example Command:
# cd /mnt/seqware-oozie/23f5253a-f33b-11e3-8add-8589c49f5d8e
# perl /mnt/home/seqware/git/genomic_tools/gnos_tools/launch_and_monitor_gnos.pl --command 'gtdownload --max-children 4 --rate-limit 200 -c /home/seqware/provisioned-bundles/Workflow_Bundle_BWA_2.6.3_SeqWare_1.1.0-alpha.5/Workflow_Bundle_BWA/2.6.3/scripts/gnostest.pem -v -d https://gtrepo-dkfz.annailabs.com/cghub/data/analysis/download/23f5253a-f33b-11e3-8add-8589c49f5d8e' --file-grep 23f5253a-f33b-11e3-8add-8589c49f5d8e --search-path . --md5-retries 120 --retries 30
### setup / INSTALL
# mkdir /mnt/seqware-oozie/23f5253a-f33b-11e3-8add-8589c49f5d8e
# sudo apt-get install libcommon-sense-perl
# PURPOSE:
# the program takes a command (use single quotes to encapsulate it in bash) and
# a to check, the existance of which indidates the gtdownload finished running.
# It also takes a retries count, timeout for no data being written in minutes, and a
# cooldown (sleep) time in minutes for checking if the output exists. It then executes the command in a thread and
# watches the files every sleep time. For every timeout period where there is no
# change in the output file size then the retries count is
# decremented. By default, the retries are 30 and timeout 60 minutes so the code
# could retry a download that times out a total of 30 hours before giving up.
# If the retries are exhausted the thread is killed, the
# thread is recreated and started, and the process starts over.
# where file is the GNOS id of the file
my ($command, $file);
my $cooldown_min = 1;
my $timeout_min = 60;
my $retries = 30;
GetOptions (
"command=s" => \$command,
"file=s" => \$file,
"retries=i" => \$retries,
"sleep-min=i" => \$cooldown_min,
"timeout-min=i" => \$timeout_min,
);
say "FILE: $file";
# will return 0 on success, not 0 on failure
my $ret_val = GNOS::Download->run_download($command, $file, $retries, $cooldown_min, $timeout_min);
exit ($ret_val);