maint: remove Travis stuff which has been replaced with Github actions (#325)
[bioperl-live.git] / examples / searchio / htmlwriter.pl
blobe29195e28009a47fccdeb2db4ffc6ac03b41594d
1 #!/usr/bin/perl
3 # Demonstrates the use of a SearchIO Blast parser and a SearchWriterI object
4 # for producing HTML Blast output from a Blast report input stream.
6 # Usage:
7 # STDIN: none; supply filename of BLAST report on command-line
8 # STDOUT: none; generates an output file "searchio.html"
9 # containing HTML-formatted Blast Report
10 # STDERR: Any errors that occurred.
12 # For more documentation about the writer, including
13 # a complete list of columns, see the docs for
14 # Bio::SearchIO::Writer::HTMLResultWriter.
16 # For more documentation about working with Blast result objects,
17 # see docs for these modules:
18 # Bio::Search::Result::BlastResult
19 # Bio::Search::Iteration::IterationI
20 # Bio::Search::Hit::BlastHit
21 # Bio::Search::HSP::BlastHSP
23 # For more documentation about the Blast parser, see docs for
24 # Bio::SearchIO
26 # Author: Steve Chervitz <sac@bioperl.org>
29 use strict;
31 use Bio::SearchIO;
32 use Bio::SearchIO::Writer::HTMLResultWriter;
34 my $outfile = "searchio.html";
35 my $file = shift or die "Usage: $0 <BLAST-report-file>\n HTML output is saved to $outfile\n";
37 my $in = Bio::SearchIO->new( -format => 'blast',
38 -file => $file, #comment this out to read STDIN
39 #-fh => \*ARGV, #uncomment this to read from STDIN
40 -verbose => 0 );
42 my $writer = new Bio::SearchIO::Writer::HTMLResultWriter();
43 my $out = new Bio::SearchIO(-writer => $writer,
44 -file => ">$outfile");
47 while ( my $result = $in->next_result() ) {
48 eval {
49 # printf STDERR "Report %d: $result\n", $in->result_count;
50 $out->write_result($result, 1);
52 if($@) {
53 warn "Warning: Blast parsing or writing exception caught for $result:\n$@\n";
57 printf STDERR "\n%d Blast report(s) processed.\n", $in->result_count;
58 printf STDERR "Output sent to file: %s\n", $out->file if $out->file;