Skip to content

Commit

Permalink
Bio::Tools::CodonTable::is_start_codon: check in case of ambiguous co…
Browse files Browse the repository at this point in the history
…dons (#266)

In the case of ambiguous codons this method should only return true if
all possible codons are start codons (same as is_ter_codon).  This was
the behaviour in BioPerl 1.2.3 but since at least BioPerl 1.6.924 it
returns true if at least one codon is a start codon.

This change fixes that regression and makes behaviour consistent with
is_ter_codon.
  • Loading branch information
carandraug committed Apr 26, 2024
1 parent ffd0c21 commit 7a28711
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Summary of important user-visible changes for BioPerl
being used. This update changes codon tables 3, 15, 24, 27-30,
32, and 33 [#389, #391].

* Bio::Tools::CodonTable::is_start_codon now returns true when all
possible codons (in the case of ambiguous codons such as NTG)
are start codons. For some recent versions it was return true
if any of the codons was a start codon. This change is
consistent with the behaviour of is_ter_codon and returns to the
(very) old behaviour [#266].

1.7.8 2021-02-02 23:02:18-06:00 America/Chicago
* Bio::SeqIO::interpro has been moved to a separate repository to
deal with issues with XML::DOM::XPath bitrot [#347]
Expand Down
28 changes: 19 additions & 9 deletions lib/Bio/Tools/CodonTable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ sub reverse_translate_best {
Title : is_start_codon
Usage : $obj->is_start_codon('ATG')
Function: returns true (1) for all codons that can be used as a
translation start, false (0) for others.
translation start, false (0) for others. In the case of
ambiguous codons, e.g., 'NTG', only returns true if all
possible codons are true.
Example : $myCodonTable->is_start_codon('ATG')
Returns : boolean
Args : codon
Expand All @@ -662,7 +664,9 @@ sub is_start_codon{
Title : is_ter_codon
Usage : $obj->is_ter_codon('GAA')
Function: returns true (1) for all codons that can be used as a
translation tarminator, false (0) for others.
translation terminator, false (0) for others. In the case
of ambiguous codons, e.g., 'TAN', only returns true if all
possible codons are true.
Example : $myCodonTable->is_ter_codon('ATG')
Returns : boolean
Args : codon
Expand Down Expand Up @@ -699,12 +703,13 @@ sub is_ter_codon{

# desc: compares the passed value with a single entry in the given
# codon table
# args: a value (typically a three-char string like 'atg'),
# a reference to the appropriate set of codon tables,
# a single-character value to check for at the position in the
# given codon table
# args: a value (typically a three-char string like 'atg'), a
# reference to the appropriate set of codon tables, a
# single-character value to check for at the position in the
# given codon table.
# ret: boolean, true if the given codon table contains the $key at the
# position corresponding to $value
# position corresponding to $value. In the case of ambiguous
# codons, only returns true if all possibilities match $key.
sub _codon_is {
my ($self, $value, $table, $key ) = @_;

Expand All @@ -714,11 +719,16 @@ sub _codon_is {
$value =~ tr/u/t/;

my $id = $self->{'id'};
my $result = 0;
for my $c ( $self->unambiguous_codons($value) ) {
my $m = substr( $table->[$id], $CODONS->{$c}, 1 );
if ($m eq $key) { return 1; }
if ($m eq $key) {
$result = 1;
} else {
return 0;
}
}
return 0;
return $result;
}

=head2 is_unknown_codon
Expand Down
6 changes: 5 additions & 1 deletion 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 => 91);
test_begin(-tests => 94);

use_ok('Bio::Tools::CodonTable');
use_ok('Bio::CodonUsage::IO');
Expand Down Expand Up @@ -185,6 +185,10 @@ is $myCodonTable->is_ter_codon('NNN'), 0, 'is_ter_codon, ambiguous codons should
is $myCodonTable->is_ter_codon('TAN'), 0, 'is_ter_codon, ambiguous codons should fail, TAN';
is $myCodonTable->is_ter_codon('CC'), 0, 'is_ter_codon, incomplete codons should fail, CC';

is $myCodonTable->is_start_codon('NNN'), 0, 'is_start_codon, ambiguous codons should fail, NNN';
is $myCodonTable->is_start_codon('NTG'), 0, 'is_start_codon, ambiguous codons should fail, NTG';
is $myCodonTable->is_start_codon('N'), 0, 'is_start_codon, incomplete codons should fail, NN';

ok $myCodonTable->is_unknown_codon('jAG');
ok $myCodonTable->is_unknown_codon('jg');
is $myCodonTable->is_unknown_codon('UAG'), 0;
Expand Down

0 comments on commit 7a28711

Please sign in to comment.