Tiago Hori | 7 Feb 15:58 2013
Picon

Re: Search I::O

Thanks, Jason! It is working Now.

So here is what I am trying to accomplish. For a given Blastx report, I 
want to extract the best BLASTx hit that is human, and does not contain 
unnamed or Predicted. I got very close, but I still can't get it to give me 
only the top BLAST hit, it gives me all blast hits that meet my criteria. I 
tried using "last" to stop it from looping through the hits, once it found 
a human one, but it didn't work. Can someone help? Here is my code so far 
(mostly stolen for the wiki).

use strict;
use Bio::SearchIO; 

my $in = new Bio::SearchIO(-format => 'blast', 
                           -file   => 'testsalmon.txt');
while( my $result = $in->next_result ) {
 ## $result is a Bio::Search::Result::ResultI compliant object
  while( my $hit = $result->next_hit ) {
  ## $hit is a Bio::Search::Hit::HitI compliant object    
    if( $hit->description !~ /[Uu]nnamed|PREDICTED|hypothetical/){        
      if( $hit->description =~ /Homo sapiens/){  
         while( my $hsp = $hit->next_hsp ) {
          ## $hsp is a Bio::Search::HSP::HSPI compliant object
              if( $hsp->length('total') > 50 ) {
                if ( $hsp->percent_identity >= 30) {
              if( $hsp->evalue <= 1e-05){
               print "Query=",   $result->query_name,"\t",
                     " Description=",    $hit->description,"\t",
                     " Hit=",        $hit->name,"\t",
                     " Length=",     $hsp->length('total'),"\t",
                     " Percent_id=", $hsp->percent_identity,"\t",
          }
        }
          }
     }
      }
    }
  }
}

T.

On Wednesday, February 6, 2013 6:46:47 PM UTC-3:30, Jason Stajich wrote:
>
> you are missing a comma after the -format => 'blast' 
> should be 
> my $in = Bio::SearchIO->new(-format => 'blast',   
>   -file => 'XXX' ); 
>
>
> On Feb 5, 2013, at 7:21 AM, Tiago Hori <tiago... <at> gmail.com <javascript:>> 
> wrote: 
>
> > Hi All, 
> > 
> > I am trying to find the best putative orthologs for 44K Atlantic Salmon 
> > sequences, and so I need to parse 44K BLAST reports to find the best 
> human 
> > hit. I am trying to learn Seach::IO, but when I try the first example on 
> > the HOWTO: use strict; 
> > use Bio::SearchIO; 
> > 
> > my $in = new Bio::SearchIO(-format => 'blast' 
> >               -file => 'C001R047.txt'); 
> > 
> > while( my $result = $in->next_result ) { 
> >  ## $result is a Bio::Search::Result::ResultI compliant object 
> >  while( my $hit = $result->next_hit ) { 
> >    ## $hit is a Bio::Search::Hit::HitI compliant object 
> >    while( my $hsp = $hit->next_hsp ) { 
> >      ## $hsp is a Bio::Search::HSP::HSPI compliant object 
> >      if( $hsp->length('total') > 50 ) { 
> >        if ( $hsp->percent_identity >= 75 ) { 
> >          print "Query=",   $result->query_name, 
> >            " Hit=",        $hit->name, 
> >            " Length=",     $hsp->length('total'), 
> >            " Percent_id=", $hsp->percent_identity, "\n"; 
> >        } 
> >      } 
> >    }   
> >  } 
> > } 
> > 
> > I get this error: Odd number of elements in hash assignment at 
> > /usr/local/share/perl/5.14.2/Bio/SearchIO.pm line 189. 
> > 
> > I am using BioPerl version 1.6.901. Is there a format problem with the 
> > blast reports? 
> > 
> > Any help would be greatly appreciated! 
> > 
> > T. 
> > _______________________________________________ 
> > Bioperl-l mailing list 
> > Biop... <at> lists.open-bio.org <javascript:> 
> > http://lists.open-bio.org/mailman/listinfo/bioperl-l 
>
> Jason Stajich 
> jason.... <at> gmail.com <javascript:> 
> ja... <at> bioperl.org <javascript:> 
>
>

Gmane