Skip to content
Snippets Groups Projects
Commit 97ab2a62 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Formatting in prep for changes to translate().

parent 225a69af
No related branches found
No related tags found
No related merge requests found
...@@ -1406,26 +1406,24 @@ sub get_all_translateable_Exons { ...@@ -1406,26 +1406,24 @@ sub get_all_translateable_Exons {
sub translate { sub translate {
my ($self) = @_; my ($self) = @_;
if(!$self->translation()) { if ( !defined( $self->translation() ) ) { return undef }
return undef;
}
my $mrna = $self->translateable_seq(); my $mrna = $self->translateable_seq();
my $display_id = $self->translation->display_id || scalar($self->translation); my $display_id = $self->translation->display_id()
|| scalar( $self->translation() );
# remove final stop codon from the mrna if it is present # remove final stop codon from the mrna if it is present
# produced peptides will not have '*' at end # produced peptides will not have '*' at end
# if terminal stop codon is desired call translatable_seq directly # if terminal stop codon is desired call translatable_seq directly
# and produce a translation from it # and produce a translation from it
if( CORE::length( $mrna ) % 3 == 0 ) { if ( CORE::length($mrna) % 3 == 0 ) {
$mrna =~ s/TAG$|TGA$|TAA$//i; $mrna =~ s/TAG$|TGA$|TAA$//i;
} }
if(CORE::length($mrna) <1){ if ( CORE::length($mrna) < 1 ) {
return undef; return undef;
} }
my $peptide = Bio::Seq->new( -seq => $mrna, my $peptide = Bio::Seq->new( -seq => $mrna,
...@@ -1433,27 +1431,30 @@ sub translate { ...@@ -1433,27 +1431,30 @@ sub translate {
-alphabet => 'dna', -alphabet => 'dna',
-id => $display_id ); -id => $display_id );
# Alternative codon tables (such as the mitochondrial codon table) can # Alternative codon tables (such as the mitochondrial codon table)
# be sepcified for a sequence region via the seq_region_attrib table. # can be sepcified for a sequence region via the seq_region_attrib
# A list of codon tables and their codes is at: # table. A list of codon tables and their codes is at:
# http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wprintgc?mode=c # http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wprintgc?mode=c
my $codon_table; my $codon_table = 1; # default vertebrate codon table
if($self->slice()) { if ( defined( $self->slice() ) ) {
my ($attrib) = @{$self->slice()->get_all_Attributes('codon_table')}; my ($attrib) =
$codon_table = $attrib->value() if($attrib); @{ $self->slice()->get_all_Attributes('codon_table') };
}
$codon_table ||= 1; # default vertebrate codon table if ( defined($attrib) ) {
$codon_table = $attrib->value();
}
}
my $translation = $peptide->translate(undef,undef,undef,$codon_table); my $translation =
$peptide->translate( undef, undef, undef, $codon_table );
if($self->edits_enabled()) { if ( $self->edits_enabled() ) {
$self->translation()->modify_translation( $translation ); $self->translation()->modify_translation($translation);
} }
return $translation; return $translation;
} } ## end sub translate
=head2 seq =head2 seq
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment