Bio-Community

 view release on metacpan or  search on metacpan

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

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
my @DistanceType = qw(1-norm 2-norm euclidean p-norm infinity-norm hellinger
                      bray-curtis morisita-horn jaccard sorensen
                      shared permuted maxiphi unifrac);
subtype 'DistanceType'
   => as enum( \@DistanceType )
   => message { _gen_err_msg(\@DistanceType, $_) };


# Type of alpha diversity
my @AlphaType = qw(
   observed  menhinick   chao1  margalef   ace       jack1     jack2
   shannon_e brillouin_e hill_e mcintosh_e simpson_e buzas     heip  camargo
   shannon   brillouin   hill   mcintosh   simpson   simpson_r
   simpson_d berger
);
subtype 'AlphaType'
   => as enum( \@AlphaType )
   => message { _gen_err_msg(\@AlphaType, $_) };


# Type of gamma diversity
my @GammaType = ( qw(
      chao2 jack1_i jack2_i ice
   ), @AlphaType
);
subtype 'GammaType'
   => as enum( \@GammaType )
   => message { _gen_err_msg(\@GammaType, $_) };


# Type of transformation
my @TransformationType = qw(identity binary relative hellinger chord);
subtype 'TransformationType'
   => as enum( \@TransformationType )
   => message { _gen_err_msg(\@TransformationType, $_) };


# Type of accumulation curve
my @AccumulationType = qw(rarefaction collector);
subtype 'AccumulationType'
   => as enum( \@AccumulationType )
   => message { _gen_err_msg(\@AccumulationType, $_) };


# Type of spacing
my @SpacingType = qw(linear logarithmic);
subtype 'SpacingType'
   => as enum( \@SpacingType )
   => message { _gen_err_msg(\@SpacingType, $_) };



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