[Bioperl-l] trying to save blast hit sequences to fasta file
torsten.seemann at infotech.monash.edu.au
Wed Aug 1 20:50:06 EDT 2007
> Hi, I would like to save my hit sequences from a blast result in a fasta
> file. I am trying some things but I have problems using Bio::SearchIO
> and Bio::SeqIO. Hope anyone could help me with this. Here is my current
> # my $seq_out = Bio::SeqIO->new("-file" => ">$fasfilename", "-format" =>
> my $seq_out = Bio::SearchIO->new("-file" => ">$fasfilename", "-format"
> => "fasta");
> my $hseq = $hsp->hit_string();
> # $seq_out->write_seq($hseq);
You have encountered two common problems for BioPerl beginners:
1. "fasta" means two different things! In SearchIO it refers to the
output format of the "fasta" sequence alignment software. In SeqIO it
refers to a file format that stores just sequences. Confusing, I know.
You need SeqIO and write_seq, not SearchIO and write_result.
2. $hseq is a STRING which has the raw sequence letters in it.
However, the write_seq() method needs a Bio::Seq object (which has
extra details like the name and ID) not a raw string.
The example code Jay Hannah supplied in his reply looks pretty good,
you should try it.
--Victorian Bioinformatics Consortium, Monash University
More information about the Bioperl-l