The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::Translator - Translate DNA sequences

SYNOPSIS

    use Bio::Translator;

    my $translator = new Bio::Translator();
    my $translator = new Bio::Translator(11);
    my $translator = new Bio::Translator( 12, 'id' );
    my $translator = new Bio::Translator( 'Yeast Mitochondrial', 'name' );
    my $translator = new Bio::Translator( 'mito', 'name' );

    my $translator = custom Bio::Translator( \$custom_table );
    my $translator = custom Bio::Translator( \$custom_table, 1 );

    $translator->translate( \$seq );
    $translator->translate( \$seq, { strand => 1 } );
    $translator->translate( \$seq, { strand => -1 } );

DESCRIPTION

Bio::Translator tries to be a robust translator object featuring translation tables based off the the ones provided by NCBI. Key features include the ability to handle degenerate nucleotides and to translate to ambiguous amino acids.

First, create a new translator object using one of the included tables or a custom one (see Bio::Translator::Table for table formats), and then passing your DNA sequences to your translator object.

The translator uses interbase coordinates. See below for the difference between interbase coordinates and traditional numbering methods:

    Traditional   1 2 3 4
                  A C G T ...
    Interbase    0 1 2 3 4

Conversion methods between the two methods can depend upon what you are trying to do, but the simple way to do this is:

    strand = 3' end <=> 5' end # that's the spaceship operator!
    lower  = min( 5' end, 3' end ) - 1
    upper  = max( 5' end, 3' end )

Parameter validation uses Params::Validate which introduces overhead but can be disabled. See the Params::Validate documentation for more information.

CONSTRUCTORS

new

    my $translator = new Bio::Translator();
    my $translator = new Bio::Translator( $id );
    my $translator = new Bio::Translator( $id, \%params );

Create a translator with a translation table provided by $id. Please see Bio::Translator::Table for the full list of options.

custom()

    my $translator = $translator->custom( $table_ref );
    my $translator = $translator->custom( $table_ref, \%params );

Create a translator with a custom translation table. Please see Bio::Translator::Table for the full list of options.

METHODS

translate

    $pep_ref = $translator->translate( $seq_ref, \%params );

The basic function of this module. Translate the specified region of the sequence (passed as $seq_ref) and return a reference to the translated string. The parameters are:

    strand: [+-]?1; default = 1
    lower:  integer between 0 and seq_length; default = 0
    upper:  integer between 0 and seq_length; default = seq_length
    start:  boolean
    offset: [012]

Translator uses interbase coordinates. "lower" and "upper" are optional parameters such that:

    0 <= lower <= upper <= seq_length

Translator will croak if those conditions are not satisfied.

"start" sets whether or not to try translating the first codon as a start codon. By default, translator will try to do this. "offset" allows you to specify an offset in addition to the lower and upper abounds and have Translator figure out the correct bound to offset from.

To translate the following:

 0 1 2 3 4 5 6 7 8 9
  C G C G C A G G A
    ---------->

    $pep_ref = $translator->translate(
        \$sequence,
        {
            strand => 1,
            lower  => 1,
            upper  => 7
        }
    );

 0 1 2 3 4 5 6 7 8 9
  C G C G C A G G A
      <----------

    $pep_ref = $translator->translate(
        \$sequence,
        {
            strand => -1,
            lower  => 2,
            upper  => 8
        }
    );

Examples:

    my $pep_ref = $translator->translate( \'acttgacgt' );

    my $pep_ref = $translator->translate( \'acttgacgt', { strand => -1 } );

    my $pep_ref = $translator->translate(
        \'acttgacgt',
        {
            strand => -1,
            lower  => 2,
            upper  => 5
        }
    );

    my $pep_ref = $translator->translate(
        \'acttgacgt',
        {
            strand  => 1,
            lower   => 0,
            upper   => 8,
            start   => 0
        }
    );

translate_lus

  $pep_ref = $translator->translate_lus( $seq_ref, $range, \%params );

translate_codon

    my $residue = $translator->translate_codon( $codon );
    my $residue = $translator->translate_codon( $codon, \%params );

Translate a codon. Return 'X' or '-' if it isn't in the codon table. Handles degenerate nucleotides, so if all possible codons for an ambiguity map to the same residue, return that residue.

Example:

    $residue = $translator->translate_codon('atg');
    $residue = $translator->translate_codon( 'tty', { strand => -1 } );
    $residue = $translator->translate_codon( 'cat', { start => 1 } );

AUTHOR

Kevin Galinsky, kgalinsky plus cpan at gmail dot com

BUGS

Please report any bugs or feature requests to bug-bio-translator at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bio-Translator. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Bio::Translator

You can also look for information at:

ACKNOWLEDGEMENTS

JCVI/Paolo Amedeo

COPYRIGHT & LICENSE

Copyright 2008-2009 J. Craig Venter Institute, 2011 Kevin Galinsky.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.