lib/Bio/MUST/Core/SeqMask/Weights.pm

filter: Statementstmt 50.9% 26 / 51 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 77.7% 7 / 9 Podpod 100% 2 / 2 totaltotal 36.4% 35 / 96 CC 14 SCAR 37.9
CC
14
Cov
35%
bootstrap_masks
72.0
jackknife_masks
56.0
BEGIN
1.0
CRAP 44.3
« lib/Bio/MUST/Core/Taxonomy.pm ↑ Summary lib/Bio/MUST/Core/Tree.pm »
1 package Bio::MUST::Core::SeqMask::Weights;
2 # ABSTRACT: Random weights for resampling sequence sites
3 18 $Bio::MUST::Core::SeqMask::Weights::VERSION = '0.252040';
4 18 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use feature qw(say);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # use Smart::Comments;
11  
12 18 ▶use List::AllUtils qw(sample);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 18 extends 'Bio::MUST::Core::SeqMask';
16  
17 18 ▶use Bio::MUST::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 # override superclass' Bool type
21 # Note: mask indices are as follow: [site]
22 # mask values are integer weights (>= 0)
23 18 has '+mask' => (
24 isa => 'ArrayRef[Int]',
25 );
26  
27 # TODO: mask non-applicable methods from superclass? (Liskov principle)
28  
29  
30  
31 0 ▶sub bootstrap_masks {
Subroutine bootstrap_masks: not called CC=8 SCAR=42.8
Pod documented
32 0 my $class = shift;
33 0 my $ali = shift;
34 0 ▶ my $args = shift // {}; # HashRef (should not be empty...)
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
35  
36 0 ▶ my $rep_n = $args->{rep} // 100;
Condition0%0/2
$args->{"rep"} // 100
l!l
00
MC/DC0%0/1
$args->{"rep"} // 100
$args->{"rep"}
Truth table0%0/2
A
A= $args->{"rep"}
Aresult
11
00
37 0 my $width = $ali->width;
38 0 ▶ my $k = $args->{width} // $width;
Condition0%0/3
$args->{"width"} // $width
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"width"} // $width
$args->{"width"} $width
Truth table0%0/3
A // B
A= $args->{"width"}B= $width
ABresult
1X1
011
000
39  
40 # convert fractional len to conservative integer (if needed)
41 0 ▶ $k = ceil($k * $width) if 0 < $k && $k <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if 0 < $k and $k <= 1 0 0 0
Condition0%0/3
0 < $k and $k <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
0 < $k and $k <= 1
0 < $k $k <= 1
Truth table0%0/3
A and B
A= 0 < $kB= $k <= 1
ABresult
0X0
100
111
42  
43 0 my @masks;
44  
45 0 for my $i (1..$rep_n) {
46 0 my @weights = (0) x $width;
47 0 $weights[ int(rand $width) ]++ for 1..$k; # bootstrap sites
48 0 push @masks, $class->new( mask => \@weights );
49 }
50  
51 0 return @masks;
52 }
53  
54  
55  
56 0 ▶sub jackknife_masks {
Subroutine jackknife_masks: not called CC=7 SCAR=40.3
Pod documented
57 0 my $class = shift;
58 0 my $ali = shift;
59 0 ▶ my $args = shift // {}; # HashRef (should not be empty...)
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
60  
61 0 ▶ my $rep_n = $args->{rep} // 100;
Condition0%0/2
$args->{"rep"} // 100
l!l
00
MC/DC0%0/1
$args->{"rep"} // 100
$args->{"rep"}
Truth table0%0/2
A
A= $args->{"rep"}
Aresult
11
00
62 0 my $width = $ali->width;
63 0 ▶ my $k = $args->{width} // 0.5;
Condition0%0/2
$args->{"width"} // "0.5"
l!l
00
MC/DC0%0/1
$args->{"width"} // "0.5"
$args->{"width"}
Truth table0%0/2
A
A= $args->{"width"}
Aresult
11
00
64  
65 # convert fractional len to conservative integer (if needed)
66 0 ▶ $k = ceil($k * $width) if 0 < $k && $k <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if 0 < $k and $k <= 1 0 0 0
Condition0%0/3
0 < $k and $k <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
0 < $k and $k <= 1
0 < $k $k <= 1
Truth table0%0/3
A and B
A= 0 < $kB= $k <= 1
ABresult
0X0
100
111
67  
68 0 my @masks;
69  
70 0 for my $i (1..$rep_n) {
71 0 my @sites = sample $k, (0..$width-1); # jackknife sites
72 0 push @masks, $class->custom_mask($width, \@sites);
73 }
74  
75 0 return @masks;
76 }
77  
78 18 __PACKAGE__->meta->make_immutable;
79 18 1;
80  
81 __END__
« lib/Bio/MUST/Core/Taxonomy.pm ↑ Summary lib/Bio/MUST/Core/Tree.pm »