Bio-Community

 view release on metacpan or  search on metacpan

lib/Bio/Community/Types.pm  view on Meta::CPAN

# BioPerl module for Bio::Community::Types
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Copyright 2011-2014 Florent Angly <florent.angly@gmail.com>
#
# You may distribute this module under the same terms as perl itself


=head1 NAME

Bio::Community::Types - Data type definitions

=head1 DESCRIPTION

This module defines useful data types for use in Moose-based modules.

=head1 AUTHOR

Florent Angly L<florent.angly@gmail.com>

=head1 SUPPORT AND BUGS

User feedback is an integral part of the evolution of this and other Bioperl
modules. Please direct usage questions or support issues to the mailing list, 
L<bioperl-l@bioperl.org>, rather than to the module maintainer directly. Many
experienced and reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem with code and
data examples if at all possible.

If you have found a bug, please report it on the BioPerl bug tracking system
to help us keep track the bugs and their resolution:
L<https://redmine.open-bio.org/projects/bioperl/>

=head1 COPYRIGHT

Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.1 or,
at your option, any later version of Perl 5 you may have available.

=cut


package Bio::Community::Types;

use Moose;
use Moose::Util::TypeConstraints;
use Method::Signatures;
use namespace::autoclean;


# Numbers

subtype 'PositiveNum'
   => as 'Num'
   => where { $_ >= 0 }
   => message { _gen_err_msg('a positive number', $_) };


subtype 'StrictlyPositiveNum'
   => as 'PositiveNum'
   => where { $_ > 0 }
   => message { _gen_err_msg('a strictly positive number', $_) };


subtype 'PositiveInt'
   => as 'Int'
   => where { $_ >= 0 }
   => message { _gen_err_msg('a positive integer', $_) };


subtype 'StrictlyPositiveInt'
   => as 'PositiveInt'
   => where { $_ > 0 }
   => message { _gen_err_msg('a strictly positive integer', $_) };


# A Count should be a positive integer. Sometimes, however, we only have access
# to the relative abundance (a float), and use it as a proxy for a count.
subtype 'Count'
   => as 'PositiveNum';


# Number of ticks (at least three)
subtype 'NumTicks'
   => as 'PositiveNum'
   => where { $_ > 2 }
   => message { _gen_err_msg('an integer greater than two', $_) };


# Sort numerically
subtype 'NumericSort'
   => as enum( [ qw(-1 0 1) ] )
   => message { _gen_err_msg('0 (off), 1 (increasing) or -1 (decreasing)', $_) };


# Abundance representation
my @AbundanceRepr = qw(count absolute percentage fraction);
subtype 'AbundanceRepr'
   => as enum( \@AbundanceRepr )
   => message { _gen_err_msg(\@AbundanceRepr, $_) };


# Rank: a strictly positive integer
subtype 'AbundanceRank'
   => as 'StrictlyPositiveInt';


# Type of distance



( run in 1.148 second using v1.01-cache-2.11-cpan-39bf76dae61 )