Bio-RNA-BarMap

 view release on metacpan or  search on metacpan

lib/Bio/RNA/BarMap/Mapping.pm  view on Meta::CPAN

package Bio::RNA::BarMap::Mapping;
our $VERSION = '0.04';

use 5.012;
use warnings;

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

use autodie qw(:all);
use Scalar::Util qw(reftype);
use List::Util qw(any);
use File::Spec;

use Bio::RNA::BarMap::Mapping::MinMappingEntry;
use Bio::RNA::BarMap::Mapping::FileMappingEntry;


# Hash mapping each minimum to the one it is mapped to in the next landscape.
has '_min_mapping' => (
    is       => 'ro',
    required => 1,
);

# Hash mapping barrier files to each other, i.e. bar1 -> bar2 iff BarMap
# mapped the minima from bar1 to the minima of bar2.
has '_file_mapping' => (
    is          => 'ro',
    init_arg    => undef,       # generated from list of mapped files
    lazy        => 1,
    builder     => '_build_file_mapping',
);

# Array for keeping the order.
has '_mapped_files' => (
    is       => 'ro',
    required => 1,
);

sub mapped_files { return @{ $_[0]->_mapped_files } }     # dereference

has 'file_name' => (
    is        => 'ro',
    predicate => 'has_file_name',
);

# The path builder is initialized with the path to this mapping's barmap
# file. Given another file name relative to the barmap, it constructs a
# path to this file from the current working directory. This is necessary
# because usually the bar files mentioned in the barmap file reside in the
# same directory and need to be prefixed with the same path.
has '_path_builder' => (
    is       => 'ro',
    init_arg => undef,
    lazy     => 1,
    builder  => '_build_path_builder',
);

# Returns a sub that builds file paths from given file names such that the
# files are in the same dir as the target file/dir given during
# construction.
# Args:
#   target_file: from this file or dir, the target dir will be inferred
# Returns: sub that builds a path from the given file name.
sub _build_path_builder {
    my $self = shift;
    confess 'File name attribute needs to be set to build any paths'
        unless $self->has_file_name;



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