[Bioperl-l] trying to save blast hit sequences to fasta file

Alicia Amadoz Alicia.Amadoz at uv.es
Wed Aug 1 10:25:29 UTC 2007


Hi, I have tried what you suggested and I get also some errors.
With this code,

my $seq_out = Bio::SearchIO->new("-file" => ">$fasfilename", "-format"
=> "fasta");
while(my $result = $blast_report->next_result()) {
   while(my $hit = $result->next_hit()) {
      while(my $hsp = $hit->next_hsp()) {
	my $hseq = $hsp->hit_string(); 
        $hseq =~ s/-//g; #### remove the gap within the aligment
        my $hseq_obj = Bio::Seq->new(-display_id => $id, -seq => $hseq); 
        $seq_out->write_seq($hseq_obj);
      }
   }				
}

I have the following error:

Can't locate object method "write_seq" via package "Bio::SearchIO::fasta"

And using write_result methog with this code,

my $seq_out = Bio::SearchIO->new("-file" => ">$fasfilename", "-format"
=> "fasta");
while(my $result = $blast_report->next_result()) {
   while(my $hit = $result->next_hit()) {
      while(my $hsp = $hit->next_hsp()) {
	my $hseq = $hsp->hit_string(); 
        $hseq =~ s/-//g; #### remove the gap within the aligment
        my $hseq_obj = Bio::Seq->new(-display_id => $id, -seq => $hseq); 
        $seq_out->write_result($hseq_obj);
      }
   }				
}

I have again this kind of error:

------------- EXCEPTION: Bio::Root::Exception -------------
MSG: ResultWriter not defined.
STACK: Error::throw

So, what else can I try?? Thanks in advance,
Alicia





More information about the Bioperl-l mailing list