Bio::EnsEMBL::Pipeline::Alignment
AlignmentSeq
Toolbar
Summary
Bio::EnsEMBL::Pipeline::Alignment::AlignmentSeq.pm
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
Description
Methods
_end_gaps | No description | Code |
add_deletion | No description | Code |
all_gaps | No description | Code |
deletion_coords | No description | Code |
deletion_hash | No description | Code |
exon | No description | Code |
fasta_string | No description | Code |
fetch_base_at_position | No description | Code |
first_base_coord | No description | Code |
increment_deletions_above | No description | Code |
insert_gap | No description | Code |
last_base_coord | No description | Code |
length | No description | Code |
name | No description | Code |
new | No description | Code |
seq | No description | Code |
seq_array | No description | Code |
seq_with_newlines | No description | Code |
start | No description | Code |
store_seq_array | No description | Code |
type | No description | Code |
Methods description
None available.
Methods code
sub _end_gaps
{ my $self = shift;
my $seq = $self->seq;
$seq =~ s/^(\-*)/$1/;
my $upstream_gaps = length $1;
$seq = reverse $seq;
$seq =~ s/^(\-*)/$1/;
my $downstream_gaps = length $1;
$self->{'_first_base_coord'} = $upstream_gaps + 1;
$self->{'_last_base_coord'} = $self->length - $downstream_gaps;
return 1
}
} |
sub add_deletion
{ my ($self, $position, $length) = @_;
throw("Add deletion requires a numeric argument, not this [" .
ref($position) . "]")
if (ref($position) ne '');
if ($position > $self->length) {
warning("Attempting to insert a deletion past the end of sequence.");
return 1
}
$length = 1 unless $length;
$self->deletion_hash->{$position} = $length
unless (defined $self->deletion_hash->{$position} &&
$self->deletion_hash->{$position} > $length);
return 1 } |
sub all_gaps
{ my $self = shift;
my $sequence_array = $self->seq_array;
my @gap_coordinates;
for (my $i = 0; $i < scalar @$sequence_array; $i++) {
push @gap_coordinates, $i+1 if $sequence_array->[$i] eq '-'
}
return\@ gap_coordinates } |
sub deletion_coords
{ my $self = shift;
my @deletion_coords = keys %{$self->deletion_hash};
return\@ deletion_coords
}
} |
sub deletion_hash
{ my $self = shift;
if (@_){
$self->{'_deletions'} = shift
}
unless ($self->{'_deletions'}){
$self->{'_deletions'} = {};
}
return $self->{'_deletions'} } |
sub exon
{ my $self = shift;
if (@_) {
$self->{'_exon'} = shift;
}
return $self->{'_exon'};
}
} |
sub fasta_string
{ my ($self, $line_length) = @_;
$line_length = 60
unless $line_length;
return '>' . $self->name . "\n" .
$self->seq_with_newlines($line_length) . "\n";
}
1; } |
sub fetch_base_at_position
{ my ($self, $base_position) = @_;
$self->throw("Must specify a coordinate in order to retrieve a base from the sequence.")
unless $base_position;
$base_position--;
return substr $self->seq, $base_position, 1;
}
} |
sub first_base_coord
{ my $self = shift;
unless (defined $self->{'_first_base_coord'}){
$self->_end_gaps;
}
return $self->{'_first_base_coord'}
}
} |
sub increment_deletions_above
{ my ($self, $coord) = @_;
my $deletion_hash = $self->deletion_hash;
my @coords = keys %$deletion_hash;
for (my $i = 0; $i < scalar @coords; $i++) {
if ($deletion_hash->{$coords[$i]}){
my $deletion_length = $deletion_hash->{$coords[$i]};
delete $deletion_hash->{$coords[$i]};
$deletion_hash->{$coords[$i]+1} = $deletion_length;
}
}
return 1 } |
sub insert_gap
{ my ($self, $insert_position, $gap_length) = @_;
unless (defined $insert_position && $gap_length > 0){
throw("Need to specify gap insertion position [$insert_position] " .
"and length [$gap_length]");
}
my $gap = '-' x $gap_length;
my $seq = $self->seq;
if (length $seq < ($insert_position - 1)){
info("Attempting to insert gap in sequence [" . $self->name .
"] beyond the end of the sequence. Sequence length [".
length($seq) ."] Insert position [" .
($insert_position - 1) . "]\n");
return 0
}
my $new_seq = substr($seq, 0, $insert_position - 1) .
$gap . substr($seq, $insert_position - 1);
$self->seq($new_seq);
for (my $i = 0; $i < $gap_length; $i++) {
$self->increment_deletions_above($insert_position+$i)
}
return 1 } |
sub last_base_coord
{ my $self = shift;
unless (defined $self->{'_last_base_coord'}){
$self->_end_gaps;
}
return $self->{'_last_base_coord'}
}
} |
sub length
{ my $self = shift;
return scalar @{$self->seq_array};
}
} |
sub name
{ my $self = shift;
if (@_) {
$self->{'_name'} = shift;
}
return $self->{'_name'}; } |
sub new
{ my ($class, @args) = @_;
my $self = bless {},$class;
my ($name,
$seq,
$deletions,
$start,
$exon,
$type) = rearrange([qw(NAME
SEQ
DELETIONS
START
EXON
TYPE)],@args);
$self->seq($seq) if $seq;
$self->name($name) if $name;
$self->start($start) if $start;
$self->exon($exon) if $exon;
$self->type($type) if $type;
return $self; } |
sub seq
{ my $self = shift;
if (@_) {
$self->{'_seq'} = shift;
}
$self->throw('No sequence attached to object')
unless $self->{'_seq'};
return $self->{'_seq'};
}
} |
sub seq_array
{ my $self = shift;
$self->throw("Cant retrieve seq_array when there is no sequence.")
unless $self->seq;
my @array = split //, $self->seq;
return\@ array;
}
} |
sub seq_with_newlines
{ my ($self, $line_length) = @_;
$line_length = 60 unless defined $line_length;
my $seq_string = $self->seq;
$seq_string =~ s/(.{$line_length})/$1\n/g;
return $seq_string;
}
} |
sub start
{ my $self = shift;
if (@_) {
$self->{'_start'} = shift;
}
return $self->{'_start'}
}
} |
sub store_seq_array
{ my $self = shift;
my $input_array = shift;
$self->throw("Array for storage contains nothing.")
unless (scalar @$input_array > 0);
my $concat_seq;
for (my $i = 0; $i < scalar @$input_array; $i++){
if (! defined $input_array->[$i] ||
$input_array->[$i] eq ''){
$concat_seq .= '-';
} else {
$concat_seq .= $input_array->[$i];
}
}
$self->seq($concat_seq);
return 1; } |
sub type
{ my $self = shift;
if (@_) {
my $type = shift;
$self->throw("Unknown sequence type - needs to be either " .
"'nucleotide' or 'protein'.")
unless ($type eq 'nucleotide' || $type eq 'protein');
$self->{'_type'} = $type;
}
return $self->{'_type'};
}
} |
General documentation
Post general queries to ensembl-dev@ebi.ac.uk