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