[Bioperl-l] Parsing sequence records in memory

Marc Logghe Marc.Logghe@devgen.com
Sun, 15 Dec 2002 22:08:43 +0100


Hi Peter,
Supposed that a fasta sequence is stored in the scalar $s, something like
this should do it:
use Bio::SeqIO;
use IO::String;

my $s = <<SEQ;
>blah
AERTYIPQSDFGHKLMWCVN
SEQ

my $io = IO::String->new($s);
my $in = Bio::SeqIO->new(-fh => $io, -format => 'fasta');
my $seq = $in->next_seq;
print $seq->seq;
Regards,
Marc, your biggest bptutorial.pl -100 fan ;-)

> -----Original Message-----
> From: Peter Schattner [mailto:schattner@alum.mit.edu]
> Sent: Sunday, December 15, 2002 9:54 PM
> To: bioperl-l@bioperl.org
> Subject: [Bioperl-l] Parsing sequence records in memory
> 
> 
> Hi folks
> 
> A question.
> 
> If I have, say, a fasta sequence or Genbank record stored in 
> a perl variable
> in memory (either the complete record in a scalar or each 
> line as an entry in
> an array), is it possible to have SeqIO parse that record and 
> create a Seq
> object directly?  That is, without printing the record to a 
> file first and
> then reading it back in with SeqIO.  (I guess writing records 
> to a file is
> not such a big deal, but I would prefer not to be creating 
> and destroying
> lots of temporary files)
> 
> TIA
> 
> Peter
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>