Skip to content

Commit

Permalink
Updated trunk to 0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kgalinsky committed Oct 28, 2009
1 parent d4b7986 commit 1b76f5b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 30 deletions.
7 changes: 6 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
Revision history for JCVI-Translator

0.5.3 Apr 13 2009
- Fixed inconsistencies in the way the start codon is being stored in the
reverse translation table
- Added test for above condition

0.5.2 Apr 13 2009
- Even more documentation in Utils
- codons/regex/find method in Utils can take "stop" for stop codons
- codons/regex/find method in Utils can take "stop" for stop codons

0.5.1 Apr 13 2009
- Better documentation in Utils
Expand Down
2 changes: 1 addition & 1 deletion lib/JCVI/Translator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use strict;
use warnings;

use version;
our $VERSION = qv('0.5.2');
our $VERSION = qv('0.5.3');

use base qw(Class::Accessor::Fast);
__PACKAGE__->mk_accessors(qw(table base));
Expand Down
4 changes: 2 additions & 2 deletions lib/JCVI/Translator/Table.pm
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ sub add_translation {
$table->store( $residue, $$codon_ref, $$rc_codon_ref );

# Store the reverse lookup
$residue = 'start' if ( $p{start} );
$self->_reverse->push( 'start', $$codon_ref, $$rc_codon_ref );
$residue = '+' if ( $p{start} );
$self->_reverse->push( $residue, $$codon_ref, $$rc_codon_ref );
}

=head2 bootstrap
Expand Down
30 changes: 15 additions & 15 deletions lib/JCVI/Translator/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ our $BOOLEAN_REGEX = qr/^[01]$/;
our $INTEGER_REGEX = qr/^\d+$/;
our $STRAND_REGEX = qr/^[+-]?1$/;
our $SEARCH_STRAND_REGEX = qr/^[+-]?[01]$/;
our $RESIDUE_REGEX = qr/^(?:$aa_match|start|stop|lower|upper)$/;
our $RESIDUE_REGEX = qr/^(?:$aa_match|\+|start|stop|lower|upper)$/;
our $STRICT_REGEX = qr/^[012]$/;

sub _new {
Expand All @@ -79,8 +79,9 @@ Returns a list of codons for a particular residue or start codon. In addition
to the one-letter codes for amino acids, the following are valid inputs for the
residue:
start: Start codons
stop: Stop codons (you may also use "*" which is the 1 letter code)
start: Start codons (you may also use "+" which is what the translator
uses as the 1-letter code for start codons)
stop: Stop codons (you may also use "*" which is the 1-letter code)
lower: Start or stop codons, depending up on strand
upper: Start or stop codons, depending up on strand
Expand Down Expand Up @@ -124,17 +125,14 @@ sub codons {
# Set the reverse comlement variable
my $rc = $p{strand} == 1 ? 0 : 1;

# If residue is 'stop' change it to '*'
if ( $residue eq 'stop' ) { $residue = '*' }

# Do nothing if residue is "start" (don't want to capitalize)
elsif ( $residue eq 'start' ) { }

# Lower bound is "*" on the - strand, "start" on the + strand
elsif ( $residue eq 'lower' ) { $residue = $rc ? '*' : 'start' }
# Format start/stop to be '+' and '*' which is how translator stores them
if ( $residue eq 'stop' ) { $residue = '*' }
elsif ( $residue eq 'start' ) { $residue = '+' }

# Upper bound is "start" on the - strand, or "*" on the + strand
elsif ( $residue eq 'upper' ) { $residue = $rc ? 'start' : '*' }
# Lower bound is stop on the - strand, start on the + strand. Upper bound
# is the reverse
elsif ( $residue eq 'lower' ) { $residue = $rc ? '*' : '+' }
elsif ( $residue eq 'upper' ) { $residue = $rc ? '+' : '*' }

# Capitalize all other residues
else { $residue = uc $residue }
Expand All @@ -157,7 +155,8 @@ Returns a regular expression matching codons for a particular amino acid
residue. In addition to the one-letter codes for amino acids, the following are
valid inputs for the residue:
start: Start codons
start: Start codons (you may also use "+" which is what the translator
uses as the 1-letter code for start codons)
stop: Stop codons (you may also use "*" which is the 1 letter code)
lower: Start or stop codons, depending up on strand
upper: Start or stop codons, depending up on strand
Expand Down Expand Up @@ -225,7 +224,8 @@ Find the indexes of a given residue in a sequence. In addition to the
one-letter codes for amino acids, the following are valid inputs for the
residue:
start: Start codons
start: Start codons (you may also use "+" which is what the translator
uses as the 1-letter code for start codons)
stop: Stop codons (you may also use "*" which is the 1 letter code)
lower: Start or stop codons, depending up on strand
upper: Start or stop codons, depending up on strand
Expand Down
35 changes: 24 additions & 11 deletions t/21-codons.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,31 @@ ok( !$@, 'codons ran with strand = 1' );

eval { $utils->codons( 'F', { strand => -1 } ) };
ok( !$@, 'codons ran with strand = -1' );

eval { $utils->codons( 'F', { strand => 2 } ) };
ok( $@, 'codons died with strand = 2' );

my @expected = ( [qw(TTT TTC TTY)], [qw(AAA GAA RAA)] );

foreach my $strand ( 1, -1 ) {
my $codons = $utils->codons( 'F', { strand => $strand } );
my $expected = shift @expected;
is( scalar(@$codons), scalar(@$expected), 'Expected number of codons' );

my $lc = List::Compare->new( $expected, $codons );

is( scalar( $lc->get_symdiff ), 0, '0 differences between lists' );
my @entries = (
[ 'F' => [ [qw(TTT TTC TTY)], [qw(AAA GAA RAA)] ] ],
[
'start' => [
[qw(YTG WTG MTG HTG TTG CTG ATG)],
[qw(CAR CAW CAK CAD CAA CAG CAT)]
]
]
);

foreach my $entry (@entries) {
my ( $residue, $expecteds ) = @$entry;

foreach my $strand ( 1, -1 ) {
my $codons = $utils->codons( $residue, { strand => $strand } );
my $expected = shift @$expecteds;
is( scalar(@$codons), scalar(@$expected),
"Got expected number of codons for $residue" );

my $lc = List::Compare->new( $expected, $codons );

is( scalar( $lc->get_symdiff ), 0,
'0 differences between codon lists' );
}
}

0 comments on commit 1b76f5b

Please sign in to comment.