[Bioperl-l] SearchIO - Stop throwing away data

Jayne Vallance jaynelvallance at hotmail.com
Mon Jul 24 09:45:50 UTC 2006


Hi

I developing someone
elses work. I wondered whether anyone could identify the
mistake that the previous coder made?
I am not very familiar with SearchIO yet.

They are trying to extract filenames from an output report.
This is their code:

     # store the query name of the mito db blast hits into an array
     my $searchio = new Bio::SearchIO( -file   => $blast_mito_output );
     # array to store the mitochondrial BLAST database hits
     my @mito_hits;
     # name of query for BLAST hit
     my $query_name;

while ( my $result = $searchio->next_result() ) {
    # get the hits and their associated name
    # do not want to include these in the clustering step
    while( my $hit = $result->next_hit ) {
      # store the names of these hits into an array
      # these filenames will not be copied over
      $query_name = $result->query_name();
      #print "\nQuery $query_name\n";
      push(@mito_hits, $query_name);
    }
}

I think they have based it on the code at
http://www.bioperl.org/wiki/HOWTO:SearchIO#Authors

use Bio::SearchIO;
use Bio::SearchIO::FastHitEventBuilder;
my $searchio = new Bio::SearchIO(-format => $format, -file => $file);

$searchio->attach_EventHandler(Bio::SearchIO::FastHitEventBuilder->new);
while( my $r = $searchio->next_result ) {
while( my $h = $r->next_hit ) {
  #   Hits will NOT have HSPs
  print $h->significance,"\n";
}

which "throws away data you don't want"???

I am finding that our code is finding the last file name in the ouput 
report,
rather than each and every one. I suspect it is overwriting (or throwing 
away the data).

How do I need to change the code to make sure *every* file name goes
into @mito_hits?

Thankyou

Jayne

_________________________________________________________________
The new MSN Search Toolbar now includes Desktop search! 
http://join.msn.com/toolbar/overview




More information about the Bioperl-l mailing list