3 # Demonstrates the use of a SearchIO parser for processing
4 # the iterations within a PSI-BLAST report.
7 # STDIN: none; supply filename of PSI-BLAST report on command-line
8 # STDOUT: information parsed from the input data.
11 # For more documentation about working with Iteration objects,
13 # Bio::Search::Iteration::IterationI
15 # Author: Steve Chervitz <sac@bioperl.org>
21 my $file = shift or die "Usage: $0 <BLAST-report-file>\n";
22 my $in = new Bio
::SearchIO
(-format
=> 'blast',
23 -file
=> $file, #comment this out to read STDIN
24 #-fh => \*ARGV, #uncomment this to read STDIN
27 # Iterate over all results in the input stream
28 while (my $result = $in->next_result) {
30 printf "Result #%d: %s\n", $in->result_count, $result->to_string;
31 printf "Total Iterations: %d\n", $result->num_iterations();
33 # Iterate over all iterations and process old and new hits
36 while( my $it = $result->next_iteration) {
37 printf "\nIteration %d\n", $it->number;
38 printf "Converged: %d\n", $it->converged;
40 # Print out the hits not found in previous iteration
41 printf "New hits: %d\n", $it->num_hits_new;
42 while( my $hit = $it->next_hit_new ) {
43 printf " %s, Expect=%g\n", $hit->name, $hit->expect;
46 # Print out the hits found in previous iteration
47 printf "Old hits: %d\n", $it->num_hits_old;
48 while( my $hit = $it->next_hit_old ) {
49 printf " %s, Expect=%g\n", $hit->name, $hit->expect;
52 printf "%s\n\n", '-' x
50;
55 printf "Total Reports processed: %d: %s\n", $in->result_count;
59 # NOTE: The following functionality is just proposed
60 # (does not yet exist but might, given sufficient hew and cry):
62 # Zero-in on the new hits found in last iteration.
63 # By default, iteration() returns the last one.
65 my $last_iteration = $result->iteration();
66 while( my $hit = $last_iteration->next_hit) {
67 # Do something with new hit...
70 # Get the first iteration
72 my $first_iteration = $result->iteration(1);