tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / examples / searchio / rawwriter.pl
blob2fde90db5e4cb8e46ab795b36197e4b11dda88e3
1 #!/usr/bin/env perl
3 # Demonstrates the use of a SearchIO Blast parser for producing
4 # output of raw HSP data from a Blast report input stream.
6 # Shows how to print out raw BLAST alignment data for each HSP.
8 # Usage:
9 # STDIN: stream containing one or more BLAST or PSI-BLAST reports.
10 # STDOUT: Raw alignment data for each HSP of each hit (BLAST format)
11 # STDERR: Progress info and any errors.
13 # For more documentation about working with Blast result objects,
14 # see docs for these modules:
15 # Bio::Search::Result::BlastResult
16 # Bio::Search::Hit::BlastHit
17 # Bio::Search::HSP::BlastHSP
19 # For more documentation about the PSI-Blast parser, see docs for
20 # Bio::SearchIO::psiblast
22 # Author: Steve Chervitz <sac@bioperl.org>
23 # Revision: $Id$
25 # TODO:
26 # * Implement a Bio::SearchIO::Writer::HSPTextWriter object
27 # that can do this. Then this example can fit into the standard
28 # model used by the other writer examples in which a writer
29 # object is created and hooked up with a SearchIO output object.
31 use strict;
33 use lib '../../';
35 use Bio::SearchIO;
37 # In this case, we only want raw alignments, and we only need to screen
38 # on significance info (E- or P-value) so we don't need
39 # to do a full parse of the alignments. Thus, we're using a -shalow_parse
40 # flag to indicate that we don't need to parse alignments. This should
41 # result in faster processing.
42 # TODO: Convert this to use -format='blast'. Shallow-parse option not supported there.
43 my $in = Bio::SearchIO->new(-format => 'psiblast',
44 -fh => \*ARGV,
45 -signif => 0.1,
46 -shallow_parse => 1,
47 -hold_raw_data => 1 );
49 while ( my $result = $in->next_result() ) {
50 print STDERR "\nBLAST Results for $result\n\n";
51 my $count = 0;
52 foreach( $result->hits ) {
53 print "Alignment for hit #", ++$count, "\n\n";
54 print $_->raw_hit_data();
56 print "=" x 50 , "\n";
59 printf STDERR "\n%d Blast report(s) processed.\n", $in->result_count;