| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | while ( my ( $k, $v ) = each %$data ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | push @m, [ $k, ( ref $v eq 'ARRAY' ? @$v : $v ) ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$m and @$m > 0
MC/DC0%0/2
$m and @$m > 0
$m
@$m > 0
Truth table33%1/3
A and B
A= $mB= @$m > 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my @preview; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if ( ref $m->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | if ( @$m >= 6 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
$c->{"dots"} and @$m > 6 or $c->{"force_dots"}
$c->{"dots"} and @$m > 6
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | push @preview, @{$m}[ 0 .. 2 ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | push @preview, '...' if(($c->{dots} && @$m > 6) || $c->{force_dots}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$c->{"dots"} and @$m > 6 or $c->{"force_dots"}
$c->{"dots"} and @$m > 6
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||||||