lib/Bio/MUST/Core/Taxonomy/Labeler.pm

filter: Statementstmt 58.6% 17 / 29 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 43.1% 22 / 51 CC 8 SCAR 31.1
CC
8
Cov
41%
classify
42.0
BUILD
12.0
BEGIN
1.0
CRAP 22.5
« lib/Bio/MUST/Core/Tree.pm ↑ Summary lib/Bio/MUST/Core/SeqMask.pm »
1 package Bio::MUST::Core::Taxonomy::Labeler;
2 # ABSTRACT: Helper class for simple labeler based on taxonomy
3 18 $Bio::MUST::Core::Taxonomy::Labeler::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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 ▶use Bio::MUST::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 with 'Bio::MUST::Core::Roles::Taxable';
11  
12  
13 18 has 'labels' => (
14 is => 'ro',
15 isa => 'Bio::MUST::Core::IdList',
16 required => 1,
17 coerce => 1,
18 handles => {
19 all_labels => 'all_ids',
20 is_a_label => 'is_listed',
21 },
22 );
23  
24  
25 0 ▶sub BUILD {
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod undocumented
26 0 my $self = shift;
27  
28 # warn in case of ambiguous taxa
29 0 for my $taxon ( $self->all_labels ) {
30 0 ▶ carp "[BMC] Warning: $taxon is taxonomically ambiguous in labeler!"
Branch: 1 branch
BranchTrueFalseTotal
if $self->tax->is_dupe($taxon) 0 0 0
31 if $self->tax->is_dupe($taxon);
32 }
33  
34 0 return;
35 }
36  
37  
38  
39 0 ▶sub classify {
Subroutine classify: not called CC=6 SCAR=37.4
Pod documented
40 0 my $self = shift;
41 0 my $seq_id = shift;
42 0 ▶ my $args = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
43  
44 0 ▶ my $greedy = $args->{greedy} // 0;
Condition0%0/2
$args->{"greedy"} // 0
l!l
00
MC/DC0%0/1
$args->{"greedy"} // 0
$args->{"greedy"}
Truth table0%0/2
A
A= $args->{"greedy"}
Aresult
11
00
45  
46 0 my @lineage = $self->tax->fetch_lineage($seq_id);
47 0 ▶ while (my $taxon = $greedy ? shift @lineage : pop @lineage) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $taxon = $greedy ? shift @lineage : pop @lineage) 0 0 0
$greedy ? : 0 0 0
48 0 ▶ return $taxon if $self->is_a_label($taxon);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_a_label($taxon) 0 0 0
49 }
50  
51 # return undef if no suitable taxon
52 0 return;
53 }
54  
55 18 __PACKAGE__->meta->make_immutable;
56 18 1;
57  
58 __END__
« lib/Bio/MUST/Core/Tree.pm ↑ Summary lib/Bio/MUST/Core/SeqMask.pm »