Add tsibley's work to Changes file
[bioperl-live.git] / scripts / seq / bp_make_mrna_protein.pl
blobc37c31021890694a021fc371181c670228218ff8
1 #!perl
3 =head1 NAME
5 bp_make_mrna_protein - Convert an input mRNA/cDNA sequence into protein
7 =head1 DESCRIPTION
9 Convert an input mRNA/cDNA sequence into protein using translate()
11 -f/--frame Specifies frame [0,1,2]
13 One can also specify:
15 -t/--terminator Stop Codon character (defaults to '*')
16 -u/--unknown Unknown Protein character (defaults to 'X')
17 -cds/--fullcds Expected Full CDS (with start and Stop codon)
18 -throwOnError Throw error if no Full CDS (defaults to 0)
19 -if/--format Input format (defaults to FASTA/Pearson)
20 -of/--format Output format (defaults to FASTA/Pearson)
21 -o/--output Output Filename (defaults to STDOUT)
22 -i/--input Input Filename (defaults to STDIN)
23 -ct/--codontable Codon table to use (defaults to '1')
25 See L<Bio::PrimarySeq> for more information on codon tables
26 and the translate() method
28 =head1 AUTHOR - Jason Stajich
30 Email jason-at-bioperl-dot-org
32 =cut
34 use strict;
35 use warnings;
36 use Bio::SeqIO;
37 use Getopt::Long;
39 use vars qw($USAGE);
41 BEGIN {
42 $USAGE =
43 qq{make_mrna_protein.pl < file.fa > file.prots
44 -f/--frame Translation Frame (0,1,2) are valid (defaults to '0')
45 -t/--terminator Stop Codon Character ('*' by default)
46 -u/--unknown Unknown Protein character (defaults to 'X')
47 -ct/--codontable Codon table to use (defaults to '1')
48 (see Bio::PrimarySeq for more information)
49 -cds/--fullcds Expected Full CDS (with start and Stop codon)
50 -throwOnError Throw an error if no Full CDS (defaults to 0)
51 -if/--iformat Input format (defaults to FASTA/Pearson)
52 -of/--oformat Output format (defaults to FASTA/Pearson)
53 -o/--output Output Filename (defaults to STDOUT)
54 -i/--input Input Filename (defaults to STDIN)
58 my ($iformat, $oformat, $frame, $termchar, $unknownProt, $codontable, $fullCDS,
59 $throw_on_Incomp_CDS, $help) = ('fasta','fasta', 0, undef, undef, 1, 0, 0);
60 my ($input,$output);
62 GetOptions('f|frame:s' => \$frame,
63 't|terminator:s' => \$termchar,
64 'u|unknown:s' => \$unknownProt,
65 'ct|codontable:s' => \$codontable,
66 'cds|fullcds' => \$fullCDS,
67 'throwOnError' => \$throw_on_Incomp_CDS,
68 'h|help' => \$help,
69 'i|input:s' => \$input,
70 'if|iformat:s' => \$iformat,
71 'of|oformat:s' => \$oformat,
72 'o|output:s' => \$output,
75 die $USAGE if( $help );
77 my ($in,$out);
78 if( $input ) {
79 $in = new Bio::SeqIO('-format' => $iformat, '-file' => $input);
80 } else {
81 $in = new Bio::SeqIO('-format' => $iformat, '-fh' => \*STDIN);
84 if( $output ) {
85 $out = new Bio::SeqIO('-format' => $oformat, '-file' => ">$output" );
86 } else {
87 $out = new Bio::SeqIO('-format' => $oformat );
90 while( my $seq = $in->next_seq ) {
91 my $protseq = $seq->translate(-terminator => $termchar,
92 -unknown => $unknownProt,
93 -frame => $frame,
94 -codontable_id => $codontable,
95 -complete => $fullCDS,
96 -throw => $throw_on_Incomp_CDS );
97 $out->write_seq($protseq);
100 __END__