Bio-RNA-Treekin

 view release on metacpan or  search on metacpan

lib/Bio/RNA/Treekin/PopulationDataRecord.pm  view on Meta::CPAN

# Bio/RNA/Treekin/PopulationDataRecord.pm
package Bio::RNA::Treekin::PopulationDataRecord;
our $VERSION = '0.05';

use 5.006;
use strict;
use warnings;

use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;

use autodie qw(:all);
use Scalar::Util qw(reftype looks_like_number);
use   List::Util qw(max all);

use overload '""' => \&stringify;

has 'time'  => (is => 'ro', required => 1);

has '_populations' => (
    is       => 'ro',
    required => 1,
    init_arg => 'populations',
);

# Return a deep copy of this object.
sub clone {
    my $self = shift;
    my $clone = __PACKAGE__->new(
        time        => $self->time,
        populations => [ $self->populations ],
    );
    return $clone;
}

# Return number of minima for which there is population data.
sub min_count {
    my $self = shift;
    my $min_count = @{ $self->_populations };   # number of data points

    return $min_count;
}

# Use to adjust the min count, e.g. when the passed data array was
# constructed before the number of minima was known. It may not be
# shrinked as data might be lost.
sub set_min_count {
    my ($self, $new_min_count) = @_;

    my $current_min_count = @{ $self->_populations };
    confess 'Can only increase min_count'
        if  $current_min_count > $new_min_count;

    # Set additional states to population of 0.
    for my $i ( $current_min_count..($new_min_count-1) ) {
        $self->_populations->[$i] = 0.;
    }

    return;
}

# Return populations of all mins. Use of_min() instead to get the
# population of a specific min.
# Returns a list of all minima's populations.
sub populations {
    my $self = shift;
    return @{ $self->_populations };
}

# Get population for the given minimum.



( run in 2.967 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )