Remove manipulation of @INC and use of lib - require install for use.
[bioperl-live.git] / examples / searchio / rawwriter.pl
blob5d1fb9ae8623a82eb6c9201fa05438125ff0d0ae
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>
24 # TODO:
25 # * Implement a Bio::SearchIO::Writer::HSPTextWriter object
26 # that can do this. Then this example can fit into the standard
27 # model used by the other writer examples in which a writer
28 # object is created and hooked up with a SearchIO output object.
30 use strict;
33 use Bio::SearchIO;
35 # In this case, we only want raw alignments, and we only need to screen
36 # on significance info (E- or P-value) so we don't need
37 # to do a full parse of the alignments. Thus, we're using a -shalow_parse
38 # flag to indicate that we don't need to parse alignments. This should
39 # result in faster processing.
40 # TODO: Convert this to use -format='blast'. Shallow-parse option not supported there.
41 my $in = Bio::SearchIO->new(-format => 'psiblast',
42 -fh => \*ARGV,
43 -signif => 0.1,
44 -shallow_parse => 1,
45 -hold_raw_data => 1 );
47 while ( my $result = $in->next_result() ) {
48 print STDERR "\nBLAST Results for $result\n\n";
49 my $count = 0;
50 foreach( $result->hits ) {
51 print "Alignment for hit #", ++$count, "\n\n";
52 print $_->raw_hit_data();
54 print "=" x 50 , "\n";
57 printf STDERR "\n%d Blast report(s) processed.\n", $in->result_count;