I think you can use the Bioperl methods subseq, translate and revcom to achieve what you want. A brief example using this test sequence, saved as nirs.fa:
#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;
my $file = "nirs.fa";
my $seqio = Bio::SeqIO->new(-file => "$file", -format => "fasta");
my $seqi = $seqio->next_seq;
my $s1 = $seqi->subseq(1,100);
my $s2 = $seqi->subseq(102,150);
# apologies for chaining together these methods...
# frame 1: in Bioperl frames 1,2,3 = 0,1,2
print Bio::Seq->new(-seq => $s1)->translate(-frame => 0)->seq, "\n";
# MKAKNWLYPAIAALPLSLWLGLPHAATKAEPKA
# frame -3: we reverse complement, then frame -3 = Bioperl frame 2
print Bio::Seq->new(-seq => $s2)->revcom->translate(-frame => 2)->seq, "\n";
# RGRTQRQ*GWGWRLS
I too am somewhat confused by EMBOSS transeq (but I think it is doing what you want). Here are the equivalent commands, with results:
transeq -sequence nirs.fa -frame 1 -regions 1:100 -stdout -auto
# >2576786-2578450_1 Ralstonia eutropha H16 chromosome 2, complete sequence
# MKAKNWLYPAIAALPLSLWLGLPHAATKAEPKAX
transeq -sequence nirs.fa -frame -3 -regions 102:150 -stdout -auto
# >2576786-2578450_6 Ralstonia eutropha H16 chromosome 2, complete sequence
# RGRTQRQ*GWGWRLSV
So transeq seems to be returning one residue more. I'm sure there's a good explanation if we think about it. Maybe the Bioperl method assumes that the last 3 bases are a terminator unless told otherwise.
I get the correct frames from parsing my blastx output by printing out $hsp->hitstring or $hsp->querystring.thats not the issue what I would like is to adjust that information from the blast output so that instead of getting 5 or 6 fragments of the protein I get a single string that is correct for the protein in the several frames blastx has detected. I thought I could do this with transec, but for any given information in the blast table it shows a different result to the transec output (I've also corrected the GFF frame() used in SearchIO to show the blastX frame).Is blast skipping bases?
Also it doesn't allow multiple commands
I think your probably right about transeq though... too much "intuition"
I would not use the BLAST output for this task. Since BLAST tells you the frames, why not just go back to the original input sequence? As your question says: "How do I translate different regions of my sequence in different frames."