~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to scripts/seq/bp_make_mrna_protein.pl

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!perl
 
2
#
 
3
=head1 NAME
 
4
 
 
5
bp_make_mrna_protein - Convert an input mRNA/cDNA sequence into protein
 
6
 
 
7
=head1 DESCRIPTION
 
8
 
 
9
Convert an input mRNA/cDNA sequence into protein using translate()
 
10
 
 
11
  -f/--frame           Specifies frame [0,1,2]
 
12
 
 
13
One can also specify:
 
14
 
 
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')
 
24
 
 
25
See L<Bio::PrimarySeq> for more information on codon tables
 
26
and the translate() method
 
27
 
 
28
=head1 AUTHOR - Jason Stajich
 
29
 
 
30
  Email jason-at-bioperl-dot-org
 
31
 
 
32
=cut
 
33
 
 
34
use strict;
 
35
use warnings;
 
36
use Bio::SeqIO;
 
37
use Getopt::Long;
 
38
 
 
39
use vars qw($USAGE);
 
40
 
 
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)
 
55
};
 
56
 
 
57
}
 
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);
 
61
 
 
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,
 
73
                         );
 
74
 
 
75
die $USAGE if( $help );
 
76
 
 
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);
 
82
}
 
83
 
 
84
if( $output ) { 
 
85
        $out = new Bio::SeqIO('-format' => $oformat, '-file' => ">$output" );
 
86
} else {
 
87
        $out = new Bio::SeqIO('-format' => $oformat );
 
88
}
 
89
 
 
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);
 
98
}
 
99
 
 
100
__END__