Hi all! I am new to perl, and this is my first post ever!

I am trying to translate nucleic acid sequences into amino acid sequences. I create a script (below). When I run the script with only the translate frames 0 & 1, then the script runs fine. Upon adding in the translate frame 2, the script stops working and I receive errors (below). Also, I tried running the translate frame 2 by itself, but receive the same errors.

I've tried searching these errors/message individually to troubleshoot myself, but I can't figure it out. Any guidance is much appreciated!

Script:

#!bin/perl -w use strict; use warnings; use Bio::SeqIO; #script to translate nucleotide sequences to amino acid sequences in f +irst three frames my $in = Bio::SeqIO->new(-file => "sequence.fasta", -format => "fasta" +); my $out = Bio::SeqIO->new(-file => ">Frame1.fasta", -format => "fasta" +); my $out2 = Bio::SeqIO->new(-file => ">Frame2.fasta", -format => "fasta +"); my $out3 = Bio::SeqIO->new(-file => ">Frame3.fasta", -format => "fasta +"); while ( my $seq = $in->next_seq() ) { my $prot = $seq->translate(); $out->write_seq($prot); my $prot2 = $seq->translate(-frame => 1); $out2->write_seq($prot2); my $prot3 = $seq->translate(-frame => 2); $out3->write_seq($prot3); }
Errors: substr outside of string at /sw/lib/perl5/5.16.2/Bio/PrimarySeqI.pm line 644, <GEN0> line 5013. ------------- EXCEPTION: Bio::Root::Exception ------------- MSG: Calling translate without a seq argument! STACK: Error::throw STACK: Bio::Root::Root::throw /sw/lib/perl5/5.16.2/Bio/Root/Root.pm:472 STACK: Bio::Tools::CodonTable::translate /sw/lib/perl5/5.16.2/Bio/Tools/CodonTable.pm:411 STACK: Bio::PrimarySeqI::translate /sw/lib/perl5/5.16.2/Bio/PrimarySeqI.pm:648 STACK: translateframe.pl:11 -----------------------------------------------------------

In reply to Error with Bio::Seq Translate by dmbNEWB

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.