bin/bp_biofetch_genbank_proxy: move to Bio-DB-NCBIHelper
[bioperl-live.git] / examples / tools / reverse-translate.pl
blob70a0542a9884f4a449565e4faf2c998cc7878075
1 #!/usr/bin/perl
3 =head1 NAME
5 reverse-translate.pl
7 =head1 DESCRIPTION
9 Reverse-translates a nucleotide sequence using the most frequent codons.
10 Requires an input sequence file and a nucleotide sequence file containing
11 one sequence comprised of one or more ORFs. This file supplies the codon
12 frequency data and will be parsed starting at the first triplet in the sequence.
14 =head1 OPTIONS
16 -i Input sequence, amino acid
17 -c Input sequence, nucleotide ORFs
19 Example:
21 reverse-translate.pl -i ~/bioperl-live/t/data/cysprot.fa -c ~/bioperl-live/t/data/HUMBETGLOA.fa
23 =cut
25 use strict;
26 use Bio::SeqIO;
27 use Bio::Tools::CodonTable;
28 use Bio::Tools::SeqStats;
29 use Bio::CodonUsage::Table;
30 use Getopt::Long;
32 my ($codonFile,$seqFile);
34 GetOptions( "c=s" => \$codonFile,
35 "i=s" => \$seqFile );
37 die "Need input sequence and file containing coding regions"
38 if ( !$codonFile || !$seqFile );
40 my $codonIn = Bio::SeqIO->new(-file => $codonFile,
41 -format => 'fasta');
43 my $codonSeq = $codonIn->next_seq;
45 my $codonStats = Bio::Tools::SeqStats->count_codons($codonSeq);
47 my $codonUsage = Bio::CodonUsage::Table->new(-data => $codonStats );
49 my $codonTable = Bio::Tools::CodonTable->new;
51 my $seqIn = Bio::SeqIO->new(-file => $seqFile);
53 my $seq = $seqIn->next_seq;
55 my $rvSeq = $codonTable->reverse_translate_best($seq,$codonUsage);
57 print $rvSeq,"\n";
59 __END__