line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RL::Command::combine; |
2
|
13
|
|
|
13
|
|
152056
|
use strict; |
|
13
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
383
|
|
3
|
13
|
|
|
13
|
|
72
|
use warnings; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
399
|
|
4
|
13
|
|
|
13
|
|
4808
|
use autodie; |
|
13
|
|
|
|
|
155210
|
|
|
13
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
82733
|
use App::RL -command; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
173
|
|
7
|
13
|
|
|
13
|
|
12224
|
use App::RL::Common; |
|
13
|
|
|
|
|
59
|
|
|
13
|
|
|
|
|
535
|
|
8
|
|
|
|
|
|
|
|
9
|
13
|
|
|
13
|
|
124
|
use constant abstract => 'combine multiple sets of runlists'; |
|
13
|
|
|
|
|
207
|
|
|
13
|
|
|
|
|
9396
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub opt_spec { |
12
|
|
|
|
|
|
|
return ( |
13
|
5
|
|
|
5
|
1
|
32
|
[ "outfile|o=s", "Output filename. [stdout] for screen." ], |
14
|
|
|
|
|
|
|
[ "remove|r", "Remove 'chr0' from chromosome names." ], |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub usage_desc { |
19
|
5
|
|
|
5
|
1
|
37678
|
my $self = shift; |
20
|
5
|
|
|
|
|
21
|
my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" |
21
|
5
|
|
|
|
|
84
|
$desc .= " "; |
22
|
5
|
|
|
|
|
20
|
return $desc; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub description { |
26
|
1
|
|
|
1
|
1
|
665
|
my $desc; |
27
|
1
|
|
|
|
|
3
|
$desc .= ucfirst(abstract) . ".\n"; |
28
|
1
|
|
|
|
|
3
|
$desc .= " " x 4 . "It's expected that the YAML file is --mk.\n"; |
29
|
1
|
|
|
|
|
2
|
$desc .= " " x 4 . "Otherwise this command will make no effects.\n"; |
30
|
1
|
|
|
|
|
3
|
return $desc; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub validate_args { |
34
|
4
|
|
|
4
|
1
|
3079
|
my ( $self, $opt, $args ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
4
|
100
|
|
|
|
7
|
if ( @{$args} != 1 ) { |
|
4
|
|
|
|
|
15
|
|
37
|
1
|
|
|
|
|
3
|
my $message = "This command need one input file.\n\tIt found"; |
38
|
1
|
|
|
|
|
3
|
$message .= sprintf " [%s]", $_ for @{$args}; |
|
1
|
|
|
|
|
3
|
|
39
|
1
|
|
|
|
|
3
|
$message .= ".\n"; |
40
|
1
|
|
|
|
|
9
|
$self->usage_error($message); |
41
|
|
|
|
|
|
|
} |
42
|
3
|
|
|
|
|
9
|
for ( @{$args} ) { |
|
3
|
|
|
|
|
9
|
|
43
|
3
|
50
|
|
|
|
10
|
next if lc $_ eq "stdin"; |
44
|
3
|
100
|
|
|
|
18
|
if ( !Path::Tiny::path($_)->is_file ) { |
45
|
1
|
|
|
|
|
112
|
$self->usage_error("The input file [$_] doesn't exist."); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
|
|
150
|
if ( !exists $opt->{outfile} ) { |
50
|
0
|
|
|
|
|
0
|
$opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".combine.yml"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub execute { |
55
|
2
|
|
|
2
|
1
|
15
|
my ( $self, $opt, $args ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#----------------------------# |
58
|
|
|
|
|
|
|
# Loading |
59
|
|
|
|
|
|
|
#----------------------------# |
60
|
2
|
|
|
|
|
5
|
my $s_of = {}; |
61
|
2
|
|
|
|
|
26
|
my $all_name_set = Set::Scalar->new; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
293
|
my $yml = YAML::Syck::LoadFile( $args->[0] ); |
64
|
2
|
|
|
|
|
470
|
my @keys = sort keys %{$yml}; |
|
2
|
|
|
|
|
13
|
|
65
|
|
|
|
|
|
|
|
66
|
2
|
100
|
|
|
|
11
|
if ( ref $yml->{ $keys[0] } eq 'HASH' ) { |
67
|
1
|
|
|
|
|
3
|
for my $key (@keys) { |
68
|
5
|
|
|
|
|
223
|
$s_of->{$key} = App::RL::Common::runlist2set( $yml->{$key}, $opt->{remove} ); |
69
|
5
|
|
|
|
|
49
|
$all_name_set->insert( keys %{ $s_of->{$key} } ); |
|
5
|
|
|
|
|
27
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
1
|
|
|
|
|
4
|
@keys = ("__single"); |
74
|
|
|
|
|
|
|
$s_of->{__single} |
75
|
1
|
|
|
|
|
9
|
= App::RL::Common::runlist2set( $yml, $opt->{remove} ); |
76
|
1
|
|
|
|
|
4
|
$all_name_set->insert( keys %{ $s_of->{__single} } ); |
|
1
|
|
|
|
|
9
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#----------------------------# |
80
|
|
|
|
|
|
|
# Operating |
81
|
|
|
|
|
|
|
#----------------------------# |
82
|
2
|
|
|
|
|
118
|
my $op_result_of = { map { $_ => App::RL::Common::new_set() } $all_name_set->members }; |
|
3
|
|
|
|
|
32
|
|
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
22
|
for my $key (@keys) { |
85
|
6
|
|
|
|
|
2165
|
my $s = $s_of->{$key}; |
86
|
6
|
|
|
|
|
9
|
for my $chr ( keys %{$s} ) { |
|
6
|
|
|
|
|
14
|
|
87
|
6
|
|
|
|
|
16
|
$op_result_of->{$chr}->add( $s->{$chr} ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# convert sets to runlists |
92
|
2
|
|
|
|
|
1998
|
for my $chr ( keys %{$op_result_of} ) { |
|
2
|
|
|
|
|
9
|
|
93
|
3
|
|
|
|
|
117
|
$op_result_of->{$chr} = $op_result_of->{$chr}->runlist; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#----------------------------# |
97
|
|
|
|
|
|
|
# Output |
98
|
|
|
|
|
|
|
#----------------------------# |
99
|
2
|
|
|
|
|
208
|
my $out_fh; |
100
|
2
|
50
|
|
|
|
15
|
if ( lc( $opt->{outfile} ) eq "stdout" ) { |
101
|
2
|
|
|
|
|
9
|
$out_fh = *STDOUT; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
else { |
104
|
0
|
|
|
|
|
0
|
open $out_fh, ">", $opt->{outfile}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
5
|
print {$out_fh} YAML::Syck::Dump($op_result_of); |
|
2
|
|
|
|
|
11
|
|
108
|
|
|
|
|
|
|
|
109
|
2
|
|
|
|
|
179
|
close $out_fh; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |