My overall goal is converting DNA to AMINO ACIDS (protein). (DNA to RNA is transcription, not translation).
Here is information from BioPerl for using this function:
http://search.cpan.org/~cjfields/BioPerl-1.6.924/Bio/PrimarySeqI.pm#translate
"Function: Provides the translation of the DNA sequence using full
IUPAC ambiguities in DNA/RNA and amino acid codes."
Here is the code example from the Beginner's guidelines:
$prot_obj = $my_seq_object->translate(-frame => 1);
And here is an example code I found online in which they call using Bio::SeqIO
#!/usr/bin/perl -w
use strict;
use Bio::Seq;
use Bio::SeqIO;
my $input = $ARGV[0];
my $seqio_obj = Bio::SeqIO->new(-file => $input, -format => "fasta" );
my $line_count;
# process multi-fasta sequences
while(my $seq_obj = $seqio_obj->next_seq){
$line_count++;
# print "===========================================================\
+n";
# obtain id of the nt sequence
my $id = $seq_obj->display_id;
# print id of nt sequence
# print "SEQ ID\t>\t", $id, "\n";
# print "===========================================================\
+n";
# use translate to convert amino acid squence to protein sequence fr
+om frame 0 (default)
# 'complete' - do some checks for ORF
# print ">>>>>>>> Frame 0 <<<<<<<\n";
print ">", $id, "-0", "\n";
my $prot_obj = $seq_obj->translate();
# print the protein sequence
print $prot_obj->seq,"\n";
# print "\n";
# print ">>>>>>>> Frame 1 <<<<<<<\n";
# translation starting from the second nucleotide (frame 1)
print ">", $id, "-1", "\n";
$prot_obj = $seq_obj->translate(-frame => 1);
# print the protein sequence
print $prot_obj->seq,"\n";
# print "\n";
My script is working fine for the default frame, for the 1st frame, and until line 5401 for the 2nd frame. The part that messes up is when it gets to the (-frame => 2) file, but even that file works until line 5401. So I don't think it is an input issue.
And thank you for the above code, but I am translating to amino acids. |