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

Ewan Birney birney@ebi.ac.uk
Mon, 28 May 2001 13:29:38 +0100 (BST)


On Mon, 28 May 2001, Marc Logghe wrote:

> Hi,
> I am currently trying to find my way in BioPerl an playing around a little.
> I struck into the following 'problem' (at least for me): you can easily
> convert a sequence from, let's say  raw to fasta using SeqIO via a file
> handle but I did not find how to get the output into a string variable
> directly without using a file handle. On the other hand I could find this
> line in Blast.pm: $hsp->seq('query')->layout('fasta'). The seq method should
> return a Bio::Seq object but this object does not 'can' this method.
> Can somebody please help me out ?

here we go:

$seqio = Bio::SeqIO->new( -format => 'fasta', -file => 'myfile');
$seq = $seqio->next_seq; # first sequence from teh file

# $seq is a Bio::Seq object

print "sequence as string is ",$seq->seq,"\n";
print "first 10 residues are ",$seq->subseq(1,10),"\n";
print "name (id) is ",$seq->id,"\n";


For more info, look at the Bio::Seq documentation, ie

perldoc Bio::Seq 



(assumming you have installed Bioperl, not just made PERL5LIB point at it)



> Thanks a lot and keep up the good work
> Marc
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
> 

-----------------------------------------------------------------
Ewan Birney. Mobile: +44 (0)7970 151230, Work: +44 1223 494420
<birney@ebi.ac.uk>. 
-----------------------------------------------------------------