Bio-MUST-Core
view release on metacpan or search on metacpan
lib/Bio/MUST/Core/Taxonomy/Category.pm view on Meta::CPAN
package Bio::MUST::Core::Taxonomy::Category;
# ABSTRACT: Helper class for multiple-criterion classifier based on taxonomy
$Bio::MUST::Core::Taxonomy::Category::VERSION = '0.252040';
use Moose;
use namespace::autoclean;
use Bio::MUST::Core::Types;
has 'label' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'description' => (
is => 'ro',
isa => 'Str',
default => 'no description',
);
has 'criteria' => (
traits => ['Array'],
is => 'ro',
isa => 'ArrayRef[Bio::MUST::Core::Taxonomy::Criterion]',
required => 1,
handles => {
all_criteria => 'elements',
},
);
sub matches {
my $self = shift;
my $listable = shift;
# loop through criteria and fail on the first one not matching input
# this means that the multiple criteria are linked by logical ANDs
for my $criterion ($self->all_criteria) {
return 0 unless $criterion->matches($listable);
}
# return success
return 1;
}
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=head1 NAME
Bio::MUST::Core::Taxonomy::Category - Helper class for multiple-criterion classifier based on taxonomy
=head1 VERSION
version 0.252040
=head1 SYNOPSIS
( run in 0.920 second using v1.01-cache-2.11-cpan-39bf76dae61 )