[Bioperl-l] Translate to 6 ORF's

Heikki Lehvaslaiho heikki@ebi.ac.uk
Tue, 23 Oct 2001 17:13:06 +0100


"Wiepert, Mathieu" wrote:
> 
> I want to translate a large fasta file with many sequences to proteins in
> all 6 ORF's.  The code is simple, copied from the docs somewhere.  Do I have
> to reverse the sequence and then translate to get the three reverse ORF's?

Yes. They are not ORFs but phases/frames, though.

Here is a simple way of doing it:

##################################################################
use Bio::SeqIO;

$in  = Bio::SeqIO->new('-file' => "file1.fa",
                       '-format' => 'Fasta');
$out = Bio::SeqIO->new(-file => ">file1_t1.fa" , 
                       '-format' => 'Fasta');
while ( my $seq = $in->next_seq() ) {
    my $c = 0;
    while ($c < 3) {
        $translation = $seq->translate(undef,undef,$c);
        $out->write_seq($translation);
        $translation = $seq->revcom->translate(undef,undef,$c);
        $out->write_seq($translation);
        $c++;
    }
}
##################################################################

Yours,
	-Heikki


> 
> use Bio::SeqIO;
> 
> $in  = Bio::SeqIO->new(-file => "file1.fa" , '-format' => 'Fasta');
> $out = Bio::SeqIO->new(-file => ">file1_t1.fa" , '-format' => 'Fasta');
> 
>     while ( my $seq = $in->next_seq() ) {
>         $translation = $seq->translate(undef,undef,0);
>         $out->write_seq($translation);
>     }
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l

-- 
______ _/      _/_____________________________________________________
      _/      _/                      http://www.ebi.ac.uk/mutations/
     _/  _/  _/  Heikki Lehvaslaiho          heikki@ebi.ac.uk
    _/_/_/_/_/  EMBL Outstation, European Bioinformatics Institute
   _/  _/  _/  Wellcome Trust Genome Campus, Hinxton
  _/  _/  _/  Cambs. CB10 1SD, United Kingdom
     _/      Phone: +44 (0)1223 494 644   FAX: +44 (0)1223 494 468
___ _/_/_/_/_/________________________________________________________