[Bioperl-l] Newbie question: fasta output to string

Heikki Lehvaslaiho heikki@ebi.ac.uk
Mon, 28 May 2001 22:43:27 +0100


Just for completeness sake, here is what I do with Bio::Variation::IO which
is a subclass of Bio::SeqIO and IO::String.

====================================================
use IO::String; 

my $s;
my $io = IO::String->new($s);
my $out = Bio::Variation::IO->new('-fh'   => $io,
				  '-format' => 'xml'
				  );

# $results is a Bio::Variation::SeqDiff
$out->write($results);

#escape tag delimiters
$s =~ s/</&lt;/g;
$s =~ s/>/&gt;/g;
#... 
#and finally:
print $s;
=================================================

One does not have to mess with tieing...

	-Heikki

Ewan Birney wrote:
> 
> Look into the IO::String module and friends (lets an array of strings
> behave as if it is a file).
> 
> -----------------------------------------------------------------
> Ewan Birney. Mobile: +44 (0)7970 151230, Work: +44 1223 494420
> <birney@ebi.ac.uk>.
> -----------------------------------------------------------------
> 
> _______________________________________________
> 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
___ _/_/_/_/_/________________________________________________________