Bio-MUST-Core

 view release on metacpan or  search on metacpan

lib/Bio/MUST/Core/SeqMask/Freqs.pm  view on Meta::CPAN

package Bio::MUST::Core::SeqMask::Freqs;
# ABSTRACT: Arbitrary frequencies for sequence sites
$Bio::MUST::Core::SeqMask::Freqs::VERSION = '0.252040';
use Moose;
use namespace::autoclean;

use autodie;
use feature qw(say);

use Const::Fast;
use List::AllUtils qw(sum);

use Bio::MUST::Core::Types;
use aliased 'Bio::MUST::Core::SeqMask::Rates';


# public hash containing freqs by sequence and site
# Note: this hash is actually a Tie::IxHash (see Profiles)
has 'freq_for_at' => (
    traits   => ['Hash'],
    is       => 'ro',
    isa      => 'HashRef[ArrayRef[Num]]',
    required => 1,
    handles  => {
        count_freqs_at     => 'count',
          all_freqs_at     => 'values',
              freqs_at_for => 'get',
          all_ids          => 'keys',
    },
);


# private SeqMask::Rates-like object derived by averaging freqs over seqs
has '_mask' => (
    is       => 'ro',
    isa      => 'Bio::MUST::Core::SeqMask::Rates',
    init_arg => undef,
    lazy     => 1,
    builder  => '_build_mask',
    handles  => {
       mask_len         => 'mask_len',
        all_freqs       =>  'all_states',
        min_freq        =>  'min_rate',
        max_freq        =>  'max_rate',
        bin_freqs_masks =>  'bin_rates_masks',
            freqs_mask  =>      'rates_mask',
    },
);


# private hash containing freqs averaged over sites
has '_avg_freq_for' => (
    traits   => ['Hash'],
    is       => 'ro',
    isa      => 'HashRef[Num]',
    init_arg => undef,
    lazy     => 1,
    builder  => '_build_avg_freq_for',
    handles  => {
        avg_freq_for => 'get',
    },
);

const my $PREC => 3;



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