[Bioperl-l] Help with reversing a sequence

Paul St. Amand pst at ksu.edu
Mon Feb 23 14:21:16 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

No, I did not benchmark it and speed is really secondary to the 
question of "what is the best way to do this using BioPerl". I was just 
wondering if BioPerl had its own function or method for reversing like 
it has for revcom.

So, the reverse that I am using below is the best way?

 > print $outputfh ">MyReversedSeq29856-29862\n",scalar
 > reverse($seqobj->subseq(29856,29862)),"\n";

Thanks!
Paul
PS, I am not subscribed to BioPerl-l, so I could not post a reply 
on-line.




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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 3071 bytes
Desc: not available
Url : http://portal.open-bio.org/pipermail/bioperl-l/attachments/20040223/68cfa05b/attachment.bin


More information about the Bioperl-l mailing list