| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Rangeops::Command::circos; |
|
2
|
8
|
|
|
8
|
|
58847
|
use strict; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
229
|
|
|
3
|
8
|
|
|
8
|
|
35
|
use warnings; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
197
|
|
|
4
|
8
|
|
|
8
|
|
2908
|
use autodie; |
|
|
8
|
|
|
|
|
101176
|
|
|
|
8
|
|
|
|
|
32
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
44998
|
use App::Rangeops -command; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
80
|
|
|
7
|
8
|
|
|
8
|
|
5816
|
use App::Rangeops::Common; |
|
|
8
|
|
|
|
|
24
|
|
|
|
8
|
|
|
|
|
5313
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub abstract { |
|
10
|
2
|
|
|
2
|
1
|
27174
|
return 'range links to circos links or highlight file'; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub opt_spec { |
|
14
|
|
|
|
|
|
|
return ( |
|
15
|
3
|
|
|
3
|
1
|
14
|
[ "outfile|o=s", "Output filename. [stdout] for screen." ], |
|
16
|
|
|
|
|
|
|
[ "highlight|l", "Create highlights instead of links", ], |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub usage_desc { |
|
21
|
3
|
|
|
3
|
1
|
31473
|
return "rangeops circos [options] "; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub description { |
|
25
|
1
|
|
|
1
|
1
|
590
|
my $desc; |
|
26
|
1
|
|
|
|
|
4
|
$desc .= ucfirst(abstract) . ".\n"; |
|
27
|
1
|
|
|
|
|
2
|
$desc .= "\tIt's assumed that all ranges in input files are valid.\n"; |
|
28
|
1
|
|
|
|
|
3
|
return $desc; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub validate_args { |
|
32
|
2
|
|
|
2
|
1
|
1551
|
my ( $self, $opt, $args ) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
2
|
50
|
|
|
|
4
|
if ( !@{$args} ) { |
|
|
2
|
|
|
|
|
6
|
|
|
35
|
0
|
|
|
|
|
0
|
$self->usage_error("This command need one or more input files."); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
2
|
|
|
|
|
3
|
for ( @{$args} ) { |
|
|
2
|
|
|
|
|
5
|
|
|
38
|
2
|
50
|
|
|
|
7
|
next if lc $_ eq "stdin"; |
|
39
|
2
|
50
|
|
|
|
7
|
if ( !Path::Tiny::path($_)->is_file ) { |
|
40
|
0
|
|
|
|
|
0
|
$self->usage_error("The input file [$_] doesn't exist."); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
2
|
50
|
|
|
|
160
|
if ( !exists $opt->{outfile} ) { |
|
45
|
|
|
|
|
|
|
$opt->{outfile} |
|
46
|
0
|
|
|
|
|
0
|
= Path::Tiny::path( $args->[0] )->absolute . ".links.txt"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub execute { |
|
51
|
2
|
|
|
2
|
1
|
10
|
my ( $self, $opt, $args ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#----------------------------# |
|
54
|
|
|
|
|
|
|
# Loading |
|
55
|
|
|
|
|
|
|
#----------------------------# |
|
56
|
2
|
|
|
|
|
4
|
my @lines; |
|
57
|
2
|
|
|
|
|
3
|
for my $file ( @{$args} ) { |
|
|
2
|
|
|
|
|
4
|
|
|
58
|
2
|
|
|
|
|
6
|
for my $line ( App::RL::Common::read_lines($file) ) { |
|
59
|
12
|
|
|
|
|
5859
|
my @parts = split /\t/, $line; |
|
60
|
12
|
|
|
|
|
22
|
my @colors = reverse map {"paired-12-qual-$_"} ( 1 .. 12 ); |
|
|
144
|
|
|
|
|
251
|
|
|
61
|
12
|
|
|
|
|
18
|
my $color_idx = 0; |
|
62
|
|
|
|
|
|
|
|
|
63
|
12
|
100
|
|
|
|
21
|
if ( defined $opt->{highlight} ) { |
|
64
|
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
10
|
for my $part (@parts) { |
|
66
|
14
|
|
|
|
|
25
|
my $info = App::RL::Common::decode_header($part); |
|
67
|
14
|
50
|
|
|
|
1759
|
next unless App::RL::Common::info_is_valid($info); |
|
68
|
|
|
|
|
|
|
my $str = join( " ", |
|
69
|
|
|
|
|
|
|
$info->{chr}, $info->{start}, $info->{end}, |
|
70
|
14
|
|
|
|
|
309
|
"fill_color=" . $colors[$color_idx] ); |
|
71
|
14
|
|
|
|
|
205
|
push @lines, $str; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# rotate color |
|
75
|
6
|
|
|
|
|
8
|
$color_idx++; |
|
76
|
6
|
50
|
|
|
|
19
|
$color_idx = 0 if $color_idx > 11; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
6
|
|
|
|
|
12
|
for ( my $i = 0; $i <= $#parts; $i++ ) { |
|
80
|
14
|
|
|
|
|
40
|
PAIR: for ( my $j = $i + 1; $j <= $#parts; $j++ ) { |
|
81
|
10
|
|
|
|
|
11
|
my @fields; |
|
82
|
10
|
|
|
|
|
17
|
for ( $i, $j ) { |
|
83
|
20
|
|
|
|
|
201
|
my $info = App::RL::Common::decode_header( $parts[$_] ); |
|
84
|
|
|
|
|
|
|
next PAIR |
|
85
|
20
|
50
|
|
|
|
2151
|
unless App::RL::Common::info_is_valid($info); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
push @fields, |
|
88
|
|
|
|
|
|
|
( |
|
89
|
|
|
|
|
|
|
$info->{chr}, |
|
90
|
|
|
|
|
|
|
$info->{strand} eq "+" |
|
91
|
|
|
|
|
|
|
? ( $info->{start}, $info->{end} ) |
|
92
|
|
|
|
|
|
|
: ( $info->{end}, $info->{start} ) |
|
93
|
20
|
100
|
|
|
|
451
|
); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
10
|
|
|
|
|
189
|
my $str = join( " ", @fields ); |
|
96
|
10
|
|
|
|
|
35
|
push @lines, $str; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
2
|
|
|
|
|
10
|
@lines = List::MoreUtils::PP::uniq(@lines); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#----------------------------# |
|
105
|
|
|
|
|
|
|
# Output |
|
106
|
|
|
|
|
|
|
#----------------------------# |
|
107
|
2
|
|
|
|
|
63
|
my $out_fh; |
|
108
|
2
|
50
|
|
|
|
6
|
if ( lc( $opt->{outfile} ) eq "stdout" ) { |
|
109
|
2
|
|
|
|
|
5
|
$out_fh = \*STDOUT; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
else { |
|
112
|
0
|
|
|
|
|
0
|
open $out_fh, ">", $opt->{outfile}; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
2
|
|
|
|
|
5
|
print {$out_fh} "$_\n" for @lines; |
|
|
24
|
|
|
|
|
234
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
22
|
close $out_fh; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |