Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/AssemblyMapper.pm view on Meta::CPAN
=cut
=head1 NAME
Bio::EnsEMBL::AssemblyMapper -
Handles mapping between two coordinate systems using the information
stored in the assembly table.
=head1 SYNOPSIS
$db = Bio::EnsEMBL::DBSQL::DBAdaptor->new(...);
$asma = $db->get_AssemblyMapperAdaptor();
$csa = $db->get_CoordSystemAdaptor();
my $chr_cs = $cs_adaptor->fetch_by_name( 'chromosome', 'NCBI33' );
my $ctg_cs = $cs_adaptor->fetch_by_name('contig');
$asm_mapper = $map_adaptor->fetch_by_CoordSystems( $cs1, $cs2 );
# Map to contig coordinate system from chromosomal.
@ctg_coords =
$asm_mapper->map( 'X', 1_000_000, 2_000_000, 1, $chr_cs );
# Map to chromosome coordinate system from contig.
@chr_coords =
$asm_mapper->map( 'AL30421.1.200.92341', 100, 10000, -1,
$ctg_cs );
# List contig names for a region of chromsome.
@ctg_ids = $asm_mapper->list_ids( '13', 1_000_000, 1, $chr_cs );
# List chromosome names for a contig region.
@chr_ids =
$asm_mapper->list_ids( 'AL30421.1.200.92341', 1, 1000, -1,
$ctg_cs );
=head1 DESCRIPTION
The AssemblyMapper is a database aware mapper which faciliates
conversion of coordinates between any two coordinate systems with an
relationship explicitly defined in the assembly table. In the future
it may be possible to perform multiple step (implicit) mapping between
coordinate systems.
It is implemented using the Bio::EnsEMBL::Mapper object, which is a
generic mapper object between disjoint coordinate systems.
=head1 METHODS
=cut
package Bio::EnsEMBL::AssemblyMapper;
$Bio::EnsEMBL::AssemblyMapper::VERSION = '114.0.0';
use strict;
use warnings;
use Bio::EnsEMBL::Mapper;
use Bio::EnsEMBL::Utils::Exception qw(throw);
use Scalar::Util qw(weaken);
use Bio::EnsEMBL::Utils::Scalar qw( check_ref);
my $ASSEMBLED = 'assembled';
my $COMPONENT = 'component';
my $DEFAULT_MAX_PAIR_COUNT = 1000;
=head2 new
Arg [1] : Bio::EnsEMBL::DBSQL::AssemblyMapperAdaptor
Arg [2] : Bio::EnsEMBL::CoordSystem $asm_cs
Arg [3] : Bio::EnsEMBL::CoordSystem $cmp_cs
Example : Should use AssemblyMapperAdaptor->fetch_by_CoordSystems()
Description: Creates a new AssemblyMapper
Returntype : Bio::EnsEMBL::DBSQL::AssemblyMapperAdaptor
Exceptions : Throws if multiple coord_systems are provided
Caller : AssemblyMapperAdaptor
Status : Stable
=cut
sub new {
my ( $proto, $adaptor, @coord_systems ) = @_;
my $class = ref($proto) || $proto;
my $self = bless( {}, $class );
$self->adaptor($adaptor);
$adaptor->cache_seq_ids_with_mult_assemblys();
if ( @coord_systems != 2 ) {
throw( 'Can only map between two coordinate systems. '
. scalar(@coord_systems)
. ' were provided' );
}
# Set the component and assembled coordinate systems
$self->{'asm_cs'} = $coord_systems[0];
$self->{'cmp_cs'} = $coord_systems[1];
# We load the mapper calling the 'ASSEMBLED' the 'from' coord system
# and the 'COMPONENT' the 'to' coord system.
$self->{'mapper'} = Bio::EnsEMBL::Mapper->new( $ASSEMBLED, $COMPONENT,
$coord_systems[0], $coord_systems[1] );
$self->{'max_pair_count'} = $DEFAULT_MAX_PAIR_COUNT;
return $self;
} ## end sub new
=head2 max_pair_count
Arg [1] : (optional) int $max_pair_count
Example : $mapper->max_pair_count(100000)
Description: Getter/Setter for the number of mapping pairs allowed
in the internal cache. This can be used to override
lib/Bio/EnsEMBL/AssemblyMapper.pm view on Meta::CPAN
sub mapper {
my ($self) = @_;
return $self->{'mapper'};
}
=head2 assembled_CoordSystem
Arg [1] : None
Example : $cs = $asm_mapper->assembled_CoordSystem();
Description: Retrieves the assembled CoordSystem from this
assembly mapper.
Return type: Bio::EnsEMBL::CoordSystem
Exceptions : None
Caller : Internal, AssemblyMapperAdaptor
Status : Stable
=cut
sub assembled_CoordSystem {
my ($self) = @_;
return $self->{'asm_cs'};
}
=head2 component_CoordSystem
Arg [1] : None
Example : $cs = $asm_mapper->component_CoordSystem();
Description: Retrieves the component CoordSystem from this
assembly mapper.
Return type: Bio::EnsEMBL::CoordSystem
Exceptions : None
Caller : Internal, AssemblyMapperAdaptor
Status : Stable
=cut
sub component_CoordSystem {
my ($self) = @_;
return $self->{'cmp_cs'};
}
=head2 adaptor
Arg [1] : Bio::EnsEMBL::DBSQL::AssemblyMapperAdaptor $adaptor
Description: Getter/set terfor this object's database adaptor.
Returntype : Bio::EnsEMBL::DBSQL::AssemblyMapperAdaptor
Exceptions : None
Caller : General
Status : Stable
=cut
sub adaptor {
my ( $self, $value ) = @_;
if ( defined($value) ) {
weaken($self->{'adaptor'} = $value);
}
return $self->{'adaptor'};
}
1;
( run in 1.136 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )