line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RL::Common; |
2
|
17
|
|
|
17
|
|
86271
|
use strict; |
|
17
|
|
|
|
|
63
|
|
|
17
|
|
|
|
|
741
|
|
3
|
17
|
|
|
17
|
|
119
|
use warnings; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
657
|
|
4
|
17
|
|
|
17
|
|
1358
|
use autodie; |
|
17
|
|
|
|
|
41866
|
|
|
17
|
|
|
|
|
129
|
|
5
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
123878
|
use 5.010001; |
|
17
|
|
|
|
|
176
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
129
|
use Carp qw(); |
|
17
|
|
|
|
|
269
|
|
|
17
|
|
|
|
|
564
|
|
9
|
17
|
|
|
17
|
|
14053
|
use IO::Zlib; |
|
17
|
|
|
|
|
1493351
|
|
|
17
|
|
|
|
|
160
|
|
10
|
17
|
|
|
17
|
|
1334
|
use List::Util qw(); |
|
17
|
|
|
|
|
47
|
|
|
17
|
|
|
|
|
394
|
|
11
|
17
|
|
|
17
|
|
17822
|
use Path::Tiny qw(); |
|
17
|
|
|
|
|
246801
|
|
|
17
|
|
|
|
|
672
|
|
12
|
17
|
|
|
17
|
|
12208
|
use Set::Scalar; |
|
17
|
|
|
|
|
233518
|
|
|
17
|
|
|
|
|
1072
|
|
13
|
17
|
|
|
17
|
|
10263
|
use Tie::IxHash; |
|
17
|
|
|
|
|
61006
|
|
|
17
|
|
|
|
|
917
|
|
14
|
17
|
|
|
17
|
|
10667
|
use YAML::Syck qw(); |
|
17
|
|
|
|
|
41923
|
|
|
17
|
|
|
|
|
597
|
|
15
|
|
|
|
|
|
|
|
16
|
17
|
|
|
17
|
|
12267
|
use AlignDB::IntSpan; |
|
17
|
|
|
|
|
149847
|
|
|
17
|
|
|
|
|
29094
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# The only entrance for AlignDB::IntSpan or AlignDB::IntSpanXS |
19
|
|
|
|
|
|
|
#@returns AlignDB::IntSpan |
20
|
|
|
|
|
|
|
sub new_set { |
21
|
360
|
|
|
360
|
0
|
1977
|
return AlignDB::IntSpan->new; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub read_lines { |
25
|
16
|
|
|
16
|
0
|
56
|
my $infile = shift; |
26
|
|
|
|
|
|
|
|
27
|
16
|
|
|
|
|
42
|
my $in_fh; |
28
|
16
|
50
|
|
|
|
96
|
if ( lc $infile eq "stdin" ) { |
29
|
0
|
|
|
|
|
0
|
$in_fh = *STDIN{IO}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
16
|
|
|
|
|
191
|
$in_fh = IO::Zlib->new( $infile, "rb" ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
16
|
|
|
|
|
36154
|
my @lines; |
36
|
16
|
|
|
|
|
97
|
while ( my $line = $in_fh->getline ) { |
37
|
910
|
|
|
|
|
120739
|
chomp $line; |
38
|
910
|
|
|
|
|
3168
|
push @lines, $line; |
39
|
|
|
|
|
|
|
} |
40
|
16
|
|
|
|
|
5497
|
close $in_fh; |
41
|
|
|
|
|
|
|
|
42
|
16
|
|
|
|
|
15915
|
return @lines; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub read_sizes { |
46
|
9
|
|
|
9
|
0
|
38
|
my $fn = shift; |
47
|
9
|
|
|
|
|
51
|
my $remove_chr = shift; |
48
|
|
|
|
|
|
|
|
49
|
9
|
|
|
|
|
65
|
my @lines = read_lines($fn); |
50
|
9
|
|
|
|
|
35
|
my %length_of; |
51
|
9
|
|
|
|
|
44
|
for (@lines) { |
52
|
122
|
|
|
|
|
402
|
my ( $key, $value ) = split /\t/; |
53
|
122
|
50
|
|
|
|
348
|
$key =~ s/chr0?//i if $remove_chr; |
54
|
122
|
|
|
|
|
411
|
$length_of{$key} = $value; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
78
|
return \%length_of; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub read_names { |
61
|
1
|
|
|
1
|
0
|
8
|
my $fn = shift; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
9
|
my @lines = read_lines($fn); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
11
|
return \@lines; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub runlist2set { |
69
|
58
|
|
|
58
|
0
|
10712
|
my $runlist_of = shift; |
70
|
58
|
|
|
|
|
197
|
my $remove_chr = shift; |
71
|
|
|
|
|
|
|
|
72
|
58
|
|
|
|
|
133
|
my $set_of = {}; |
73
|
|
|
|
|
|
|
|
74
|
58
|
|
|
|
|
127
|
for my $chr ( sort keys %{$runlist_of} ) { |
|
58
|
|
|
|
|
386
|
|
75
|
241
|
|
|
|
|
703
|
my $new_chr = $chr; |
76
|
241
|
50
|
|
|
|
887
|
$new_chr =~ s/chr0?//i if $remove_chr; |
77
|
241
|
|
|
|
|
935
|
my $set = new_set(); |
78
|
241
|
|
|
|
|
4821
|
$set->add( $runlist_of->{$chr} ); |
79
|
241
|
|
|
|
|
1296996
|
$set_of->{$new_chr} = $set; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
58
|
|
|
|
|
364
|
return $set_of; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub decode_header { |
86
|
39
|
|
|
39
|
0
|
3315
|
my $header = shift; |
87
|
|
|
|
|
|
|
|
88
|
39
|
|
|
|
|
252
|
tie my %info, "Tie::IxHash"; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# S288.chrI(+):27070-29557|species=S288C |
91
|
39
|
|
|
|
|
918
|
my $head_qr = qr{ |
92
|
|
|
|
|
|
|
(?:(?P[\w_]+)\.)? |
93
|
|
|
|
|
|
|
(?P[\w-]+) |
94
|
|
|
|
|
|
|
(?:\((?P.+)\))? |
95
|
|
|
|
|
|
|
[\:] # spacer |
96
|
|
|
|
|
|
|
(?P\d+) |
97
|
|
|
|
|
|
|
[\_\-]? # spacer |
98
|
|
|
|
|
|
|
(?P\d+)? |
99
|
|
|
|
|
|
|
}xi; |
100
|
|
|
|
|
|
|
|
101
|
39
|
|
|
|
|
503
|
$header =~ $head_qr; |
102
|
39
|
|
|
|
|
149
|
my $chr_name = $2; |
103
|
39
|
|
|
|
|
114
|
my $chr_start = $4; |
104
|
39
|
|
|
|
|
103
|
my $chr_end = $5; |
105
|
|
|
|
|
|
|
|
106
|
39
|
100
|
66
|
|
|
259
|
if ( defined $chr_name and defined $chr_start ) { |
107
|
36
|
100
|
|
|
|
111
|
if ( !defined $chr_end ) { |
108
|
1
|
|
|
|
|
3
|
$chr_end = $chr_start; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
%info = ( |
111
|
36
|
|
|
|
|
341
|
name => $1, |
112
|
|
|
|
|
|
|
chr => $chr_name, |
113
|
|
|
|
|
|
|
strand => $3, |
114
|
|
|
|
|
|
|
start => $chr_start, |
115
|
|
|
|
|
|
|
end => $chr_end, |
116
|
|
|
|
|
|
|
); |
117
|
36
|
100
|
|
|
|
3769
|
if ( defined $info{strand} ) { |
118
|
16
|
50
|
|
|
|
167
|
if ( $info{strand} eq '1' ) { |
|
|
50
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
$info{strand} = '+'; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
elsif ( $info{strand} eq '-1' ) { |
122
|
0
|
|
|
|
|
0
|
$info{strand} = '-'; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
else { |
127
|
3
|
|
|
|
|
14
|
$header =~ /^(\S+)/; |
128
|
3
|
|
|
|
|
8
|
my $chr = $1; |
129
|
3
|
|
|
|
|
19
|
%info = ( |
130
|
|
|
|
|
|
|
name => undef, |
131
|
|
|
|
|
|
|
chr => $chr, |
132
|
|
|
|
|
|
|
strand => undef, |
133
|
|
|
|
|
|
|
start => undef, |
134
|
|
|
|
|
|
|
end => undef, |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# additional keys |
139
|
39
|
100
|
|
|
|
946
|
if ( $header =~ /\|(.+)/ ) { |
140
|
1
|
|
|
|
|
6
|
my @parts = grep {defined} split /;/, $1; |
|
1
|
|
|
|
|
4
|
|
141
|
1
|
|
|
|
|
3
|
for my $part (@parts) { |
142
|
1
|
|
|
|
|
4
|
my ( $key, $value ) = split /=/, $part; |
143
|
1
|
50
|
33
|
|
|
7
|
if ( defined $key and defined $value ) { |
144
|
1
|
|
|
|
|
4
|
$info{$key} = $value; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
39
|
|
|
|
|
215
|
return \%info; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub info_is_valid { |
153
|
42
|
|
|
42
|
0
|
97
|
my $info = shift; |
154
|
|
|
|
|
|
|
|
155
|
42
|
50
|
|
|
|
153
|
if ( ref $info eq "HASH" ) { |
156
|
42
|
50
|
33
|
|
|
205
|
if ( exists $info->{chr} and exists $info->{start} ) { |
157
|
42
|
50
|
33
|
|
|
516
|
if ( defined $info->{chr} and defined $info->{start} ) { |
158
|
42
|
|
|
|
|
696
|
return 1; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
0
|
return 0; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub encode_header { |
167
|
19
|
|
|
19
|
0
|
31461
|
my $info = shift; |
168
|
19
|
|
|
|
|
50
|
my $only_essential = shift; |
169
|
|
|
|
|
|
|
|
170
|
19
|
|
|
|
|
48
|
my $header; |
171
|
19
|
100
|
|
|
|
153
|
if ( defined $info->{name} ) { |
|
|
50
|
|
|
|
|
|
172
|
7
|
50
|
|
|
|
51
|
if ( defined $info->{chr} ) { |
173
|
7
|
|
|
|
|
45
|
$header .= $info->{name}; |
174
|
7
|
|
|
|
|
44
|
$header .= "." . $info->{chr}; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
else { |
177
|
0
|
|
|
|
|
0
|
$header .= $info->{name}; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
elsif ( defined $info->{chr} ) { |
181
|
12
|
|
|
|
|
214
|
$header .= $info->{chr}; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
19
|
100
|
|
|
|
162
|
if ( defined $info->{strand} ) { |
185
|
10
|
|
|
|
|
72
|
$header .= "(" . $info->{strand} . ")"; |
186
|
|
|
|
|
|
|
} |
187
|
19
|
50
|
|
|
|
144
|
if ( defined $info->{start} ) { |
188
|
19
|
|
|
|
|
152
|
$header .= ":" . $info->{start}; |
189
|
19
|
100
|
|
|
|
147
|
if ( $info->{end} != $info->{start} ) { |
190
|
17
|
|
|
|
|
218
|
$header .= "-" . $info->{end}; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# additional keys |
195
|
19
|
50
|
|
|
|
159
|
if ( !$only_essential ) { |
196
|
19
|
|
|
|
|
64
|
my %essential = map { $_ => 1 } qw{name chr strand start end seq full_seq}; |
|
133
|
|
|
|
|
360
|
|
197
|
19
|
|
|
|
|
45
|
my @parts; |
198
|
19
|
|
|
|
|
39
|
for my $key ( sort keys %{$info} ) { |
|
19
|
|
|
|
|
117
|
|
199
|
92
|
100
|
|
|
|
743
|
if ( !$essential{$key} ) { |
200
|
2
|
|
|
|
|
9
|
push @parts, $key . "=" . $info->{$key}; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
} |
203
|
19
|
100
|
|
|
|
97
|
if (@parts) { |
204
|
2
|
|
|
|
|
7
|
my $additional = join ";", @parts; |
205
|
2
|
|
|
|
|
9
|
$header .= "|" . $additional; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
19
|
|
|
|
|
135
|
return $header; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |