Bio::EnsEMBL::Compara
GenomicAlignGroup
Toolbar
Summary
Bio::EnsEMBL::Compara::GenomicAlignGroup - Defines groups of genomic aligned sequences
Package variables
No package variables defined.
Included modules
Scalar::Util qw ( weaken )
Synopsis
use Bio::EnsEMBL::Compara::GenomicAlignGroup;
my $genomic_align_group = new Bio::EnsEMBL::Compara::GenomicAlignGroup (
-adaptor => $genomic_align_group_adaptor,
-genomic_align_array => [$genomic_align1, $genomic_align2...]
);
SET VALUES
$genomic_align_group->adaptor($gen_ali_group_adaptor);
$genomic_align_group->dbID(12);
$genomic_align_group->genomic_align_array([$genomic_align1, $genomic_align2]);
GET VALUES
my $genomic_align_group_adaptor = $genomic_align_group->adaptor();
my $dbID = $genomic_align_group->dbID();
my $genomic_aligns = $genomic_align_group->genomic_align_array();
Description
The GenomicAlignGroup object defines groups of alignments.
Methods
Methods description
Arg [1] : Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor $adaptor Example : my $gen_ali_grp_adaptor = $genomic_align_block->adaptor(); Example : $genomic_align_block->adaptor($gen_ali_grp_adaptor); Description: Getter/Setter for the adaptor this object uses for database interaction. Returntype : Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor object Exceptions : thrown if $adaptor is not a Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor object Caller : general Status : Stable |
Arg [1] : Bio::EnsEMBL::Compara::GenomicAlign $genomic_align Example : $genomic_align_block->add_GenomicAlign($genomic_align); Description: adds another Bio::EnsEMBL::Compara::GenomicAlign object to the set of Bio::EnsEMBL::Compara::GenomicAlign objects in the attribute genomic_align_array. Returntype : Bio::EnsEMBL::Compara::GenomicAlign object Exceptions : thrown if wrong argument Caller : general Status : Stable |
Arg [1] : -none- Example : $aligned_sequence = $object->aligned_sequence(); Description : Get the aligned sequence for this group. When the group contains one single sequence, returns its aligned sequence. For composite segments, returns the combined aligned seq. Returntype : string Exceptions : none Caller : general Status : At risk |
Arg : none Example : my $new_gag = $gag->copy() Description : Create a copy of this Bio::EnsEMBL::Compara::GenomicAlignGroup object Returntype : Bio::EnsEMBL::Compara::GenomicAlignGroup Exceptions : none Caller : general Status : Stable |
Arg [1] : integer $dbID Example : my $dbID = $genomic_align_group->dbID(); Example : $genomic_align_group->dbID(12); Description: Getter/Setter for the attribute dbID Returntype : integer Exceptions : none Caller : general Status : Stable |
Arg [1] : -none- Example : $dnafrag = $object->dnafrag(); Description : Get the dnafrag object from the underlying GenomicAlign objects Returntype : Bio::EnsEMBL::Compara::DnaFrag Exceptions : none Caller : general Status : Stable |
Arg [1] : -none- Example : $dnafrag_end = $object->dnafrag_end(); Description : Get the dnafrag_end value from the underlying GenomicAlign objects Returntype : int Exceptions : none Caller : general Status : Stable |
Arg [1] : -none- Example : $dnafrag_start = $object->dnafrag_start(); Description : Get the dnafrag_start value from the underlying GenomicAlign objects Returntype : int Exceptions : none Caller : general Status : Stable |
Arg [1] : -none- Example : $dnafrag_strand = $object->dnafrag_strand(); Description : Get the dnafrag_strand value from the underlying GenomicAlign objects Returntype : int Exceptions : none Caller : general Status : Stable |
Arg [1] : -none- Example : $genome_db = $object->genome_db(); Description : Get the genome_db object from the underlying GenomicAlign objects Returntype : Bio::EnsEMBL::Compara::GenomeDB Exceptions : none Caller : general Status : Stable |
Arg [1] : array reference containing Bio::EnsEMBL::Compara::GenomicAlign objects Example : $genomic_aligns = $genomic_align_group->genomic_align_array(); $genomic_align_group->genomic_align_array([$genomic_align1, $genomic_align2]); Description: get/set for attribute genomic_align_array Returntype : array reference containing Bio::EnsEMBL::Compara::GenomicAlign objects Exceptions : none Caller : general Status : Stable |
Arg [1] : none Example : $genomic_aligns = $genomic_align_block->get_all_GenomicAligns(); Description: returns the set of Bio::EnsEMBL::Compara::GenomicAlign objects in the attribute genomic_align_array. Returntype : array reference containing Bio::EnsEMBL::Compara::GenomicAlign objects Exceptions : none Caller : general Status : Stable |
Arg [-DBID] : (opt.) int $dbID (the database internal ID for this object) Arg [-ADAPTOR] : (opt.) Bio::EnsEMBL::Compara::DBSQL::GenomicAlignAdaptor $adaptor (the adaptor for connecting to the database) Arg [-TYPE] : (opt.) string $type (a string identifying the type of grouping) Arg [-GENOMIC_ALIGN_ARRAY] : (opt.) array_ref $genomic_aligns (a reference to the array of Bio::EnsEMBL::Compara::GenomicAlign objects corresponding to this Bio::EnsEMBL::Compara::GenomicAlignGroup object) Example : my $genomic_align_group = new Bio::EnsEMBL::Compara::GenomicAlignGroup( -adaptor => $genomic_align_group_adaptor, -type => "pairwise", -genomic_align_array => [$genomic_align1, $genomic_align2...] ); Description: Creates a new GenomicAligngroup object Returntype : Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroup Exceptions : none Caller : general Status : Stable |
Arg [1] : hash reference $hashref Example : none Description: This is an ultra fast constructor which requires knowledge of the objects internals to be used. Returntype : Exceptions : none Caller : Status : Stable |
Arg [1] : string $type Example : my $type = $genomic_align_group->type(); Example : $genomic_align_group->type("pairwise"); Description: Getter/Setter for the attribute type Returntype : string Exceptions : none Caller : general Status : Stable |
Methods code
sub adaptor
{ my ($self, $adaptor) = @_;
if (defined($adaptor)) {
throw("$adaptor is not a Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor object")
unless ($adaptor->isa("Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor"));
$self->{'adaptor'} = $adaptor;
}
return $self->{'adaptor'}; } |
sub add_GenomicAlign
{ my ($self, $genomic_align) = @_;
throw("[$genomic_align] is not a Bio::EnsEMBL::Compara::GenomicAlign object")
unless ($genomic_align and ref($genomic_align) and
$genomic_align->isa("Bio::EnsEMBL::Compara::GenomicAlign"));
push(@{$self->{'genomic_align_array'}}, $genomic_align);
return $genomic_align; } |
sub aligned_sequence
{ my $self = shift;
my $aligned_sequence;
foreach my $this_genomic_align (@{$self->get_all_GenomicAligns}) {
if (!$aligned_sequence) {
$aligned_sequence = $this_genomic_align->aligned_sequence;
} else {
my $pos = 0;
foreach my $substr (grep {$_} split(/(\.+)/, $this_genomic_align->aligned_sequence)) {
if ($substr =~ /^\.+$/) {
$pos += length($substr);
} else {
substr($aligned_sequence, $pos, length($substr), $substr);
}
}
}
}
return $aligned_sequence;
}
1; } |
sub copy
{ my $self = shift;
my $copy;
$copy->{original_dbID} = $self->{dbID};
$copy->{type} = $self->type;
$copy->{genomic_align_array} = $self->{genomic_align_array};
return bless $copy, ref($self); } |
sub dbID
{ my ($self, $dbID) = @_;
if (defined($dbID)) {
$self->{'dbID'} = $dbID;
}
return $self->{'dbID'}; } |
sub dnafrag
{ my $self = shift;
my $dnafrag;
foreach my $genomic_align (@{$self->get_all_GenomicAligns}) {
if (!$dnafrag) {
$dnafrag = $genomic_align->dnafrag;
} elsif ($dnafrag != $genomic_align->dnafrag) {
return bless({name => "Composite"}, "Bio::EnsEMBL::Compara::DnaFrag");
}
}
return $dnafrag; } |
sub dnafrag_end
{ my $self = shift;
my $dnafrag;
my $dnafrag_end;
foreach my $genomic_align (@{$self->get_all_GenomicAligns}) {
if (!$dnafrag) {
$dnafrag = $genomic_align->dnafrag;
$dnafrag_end = $genomic_align->dnafrag_end;
} elsif ($dnafrag != $genomic_align->dnafrag) {
return $genomic_align->length;
} elsif ($genomic_align->dnafrag_end > $dnafrag_end) {
$dnafrag_end = $genomic_align->dnafrag_end;
}
}
return $dnafrag_end; } |
sub dnafrag_start
{ my $self = shift;
my $dnafrag;
my $dnafrag_start;
foreach my $genomic_align (@{$self->get_all_GenomicAligns}) {
if (!$dnafrag) {
$dnafrag = $genomic_align->dnafrag;
$dnafrag_start = $genomic_align->dnafrag_start;
} elsif ($dnafrag != $genomic_align->dnafrag) {
return 1;
} elsif ($genomic_align->dnafrag_start < $dnafrag_start) {
$dnafrag_start = $genomic_align->dnafrag_start;
}
}
return $dnafrag_start; } |
sub dnafrag_strand
{ my $self = shift;
my $dnafrag_strand;
foreach my $genomic_align (@{$self->get_all_GenomicAligns}) {
if (!$dnafrag_strand) {
$dnafrag_strand = $genomic_align->dnafrag_strand;
} elsif ($dnafrag_strand != $genomic_align->dnafrag_strand) {
return 0;
}
}
return $dnafrag_strand; } |
sub genome_db
{ my $self = shift;
foreach my $genomic_align (@{$self->get_all_GenomicAligns}) {
return $genomic_align->genome_db if ($genomic_align->genome_db);
}
return undef; } |
sub genomic_align_array
{ my ($self, $genomic_align_array) = @_;
my $genomic_align_adaptor;
if (defined($genomic_align_array)) {
$self->{'genomic_align_array'} = undef;
foreach my $genomic_align (@$genomic_align_array) {
throw("$genomic_align is not a Bio::EnsEMBL::Compara::GenomicAlign object")
unless ($genomic_align->isa("Bio::EnsEMBL::Compara::GenomicAlign"));
if (!defined($genomic_align_adaptor)) {
if (defined($genomic_align->adaptor)) {
$genomic_align_adaptor = $genomic_align->adaptor;
} elsif (defined($self->adaptor)) {
$genomic_align_adaptor = $self->adaptor->db->get_GenomicAlignAdaptor;
}
}
if (defined($genomic_align_adaptor) and $genomic_align->dbID) {
weaken($self->{'genomic_align_array'}->{$genomic_align->dbID} = $genomic_align);
$self->{'genomic_align_adaptor'} = $genomic_align_adaptor;
} else {
$self->{'genomic_align_array'}->{$genomic_align} = $genomic_align;
}
}
} elsif (!defined($self->{'genomic_align_array'})) {
if (defined($self->{'adaptor'}) and defined($self->{'dbID'})) {
$self = $self->{'adaptor'}->fetch_by_dbID($self->{'dbID'});
}
}
$genomic_align_array = [];
if ($self->{'genomic_align_adaptor'}) {
$genomic_align_adaptor = $self->{'genomic_align_adaptor'};
}
if (defined($genomic_align_adaptor)) {
while (my ($dbID, $genomic_align) = each %{$self->{'genomic_align_array'}}) {
if (!defined($genomic_align)) {
$genomic_align = $genomic_align_adaptor->fetch_by_dbID($dbID);
weaken($self->{'genomic_align_array'}->{$dbID} = $genomic_align);
}
push(@$genomic_align_array, $genomic_align);
}
} else {
$genomic_align_array = [values %{$self->{'genomic_align_array'}}];
}
return $genomic_align_array; } |
sub get_all_GenomicAligns
{ my ($self) = @_;
return ($self->{'genomic_align_array'} or []); } |
sub new
{ my($class, @args) = @_;
my $self = {};
bless $self,$class;
my ($adaptor, $dbID, $type, $genomic_align_array) =
rearrange([qw(
ADAPTOR DBID TYPE GENOMIC_ALIGN_ARRAY)], @args);
$self->adaptor($adaptor) if (defined ($adaptor));
$self->dbID($dbID) if (defined ($dbID));
$self->type($type) if (defined ($type));
$self->genomic_align_array($genomic_align_array) if (defined($genomic_align_array));
return $self; } |
sub new_fast
{ my $class = shift;
my $hashref = shift;
return bless $hashref, $class; } |
sub type
{ my ($self, $type) = @_;
if (defined($type)) {
$self->{'type'} = $type;
} elsif (!defined($self->{'type'})) {
if (defined($self->{'dbID'}) and defined($self->{'adaptor'})) {
$self->adaptor->retrieve_all_direct_attributes($self);
}
}
return $self->{'type'}; } |
General documentation
dbID
corresponds to genomic_align_group.group_id
adaptor
Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor object to access DB
type
corresponds to genomic_align_group.type
genomic_align_array
listref of Bio::EnsEMBL::Compara::DBSQL::GenomicAlign objects corresponding to this
Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroup object
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _