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

Xianran Li xianranli78 at yahoo.com.cn
Wed Aug 1 04:11:53 EDT 2007


The $hseq->$hsp->hit_string() will return the string of hit sequence, rather than an objective of Bio::Seq. So may be you should construct a objective firstly, then you could use $seq_out->write_seq($hseq_obj) to write the seq into a fasta file.

# my $seq_out = Bio::SeqIO->new("-file" => ">$fasfilename", "-format" =>"fasta");
  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);
         $seq_out->write_result($hseq_obj);
      }
   }
}

Xianran
----- Original Message ----- 
From: "Alicia Amadoz" <Alicia.Amadoz at uv.es>
To: <bioperl-l at lists.open-bio.org>
Sent: Wednesday, August 01, 2007 3:13 PM
Subject: [Bioperl-l] trying to save blast hit sequences to fasta file


> 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
> code:
> 
> # my $seq_out = Bio::SeqIO->new("-file" => ">$fasfilename", "-format" =>
> "fasta");
> 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();
>          # $seq_out->write_seq($hseq);
>          $seq_out->write_result($hseq);
>       }
>    }
> }
> 
> Here the error is,
> 
> ------------- EXCEPTION: Bio::Root::Exception -------------
> MSG: ResultWriter not defined.
> 
> I couldn't find any kind of documentation about ResultWriter.
> Thanks in advance,
> Alicia
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-lÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿá¶Úÿÿ÷'þf¢—üš†Šÿ



More information about the Bioperl-l mailing list