-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathscafe.download.resources.genome
296 lines (205 loc) · 9.51 KB
/
scafe.download.resources.genome
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
#!/usr/bin/env perl
# This chunk of stuff was generated by App::FatPacker. To find the original
# file's code, look for the end of this BEGIN block or the string 'FATPACK'
BEGIN {
my %fatpacked;
s/^ //mg for values %fatpacked;
my $class = 'FatPacked::'.(0+\%fatpacked);
no strict 'refs';
*{"${class}::files"} = sub { keys %{$_[0]} };
if ($] < 5.008) {
*{"${class}::INC"} = sub {
if (my $fat = $_[0]{$_[1]}) {
my $pos = 0;
my $last = length $fat;
return (sub {
return 0 if $pos == $last;
my $next = (1 + index $fat, "\n", $pos) || $last;
$_ .= substr $fat, $pos, $next - $pos;
$pos = $next;
return 1;
});
}
};
}
else {
*{"${class}::INC"} = sub {
if (my $fat = $_[0]{$_[1]}) {
open my $fh, '<', \$fat
or die "FatPacker error loading $_[1] (could be a perl installation issue?)";
return $fh;
}
return;
};
}
unshift @INC, bless \%fatpacked, $class;
} # END OF FATPACK CODE
#====================================================================================================================================================#
#<use>
$|++; #---turn on the auto flush for the progress bar
no warnings 'utf8';
use warnings;
use strict;
use Getopt::Long 'HelpMessage';
use Time::HiRes qw( time );
use File::Spec::Functions qw(rel2abs abs2rel);
use Cwd 'abs_path';
#<\use>
#====================================================================================================================================================#
#====================================================================================================================================================#
#<doc>
=head1 SYNOPSIS
5'-O~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AAA-3'
O~~~AA O~~ O~ O~~~~~~~AO~~~~~~~~A
O~~ O~~ O~~ O~~ O~O~~ O~~ O~~
O~~ O~~ O~ O~~ O~~ O~~
O~~ O~~ O~~ O~~ O~~~~~AA O~~~~~~A
O~~ O~~ O~~~~~A O~~ O~~ O~~
O~~ O~~ O~~ O~~ O~~ O~~ O~~ O~~
O~~~~A O~~~ O~~ O~~O~~ O~~~~~~~AA
┌─ᐅ 5'-O~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-3'
...===┴========================================================================================...
Single Cell Analysis of Five-prime End (SCAFE) Tool Suite
---> download.resources.genome <---
<--- download, reference genome to resources dir --->
Description:
This script download reference genome data and save in ./resources/genome.
Usage:
download.resources.genome --genome
--genome <required> [string] name of genome reference, currently available genomes:
hg19.gencode_v32lift37
hg38.gencode_v32
mm10.gencode_vM25
TAIR10.AtRTDv2
Dependencies:
wget
tar
For demo, cd to SCAFE dir and run,
scafe.download.resources.genome \
--genome=hg19.gencode_v32lift37
=head1 VERSION
v0.9.0-beta [March 20, 2021]
-Initial pre-release
v1.0.0 [June 6, 2022]
-No major update
=cut
#<\doc>
#====================================================================================================================================================#
#====================================================================================================================================================#
#<lastCmdCalled>
#
# notCalledBefore
#
# notCalledBefore
#
#<\lastCmdCalled>
#====================================================================================================================================================#
#====================================================================================================================================================#
#<global>
#<\global>
#====================================================================================================================================================#
#====================================================================================================================================================#
{ #Main sections lexical scope starts
#====================================================================================================================================================#
#====================================================================================================================================================#
# section 0_startTasks
#
#<section ID="startTasks" num="0">
my $genome_url_hsh_ref = {
'hg19.gencode_v32lift37' => "https://www.dropbox.com/s/ol23wpn695p06wj/hg19.gencode_v32lift37.tar.gz",
'hg38.gencode_v32' => "https://www.dropbox.com/s/q9h4dcz3jhd43wy/hg38.gencode_v32.tar.gz",
'mm10.gencode_vM25' => "https://www.dropbox.com/s/a2397vqfm1igpml/mm10.gencode_vM25.tar.gz",
'TAIR10.AtRTDv2' => "https://www.dropbox.com/s/kekn3p6e2n5lv88/TAIR10.AtRTDv2.tar.gz",
};
my ($genome) = &readParameters();#->171
my ($scafe_dir, $script_dir, $genome_dir) = &prepDir();#->145
&download($genome_dir, $genome, $genome_url_hsh_ref);#->117
#<\section>
#====================================================================================================================================================#
#====================================================================================================================================================#
# section 1_run
#
#<section ID="run" num="1">
#<\section>
#====================================================================================================================================================#
#====================================================================================================================================================#
} #Main sections lexical scope ends
#====================================================================================================================================================#
#====================================================================================================================================================#
#List of subroutines by category
#
# general [n=1]:
# readParameters
#
# unassigned [n=2]:
# download, prepDir
#
#====================================================================================================================================================#
sub download {
#....................................................................................................................................................#
# subroutineCategory: unassigned
# dependOnSub: >none
# appearInSub: >none
# primaryAppearInSection: 0_startTasks|79
# secondaryAppearInSection: >none
# input: $genome, $genome_dir, $genome_url_hsh_ref
# output:
# toCall: &download($genome_dir, $genome, $genome_url_hsh_ref);
# calledInLine: 90
#....................................................................................................................................................#
my ($genome_dir, $genome, $genome_url_hsh_ref) = @_;
my $tar_gz_path = "$genome_dir/$genome.tar.gz";
my $genome_url = $genome_url_hsh_ref->{$genome};
die "genome $genome is not avaiable\n" if not exists $genome_url_hsh_ref->{$genome};
print "Cleaning up $genome_dir/$genome/";
system ("rm -f $tar_gz_path");
system ("rm -rf $genome_dir/$genome/");
system ("wget $genome_url -P $genome_dir");
system ("tar -xzvf $tar_gz_path -C $genome_dir");
system ("rm $tar_gz_path");
return ();
}
sub prepDir {
#....................................................................................................................................................#
# subroutineCategory: unassigned
# dependOnSub: >none
# appearInSub: >none
# primaryAppearInSection: 0_startTasks|79
# secondaryAppearInSection: >none
# input: none
# output: $genome_dir, $scafe_dir, $script_dir
# toCall: my ($scafe_dir, $script_dir, $genome_dir) = &prepDir();
# calledInLine: 89
#....................................................................................................................................................#
my $scriptAbsPath = abs_path($0);
my @path_split = split /\//, $scriptAbsPath;
my $scafe_dir_index = $#path_split-2;
my $script_dir_index = $#path_split-1;
my $scafe_dir = join "/", @path_split[0..$scafe_dir_index];
my $script_dir = join "/", @path_split[0..$script_dir_index];
my @mkDirAry = ();
my $genome_dir = $scafe_dir."/resources/genome/"; push @mkDirAry, $genome_dir;
foreach my $dir (@mkDirAry) {system ("mkdir -pm 755 $dir");}
return ($scafe_dir, $script_dir, $genome_dir);
}
sub readParameters {
#....................................................................................................................................................#
# subroutineCategory: general
# dependOnSub: >none
# appearInSub: >none
# primaryAppearInSection: 0_startTasks|79
# secondaryAppearInSection: >none
# input: none
# output: $genome
# toCall: my ($genome) = &readParameters();
# calledInLine: 88
#....................................................................................................................................................#
my ($genome);
GetOptions (
"genome=s" => \$genome,
'help' => sub { HelpMessage(0) },
) or HelpMessage(1);
HelpMessage(1) unless $genome;
return($genome);
}
exit;