[Bioperl-l] help using SEARCH IO to parse blast results

Sendu Bala bix at sendu.me.uk
Tue Nov 27 12:01:36 EST 2007


alison waller wrote:
> I am trying to write a script that will parse large blast files (usually
> blastx) I also want to be able to specify how many hits I want to report
> information on.
> 
> Most of the time I will only want information on the top hit, but I want to
> have the flexibility to obtain information on say the top5.  I am pretty
> sure I have done this wrong, any advice on how to correct my script to do
> this, would be great.

[snip]

>       if ($top_hit=$result->next_hit) # this might be wrong - I want to
> specify how many hits to print results for

I didn't really pay attention to the rest of your code, but assuming it 
all works except for only ever giving you info for the top hit, you just 
need to change this 'if' to a loop of some kind.

# ...
my $hits = 0;

while (my $hit = $result->next_hit) {
  $hits++;
  last if $hits > $tophit;
  # ...
}


More information about the Bioperl-l mailing list