Skip to content

Commit

Permalink
Add script that demonstrates reverse_tranlate_best()
Browse files Browse the repository at this point in the history
svn path=/bioperl-live/trunk/; revision=15087
  • Loading branch information
bosborne committed Dec 4, 2008
1 parent 5e9409f commit 94e97c6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/popgen/parse_calc_stats.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# Author: Jason Stajich, jason@bioperl.org
# $Id$
# $Revision$
# $Revision: 6576 $

use strict;

Expand Down
60 changes: 60 additions & 0 deletions examples/tools/reverse-translate.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/perl -w
# $Id$

=head1 NAME
reverse-translate.pl
=head1 DESCRIPTION
Reverse-translates a nucleotide sequence using the most frequent codons.
Requires an input sequence file and a nucleotide sequence file containing
one sequence comprised of one or more ORFs. This file supplies the codon
frequency data and will be parsed starting at the first triplet in the sequence.
=head1 OPTIONS
-i Input sequence, amino acid
-c Input sequence, nucleotide ORFs
Example:
reverse-translate.pl -i ~/bioperl-live/t/data/cysprot.fa -c ~/bioperl-live/t/data/HUMBETGLOA.fa
=cut

use strict;
use Bio::SeqIO;
use Bio::Tools::CodonTable;
use Bio::Tools::SeqStats;
use Bio::CodonUsage::Table;
use Getopt::Long;

my ($codonFile,$seqFile);

GetOptions( "c=s" => \$codonFile,
"i=s" => \$seqFile );

die "Need input sequence and file containing coding regions"
if ( !$codonFile || !$seqFile );

my $codonIn = Bio::SeqIO->new(-file => $codonFile,
-format => 'fasta');

my $codonSeq = $codonIn->next_seq;

my $codonStats = Bio::Tools::SeqStats->count_codons($codonSeq);

my $codonUsage = Bio::CodonUsage::Table->new(-data => $codonStats );

my $codonTable = Bio::Tools::CodonTable->new;

my $seqIn = Bio::SeqIO->new(-file => $seqFile);

my $seq = $seqIn->next_seq;

my $rvSeq = $codonTable->reverse_translate_best($seq,$codonUsage);

print $rvSeq,"\n";

__END__

0 comments on commit 94e97c6

Please sign in to comment.