| 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
| |||||||||||||||
| 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() // {}
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||
| 43 | |||||||||||||||
| 44 | 0 | ▶ | my $greedy = $args->{greedy} // 0; | ||||||||||||
|
Condition0%0/2
$args->{"greedy"} // 0
MC/DC0%0/1
$args->{"greedy"} // 0
$args->{"greedy"}
Truth table0%0/2
A
A= $args->{"greedy"}
| |||||||||||||||
| 45 | |||||||||||||||
| 46 | 0 | my @lineage = $self->tax->fetch_lineage($seq_id); | |||||||||||||
| 47 | 0 | ▶ | while (my $taxon = $greedy ? shift @lineage : pop @lineage) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 48 | 0 | ▶ | return $taxon if $self->is_a_label($taxon); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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__ | ||||||||||||||