line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::MLST::Download::Downloadable; |
2
|
|
|
|
|
|
|
# ABSTRACT: Moose Role to download everything data |
3
|
|
|
|
|
|
|
$Bio::MLST::Download::Downloadable::VERSION = '2.1.1630910'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
9675
|
use Moose::Role; |
|
7
|
|
|
|
|
30011
|
|
|
7
|
|
|
|
|
31
|
|
7
|
7
|
|
|
7
|
|
39139
|
use File::Copy; |
|
7
|
|
|
|
|
9059
|
|
|
7
|
|
|
|
|
479
|
|
8
|
7
|
|
|
7
|
|
46
|
use File::Basename; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
460
|
|
9
|
7
|
|
|
7
|
|
2789
|
use LWP::Simple; |
|
7
|
|
|
|
|
170528
|
|
|
7
|
|
|
|
|
81
|
|
10
|
7
|
|
|
7
|
|
2863
|
use File::Path 2.06 qw(make_path); |
|
7
|
|
|
|
|
169
|
|
|
7
|
|
|
|
|
2557
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _download_file |
13
|
|
|
|
|
|
|
{ |
14
|
7
|
|
|
7
|
|
68
|
my ($self, $filename,$destination_directory) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# copy if its on the same filesystem |
17
|
7
|
100
|
|
|
|
146
|
if(-e $filename) |
18
|
|
|
|
|
|
|
{ |
19
|
5
|
|
|
|
|
27
|
copy($filename, $destination_directory); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else |
22
|
|
|
|
|
|
|
{ |
23
|
2
|
|
|
|
|
14
|
my $status = getstore($filename, join('/',($destination_directory,$self->_get_filename_from_url($filename)))); |
24
|
2
|
100
|
|
|
|
19
|
die "Something went wrong, got a $status status code" if is_error($status); |
25
|
|
|
|
|
|
|
} |
26
|
6
|
|
|
|
|
1679
|
1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _get_filename_from_url |
30
|
|
|
|
|
|
|
{ |
31
|
5
|
|
|
5
|
|
12
|
my ($self, $filename) = @_; |
32
|
5
|
50
|
|
|
|
54
|
if($filename =~ m!/([^/]+)$!) |
33
|
|
|
|
|
|
|
{ |
34
|
5
|
|
|
|
|
53
|
return $1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
return int(rand(10000)).".tfa"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _build_destination_directory |
41
|
|
|
|
|
|
|
{ |
42
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
43
|
1
|
|
|
|
|
25
|
my $destination_directory = join('/',($self->base_directory,$self->_sub_directory)); |
44
|
1
|
|
|
|
|
179
|
make_path($destination_directory); |
45
|
1
|
|
|
|
|
145
|
make_path(join('/',($destination_directory,'alleles'))); |
46
|
1
|
|
|
|
|
109
|
make_path(join('/',($destination_directory,'profiles'))); |
47
|
1
|
|
|
|
|
33
|
return $destination_directory; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _sub_directory |
51
|
|
|
|
|
|
|
{ |
52
|
1
|
|
|
1
|
|
1
|
my ($self) = @_; |
53
|
1
|
|
|
|
|
23
|
my $combined_name = join('_',($self->species)); |
54
|
1
|
|
|
|
|
2
|
$combined_name =~ s!\.$!!gi; |
55
|
1
|
|
|
|
|
4
|
$combined_name =~ s!\W!_!gi; |
56
|
1
|
|
|
|
|
4
|
return $combined_name; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
7
|
|
47
|
no Moose; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
74
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Bio::MLST::Download::Downloadable - Moose Role to download everything data |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 2.1.1630910 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Moose Role to download everything data |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
with 'Bio::MLST::Download::Downloadable'; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Bio::MLST::Download::Database> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<Bio::MLST::Download::Databases> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Wellcome Trust Sanger Institute. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This is free software, licensed under: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |