Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in is_ter_codon #387

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions lib/Bio/Tools/CodonTable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -735,41 +735,18 @@ sub is_start_codon{
=head2 is_ter_codon

Title : is_ter_codon
Usage : $obj->is_ter_codon('GAA')
Usage : $obj->is_ter_codon('TGA')
Function: returns true (1) for all codons that can be used as a
translation tarminator, false (0) for others.
Example : $myCodonTable->is_ter_codon('ATG')
Example : $myCodonTable->is_ter_codon('TGA')
Returns : boolean
Args : codon

=cut

sub is_ter_codon{
my ($self, $value) = @_;
my $id = $self->{'id'};

# We need to ensure U is mapped to T (ie. UAG)
$value = uc $value;
$value =~ tr/U/T/;

if (length $value != 3 ) {
# Incomplete codons are not stop codons
return 0;
} else {
my $result = 0;

# For all the possible codons, if any are not a stop
# codon, fail immediately
for my $c ( $self->unambiguous_codons($value) ) {
my $m = substr( $TABLES[$id], $CODONS->{$c}, 1 );
if($m eq $TERMINATOR) {
$result = 1;
} else {
return 0;
}
}
return $result;
}
shift->_codon_is( shift, \@STARTS, '*' );
}

# desc: compares the passed value with a single entry in the given
Expand Down
12 changes: 8 additions & 4 deletions t/SeqTools/CodonTable.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use strict;
BEGIN {
use Bio::Root::Test;

test_begin(-tests => 84);
test_begin(-tests => 87);

use_ok('Bio::Tools::CodonTable');
use_ok('Bio::CodonUsage::IO');
Expand Down Expand Up @@ -170,9 +170,13 @@ ok $myCodonTable->is_ter_codon('TaR'), 'is_ter_codon,TaR';
ok $myCodonTable->is_ter_codon('tRa'), 'is_ter_codon,tRa';
is $myCodonTable->is_ter_codon('ttA'), 0, 'is_ter_codon,ttA';

# Ambiguous codons should fail
is $myCodonTable->is_ter_codon('NNN'), 0, 'is_ter_codon, ambiguous codons should fail, NNN';
is $myCodonTable->is_ter_codon('TAN'), 0, 'is_ter_codon, ambiguous codons should fail, TAN';
# Ambiguous codons
is $myCodonTable->is_start_codon('NNN'), 1, 'is_start_codon, ambiguous codons should succeed, NNN';
is $myCodonTable->is_start_codon('ATN'), 1, 'is_start_codon, ambiguous codons should succeed, ATN';
is $myCodonTable->is_start_codon('CC'), 0, 'is_ter_codon, incomplete codons should fail, CC';

is $myCodonTable->is_ter_codon('NNN'), 1, 'is_ter_codon, ambiguous codons should succeed, NNN';
is $myCodonTable->is_ter_codon('TAN'), 1, 'is_ter_codon, ambiguous codons should succeed, TAN';
is $myCodonTable->is_ter_codon('CC'), 0, 'is_ter_codon, incomplete codons should fail, CC';

ok $myCodonTable->is_unknown_codon('jAG');
Expand Down
Loading