Bio-RNA-BarMap
view release on metacpan or search on metacpan
lib/Bio/RNA/BarMap/Mapping/MinMappingEntry.pm view on Meta::CPAN
# Bio/RNA/BarMap/Mapping/MinMappingEntry.pm
package Bio::RNA::BarMap::Mapping::MinMappingEntry;
our $VERSION = '0.04';
use 5.012;
use warnings;
use Moose;
use namespace::autoclean;
use Scalar::Util qw( weaken );
use Bio::RNA::BarMap::Mapping::Type;
use Bio::RNA::BarMap::Mapping::Set;
has 'index' => (is => 'ro', required => 1);
has 'to_type' => (
is => 'rw',
isa => 'Bio::RNA::BarMap::Mapping::Type',
);
# Ensure object is cleaned after use => use weak refs
has '_from' => (
is => 'ro',
init_arg => undef, # use add_from() method to add elements
default => sub { Bio::RNA::BarMap::Mapping::Set->new },
);
has 'to' => (
is => 'rw',
weak_ref => 1,
predicate => 'has_to',
isa => __PACKAGE__, # another entry
);
# Always use this method to add 'from' minima. This ensures the refs
# are weakened and no memory leaks arise.
sub add_from {
my ($self, @from) = @_;
weaken $_ foreach @from; # turn into weak references
$self->_from->insert(@from);
}
sub get_from {
my ($self) = @_;
my @from = $self->_from->elements;
return @from;
}
__PACKAGE__->meta->make_immutable;
1; # End of Bio::RNA::BarMap::Mapping::MinMappingEntry
__END__
=pod
=encoding UTF-8
=head1 NAME
Bio::RNA::BarMap::Mapping::MinMappingEntry - Store I<BarMap> mappings of a
single minimum.
=head1 SYNOPSIS
( run in 0.720 second using v1.01-cache-2.11-cpan-39bf76dae61 )