Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/MappedSlice.pm view on Meta::CPAN
Not currently supported but maybe should/could:
calculate_pi
calculate_theta
get_base_count
get_by_Individual
get_by_strain
invert
Internally, a MappedSlice is a collection of Bio::EnsEMBL::Slices and
associated Bio::EnsEMBL::Mappers which map the slices to the common
container coordinate system.
MappedSlices are usually created and attached to a MappedSliceContainer
by an adaptor/factory.
=head1 METHODS
new
add_Slice_Mapper_pair
get_all_Slice_Mapper_pairs
adaptor
container
name
seq_region_name
start
end
strand
length
seq_region_length
centrepoint
coord_system
coord_system_name
is_toplevel
seq (not implemented yet)
subseq (not implemented yet)
get_repeatmasked_seq (not implemented yet)
sub_MappedSlice (not implemented yet)
project (not implemented yet)
=head1 RELATED MODULES
Bio::EnsEMBL::MappedSlice
Bio::EnsEMBL::DBSQL::AssemblySliceAdaptor
Bio::EnsEMBL::Compara::AlignSlice
Bio::EnsEMBL::Compara::AlignSlice::Slice
Bio::EnsEMBL::StrainSlice
=cut
package Bio::EnsEMBL::MappedSlice;
$Bio::EnsEMBL::MappedSlice::VERSION = '114.0.0';
use strict;
use warnings;
no warnings 'uninitialized';
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use Bio::EnsEMBL::Mapper;
use Scalar::Util qw(weaken);
use vars qw($AUTOLOAD);
=head2 new
Arg [ADAPTOR] : Adaptor $adaptor - an adaptor of the appropriate type
Arg [CONTAINER] : Bio::EnsEMBL::MappedSliceContainer $container - the
container this MappedSlice is attached to
Arg [NAME] : String $name - name
Example : my $mapped_slice = Bio::EnsEMBL::MappedSlice->new(
-ADAPTOR => $adaptor,
-CONTAINER => $container,
-NAME => $name,
);
Description : Constructor. Usually you won't call this method manually, but
the MappedSlice will be constructed by an adaptor/factory.
Return type : Bio::EnsEMBL::MappedSlice
Exceptions : thrown on wrong or missing arguments
Caller : general, MappedSlice adaptors
Status : At Risk
: under development
=cut
sub new {
my $caller = shift;
my $class = ref($caller) || $caller;
my ($adaptor, $container, $name) =
rearrange([qw(ADAPTOR CONTAINER NAME)], @_);
# arguement check
unless ($container and ref($container) and
$container->isa('Bio::EnsEMBL::MappedSliceContainer')) {
throw("Need a MappedSliceContainer.");
}
my $self = {};
bless ($self, $class);
#
# initialise object
#
# need to weaken reference to prevent circular reference
weaken($self->{'container'} = $container);
$self->adaptor($adaptor) if (defined($adaptor));
$self->{'name'} = $name if (defined($name));
$self->{'slice_mapper_pairs'} = [];
return $self;
}
=head2 add_Slice_Mapper_pair
Arg[1] : Bio::EnsEMBL::Slice $slice - slice to add
Arg[2] : Bio::EnsEMBL::Mapper $mapper - the mapper for this slice
Example : $mapped_slice->add_Slice_Mapper_pair($slice, $mapper);
Description : Adds a native slice and a corresponding mapper to map to/from
the artificial container coord system.
Return type : listref of Bio::EnsEMBL::MappedSlice
Exceptions : thrown on wrong or missing arguments
Caller : general, MappedSlice adaptors
Status : At Risk
: under development
=cut
sub add_Slice_Mapper_pair {
my $self = shift;
my $slice = shift;
my $mapper = shift;
# argument check
unless ($slice and ref($slice) and ($slice->isa('Bio::EnsEMBL::Slice') or $slice->isa('Bio::EnsEMBL::LRGSlice')) ) {
throw("You must provide a slice.");
}
unless ($mapper and ref($mapper) and $mapper->isa('Bio::EnsEMBL::Mapper')) {
throw("You must provide a mapper.");
}
push @{ $self->{'slice_mapper_pairs'} }, [ $slice, $mapper ];
return $self->{'slice_mapper_pairs'};
}
=head2 get_all_Slice_Mapper_pairs
Example : foreach my $pair (@{ $self->get_all_Slice_Mapper_pairs }) {
my ($slice, $mapper) = @$pair;
# get container coordinates
my @coords = $mapper->map_coordinates(
$slice->seq_region_name,
$slice->start,
$slice->end,
$slice->strand,
'mapped_slice'
);
# ....
}
Description : Gets all Slice/Mapper pairs this MappedSlice is composed of.
Each slice (and features on it) can be mapped onto the
artificial container coord system using the mapper.
Return type : listref of listref of a Bio::EnsEMBL::Slice and
Bio::EnsEMBL::Mapper pair
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub get_all_Slice_Mapper_pairs {
my $self = shift;
return $self->{'slice_mapper_pairs'};
}
=head2 adaptor
Arg[1] : (optional) Adaptor $adaptor - the adaptor/factory for this
object
Example : $mapped_slice->adaptor($assembly_slice_adaptor);
Description : Getter/setter for the adaptor/factory for this object.
Return type : Adaptor of appropriate type
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub adaptor {
my $self = shift;
weaken($self->{'adaptor'} = shift) if (@_);
return $self->{'adaptor'};
}
=head2 container
Arg[1] : (optional) Bio::EnsEMBL::MappedSliceContainer - the container
this object is attached to
Example : my $container = $mapped_slice->container;
print $container->ref_slice->name, "\n";
Description : Getter/setter for the container this object is attached to. The
container will give you access to the reference slice, a common
artificial container slice, and a mapper to map to it from the
container coord system.
The implementation uses a weak reference to attach the container
since the container holds a list of MappedSlices itself.
Return type : Bio::EnsEMBL::MappedSliceContainer
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub container {
my $self = shift;
weaken($self->{'container'} = shift) if (@_);
return $self->{'container'};
}
=head2 name
Arg[1] : String - the name of this object
Example : my $name = $mapped_slice->container->ref_slice->name .
":mapped_" . $ident_string;
$mapped_slice->name($name);
Description : Getter/setter for this object's name
Return type : String
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub name {
my $self = shift;
$self->{'name'} = shift if (@_);
return $self->{'name'};
}
=head2 seq_region_name
Example : my $sr_name = $mapped_slice->seq_region_name;
Description : Returns the seq_region name of the reference slice.
Return type : String
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub seq_region_name {
my $self = shift;
return $self->container->ref_slice->seq_region_name;
}
=head2 start
Example : my $start = $mapped_slice->start;
Description : Returns the start of the container slice.
Return type : Int
Exceptions : none
Caller : general
Status : At Risk
: under development
=cut
sub start {
my $self = shift;
return $self->container->container_slice->start;
}
( run in 1.355 second using v1.01-cache-2.11-cpan-98e64b0badf )