[Bioperl-l] Help with reversing a sequence

Jason Stajich jason at cgt.duhs.duke.edu
Mon Feb 23 13:53:38 EST 2004


The perl reverse cmd is what you want that does exactly what you want --
reverse a string.  What is slow specifically?  Did you benchmark
something?

-jason
On Mon, 23 Feb 2004, Paul St. Amand wrote:

> Hi,
>
> I am using the following script to get a subsequence and reverse it.
> Note that I do NOT want the "reverse complement" of the sequence here,
> just the actual reverse. BioPerl has a method to get the revcom of a
> seq, such as:
>
> print $outputfh "Reverse complemented sequence 5 to 10  is
> ",$seqobj->trunc(5,10)->revcom->seq, "  \n";
>
> Does BioPerl have a similar/better way to get the reverse (not revcom)
> of a sequence?
>
> This is how I am doing it and it is slow. Is there a way that is faster
> or "better" using BioPerl???
>
>
> use strict;
> use warnings;
> use Bio::SeqIO;
> my $outputfh = *STDOUT;
>
>      my ($infile, $in, $out, $seqobj);
>      $infile = shift or die;
>
>      $in  = Bio::SeqIO->new('-file' => $infile ,
>                             '-format' => 'Fasta');
>      $seqobj = $in->next_seq();
>
>      $out = Bio::SeqIO->newFh('-format'   => 'fasta',
> 			     '-noclose'  => 1,
> 			     '-fh'       => $outputfh);
>
> print $outputfh ">MyReversedSeq29856-29862\n",scalar
> reverse($seqobj->subseq(29856,29862)),"\n";
>
>
>
>
>
> Thanks,
> Paul
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list