blib/lib/Bio/Gonzales/Matrix/Util.pm

filter: Statementstmt 57.1% 32 / 56 Branchbran 22.2% 4 / 18 Conditioncond 20.0% 3 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 4 totaltotal 40.9% 45 / 110 CC 15 SCAR 32.6
CC
15
Cov
44%
preview
42.4
as_matrix
20.0
uniq_rows
2.0
CRAP 26.0
« blib/lib/Bio/Gonzales/Feat/IO/MUM.pm ↑ Summary blib/lib/Bio/Gonzales/Seq/Validate/fasta.pm »
1 package Bio::Gonzales::Matrix::Util;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 our ( @EXPORT, @EXPORT_OK, %EXPORT_TAGS );
11 5 our $VERSION = '0.058'; # VERSION
12  
13 5 @EXPORT = qw();
14 5 %EXPORT_TAGS = ();
15 5 @EXPORT_OK = qw(uniq_rows uniq_rows_secure as_matrix preview);
16  
17 sub uniq_rows {
18 0 ▶ my $matrix = shift;
Subroutine uniq_rows: not called CC=1 SCAR=6.9
Pod undocumented
19  
20 # http://www.perlmonks.org/?node_id=489796
21  
22 # relaxed
23 0 my %seen;
24 0 my @umatrix = grep { not $seen{ join $;, @$_ }++ } @$matrix;
25  
26 0 return \@umatrix;
27 }
28  
29 sub uniq_rows_secure {
30 0 ▶ my $matrix = shift;
Subroutine uniq_rows_secure: not called CC=1 SCAR=6.9
Pod undocumented
31  
32 # http://www.perlmonks.org/?node_id=489796
33  
34 0 my %seen;
35 0 my @umatrix = grep { not $seen{ join " ", map quotemeta, @$_ }++ } @$matrix;
36  
37 0 return \@umatrix;
38 }
39  
40 sub as_matrix {
41 0 ▶ my $data = shift;
Subroutine as_matrix: not called CC=4 SCAR=30.0
Pod undocumented
42 0 my @m;
43 0 ▶ if ( ref $data eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "HASH") 0 0 0
44 0 ▶ while ( my ( $k, $v ) = each %$data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$data) 0 0 0
45 0 ▶ push @m, [ $k, ( ref $v eq 'ARRAY' ? @$v : $v ) ];
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'ARRAY' ? : 0 0 0
46 }
47 }
48 0 return \@m;
49 }
50  
51 sub preview {
52 1 ▶ my ($m, $c) = @_;
Subroutine preview: called CC=12 SCAR=37.5
Pod undocumented
53  
54 1 ▶ return unless ( $m && @$m > 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless $m and @$m > 0 0 1 1
Condition33%1/3
$m and @$m > 0
!ll&&!rl&&r
001
MC/DC0%0/2
$m and @$m > 0
$m @$m > 0
Truth table33%1/3
A and B
A= $mB= @$m > 0
ABresult
0X0
100
111
55 1 my @preview;
56 1 ▶ if ( ref $m->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $m->[0]) { } 1 0 1
57 1 ▶ if ( @$m >= 6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$m >= 6) { } 1 0 1
58 1 push @preview, @{$m}[ 0 .. 2 ];
59 1 ▶ push @preview, [("...") x scalar @{ $m->[0] }] if(($c->{dots} && @$m > 6) || $c->{force_dots});
Branch: 1 branch
BranchTrueFalseTotal
if $c->{"dots"} and @$m > 6 or $c->{"force_dots"} 1 0 1
Condition33%2/6
$c->{"dots"} and @$m > 6 or $c->{"force_dots"}
l!l&&r!l&&!r
100
$c->{"dots"} and @$m > 6
!ll&&!rl&&r
001
MC/DC0%0/3
$c->{"dots"} and @$m > 6 or $c->{"force_dots"}
$c->{"dots"} @$m > 6 $c->{"force_dots"}
Truth table20%1/5
A and B or C
A= $c->{"dots"}B= @$m > 6C= $c->{"force_dots"}
ABCresult
11X1
0X11
1011
0X00
1000
60 1 push @preview, @{$m}[ -3, -2, -1 ];
61 } else {
62 0 @preview = @$m;
63 }
64 } else {
65 0 ▶ if ( @$m >= 6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$m >= 6) { } 0 0 0
66 0 push @preview, @{$m}[ 0 .. 2 ];
67
68 0 ▶ push @preview, '...' if(($c->{dots} && @$m > 6) || $c->{force_dots});
Branch: 1 branch
BranchTrueFalseTotal
if $c->{"dots"} and @$m > 6 or $c->{"force_dots"} 0 0 0
Condition0%0/6
$c->{"dots"} and @$m > 6 or $c->{"force_dots"}
l!l&&r!l&&!r
000
$c->{"dots"} and @$m > 6
!ll&&!rl&&r
000
MC/DC0%0/3
$c->{"dots"} and @$m > 6 or $c->{"force_dots"}
$c->{"dots"} @$m > 6 $c->{"force_dots"}
Truth table0%0/5
A and B or C
A= $c->{"dots"}B= @$m > 6C= $c->{"force_dots"}
ABCresult
11X1
0X11
1011
0X00
1000
69
70 0 push @preview, @{$m}[ -3, -2, -1 ];
71 } else {
72 0 @preview = @$m;
73 }
74 }
75 1 return \@preview;
76  
77 }
78  
79 5 1;
« blib/lib/Bio/Gonzales/Feat/IO/MUM.pm ↑ Summary blib/lib/Bio/Gonzales/Seq/Validate/fasta.pm »