line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RL::Command::convert; |
2
|
14
|
|
|
14
|
|
8543
|
use strict; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
379
|
|
3
|
14
|
|
|
14
|
|
65
|
use warnings; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
313
|
|
4
|
14
|
|
|
14
|
|
63
|
use autodie; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
68038
|
use App::RL -command; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
132
|
|
7
|
14
|
|
|
14
|
|
4427
|
use App::RL::Common; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
332
|
|
8
|
|
|
|
|
|
|
|
9
|
14
|
|
|
14
|
|
65
|
use constant abstract => 'convert runlist file to position file'; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
7261
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub opt_spec { |
12
|
|
|
|
|
|
|
return ( |
13
|
4
|
|
|
4
|
1
|
28
|
[ "outfile|o=s", "Output filename. [stdout] for screen." ], |
14
|
|
|
|
|
|
|
[ "remove|r", "Remove 'chr0' from chromosome names." ], |
15
|
|
|
|
|
|
|
{ show_defaults => 1, } |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub usage_desc { |
20
|
4
|
|
|
4
|
1
|
34837
|
return "runlist convert [options] "; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub description { |
24
|
1
|
|
|
1
|
1
|
737
|
my $desc; |
25
|
1
|
|
|
|
|
4
|
$desc .= ucfirst(abstract) . ".\n"; |
26
|
1
|
|
|
|
|
4
|
return $desc; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub validate_args { |
30
|
3
|
|
|
3
|
1
|
2283
|
my ( $self, $opt, $args ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
3
|
100
|
|
|
|
7
|
if ( @{$args} != 1 ) { |
|
3
|
|
|
|
|
12
|
|
33
|
1
|
|
|
|
|
3
|
my $message = "This command need one input file.\n\tIt found"; |
34
|
1
|
|
|
|
|
6
|
$message .= sprintf " [%s]", $_ for @{$args}; |
|
1
|
|
|
|
|
4
|
|
35
|
1
|
|
|
|
|
4
|
$message .= ".\n"; |
36
|
1
|
|
|
|
|
10
|
$self->usage_error($message); |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
6
|
for ( @{$args} ) { |
|
2
|
|
|
|
|
7
|
|
39
|
2
|
50
|
|
|
|
10
|
next if lc $_ eq "stdin"; |
40
|
2
|
100
|
|
|
|
9
|
if ( !Path::Tiny::path($_)->is_file ) { |
41
|
1
|
|
|
|
|
104
|
$self->usage_error("The input file [$_] doesn't exist."); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
61
|
if ( !exists $opt->{outfile} ) { |
46
|
0
|
|
|
|
|
0
|
$opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".pos.txt"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub execute { |
51
|
1
|
|
|
1
|
1
|
8
|
my ( $self, $opt, $args ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#----------------------------# |
54
|
|
|
|
|
|
|
# Loading |
55
|
|
|
|
|
|
|
#----------------------------# |
56
|
1
|
|
|
|
|
3
|
my $infile; # YAML::Syck::LoadFile handles IO::* |
57
|
1
|
50
|
|
|
|
5
|
if ( lc $args->[0] eq 'stdin' ) { |
58
|
0
|
|
|
|
|
0
|
$infile = *STDIN; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
1
|
|
|
|
|
3
|
$infile = $args->[0]; |
62
|
|
|
|
|
|
|
} |
63
|
1
|
|
|
|
|
7
|
my $r_of = App::RL::Common::runlist2set( YAML::Syck::LoadFile($infile), $opt->{remove} ); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
7
|
my $out_fh; |
66
|
1
|
50
|
|
|
|
6
|
if ( lc( $opt->{outfile} ) eq "stdout" ) { |
67
|
1
|
|
|
|
|
3
|
$out_fh = *STDOUT; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
0
|
|
|
|
|
0
|
open $out_fh, ">", $opt->{outfile}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#----------------------------# |
74
|
|
|
|
|
|
|
# Operating |
75
|
|
|
|
|
|
|
#----------------------------# |
76
|
1
|
|
|
|
|
3
|
for my $key ( sort keys %{$r_of} ) { |
|
1
|
|
|
|
|
8
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#@type AlignDB::IntSpan |
79
|
16
|
|
|
|
|
265
|
my $set = $r_of->{$key}; |
80
|
16
|
100
|
|
|
|
36
|
next if $set->is_empty; |
81
|
11
|
|
|
|
|
149
|
for my $span ( $set->runlists ) { |
82
|
28
|
|
|
|
|
743
|
printf {$out_fh} "%s:%s\n", $key, $span; |
|
28
|
|
|
|
|
85
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
21
|
close $out_fh; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |