23
23
use Bio::SearchIO::Writer::HTMLResultWriter;
25
my $in = new Bio::SearchIO(-format => 'blast',
25
my $in = Bio::SearchIO->new(-format => 'blast',
26
26
-file => shift @ARGV);
28
my $writer = new Bio::SearchIO::Writer::HTMLResultWriter();
29
my $out = new Bio::SearchIO(-writer => $writer);
28
my $writer = Bio::SearchIO::Writer::HTMLResultWriter->new();
29
my $out = Bio::SearchIO->new(-writer => $writer);
30
30
$out->write_result($in->next_result);
41
41
return $hsp->num_hits > 0;
44
my $writer = new Bio::SearchIO::Writer::HTMLResultWriter
44
my $writer = Bio::SearchIO::Writer::HTMLResultWriter->new
45
45
(-filters => { 'HSP' => \&hsp_filter} );
46
my $out = new Bio::SearchIO(-writer => $writer);
46
my $out = Bio::SearchIO->new(-writer => $writer);
47
47
$out->write_result($in->next_result);
49
49
# can also set the filter via the writer object
282
281
# no HSPs so no link
283
282
$str .= sprintf('<tr><td>%s %s</td><td>%s</td><td>%.2g</td></tr>'."\n",
284
283
$url_desc, $descsub,
285
($hit->raw_score ? $hit->raw_score :
286
(defined $hsps[0] ? $hsps[0]->score : ' ')),
284
($hit->bits ? $hit->bits :
285
(defined $hsps[0] ? $hsps[0]->bits : ' ')),
287
286
( $hit->significance ? $hit->significance :
288
287
(defined $hsps[0] ? $hsps[0]->evalue : ' '))
294
293
$str .= sprintf('<tr><td>%s %s</td><td>%s</td><td><a href="#%s">%.2g</a></td></tr>'."\n",
295
294
$url_desc, $descsub,
296
($hit->raw_score ? $hit->raw_score :
297
(defined $hsps[0] ? $hsps[0]->score : ' ')),
295
($hit->bits ? $hit->bits :
296
(defined $hsps[0] ? $hsps[0]->bits : ' ')),
299
298
( $hit->significance ? $hit->significance :
300
299
(defined $hsps[0] ? $hsps[0]->evalue : ' '))
301
my $dline = &{$self->hit_desc_line}($self, $hit, $result);
302
302
$hspstr .= "<a name=\"$acc\">\n".
303
sprintf("><b>%s</b> %s\n<dd>Length = %s</dd><p>\n\n", $url_align,
304
defined $hit->description ? $hit->description : '',
305
&_numwithcommas($hit->length));
303
sprintf("><b>%s</b> %s</br><dd>Length = %s</dd><p>\n\n", $url_align,
304
$dline , &_numwithcommas($hit->length));
307
306
foreach my $hsp (@hsps ) {
308
307
next if( $hspfilter && ! &{$hspfilter}($hsp) );
417
416
length($hspvals[2]->{'start'}),
418
417
length($hspvals[2]->{'end'}));
420
while ( $count <= $hsp->length('total') ) {
419
while ( $count < $hsp->length('total') ) {
421
420
foreach my $v ( @hspvals ) {
422
421
my $piece = substr($v->{'seq'}, $v->{'index'} + $count,
423
422
$AlignmentLineWidth);
453
452
# $hspstr .= "</pre>\n";
457
# make table of search statistics and end the web page
458
$str .= "</table><p>\n".$hspstr."<p><p><hr><h2>Search Parameters</h2><table border=1><tr><th>Parameter</th><th>Value</th>\n";
455
$str .= "</table><p>\n".$hspstr;
456
my ($pav, $sav) = ($result->available_parameters, $result->available_statistics);
458
# make table of search statistics and end the web page
459
$str .= "<p><p><hr><h2>Search Parameters</h2>";
461
$str .= "<table border=1><tr><th>Parameter</th><th>Value</th>\n";
462
foreach my $param ( sort $result->available_parameters ) {
463
$str .= "<tr><td>$param</td><td>". $result->get_parameter($param) ."</td></tr>\n";
460
foreach my $param ( sort $result->available_parameters ) {
461
$str .= "<tr><td>$param</td><td>". $result->get_parameter($param) ."</td></tr>\n";
464
$str .= "</table><p><h2>Search Statistics</h2><table border=1><tr><th>Statistic</th><th>Value</th></tr>\n";
465
foreach my $stat ( sort $result->available_statistics ) {
466
$str .= "<tr><td>$stat</td><td>". $result->get_statistic($stat). "</td></tr>\n";
468
$str .= "</table><P>".$self->footer() . "<P>\n";
469
$str .= "<p><h2>Search Statistics</h2><table border=1><tr><th>Statistic</th><th>Value</th></tr>\n";
470
foreach my $stat ( sort $result->available_statistics ) {
471
$str .= "<tr><td>$stat</td><td>". $result->get_statistic($stat). "</td>\n";
473
$str .= "</tr></table>";
476
$str .= $self->footer() . "<P>\n";
496
504
=head2 default_hit_link_desc
498
Title : defaulthit_link_desc
506
Title : default_hit_link_desc
499
507
Usage : $self->default_hit_link_desc($hit, $result)
500
508
Function: Provides an HTML link(s) for the given hit to be used
501
509
within the description section at the top of the BLAST report.
559
567
return $self->{'_hit_link_align'} || \&default_hit_link_desc;
572
Title : hit_desc_line
573
Usage : $self->hit_desc_line(\&link_function);
574
Function: Get/Set the function which provides HTML for the description
575
information from a hit. This allows one to parse
576
the rest of the description and split up lines, add links, etc.
577
Returns : Function reference
578
Args : Function reference
579
See Also: L<default_hit_link_desc()>
584
my( $self, $code ) = @_;
586
$self->{'_hit_desc_line'} = $code;
588
return $self->{'_hit_desc_line'} || \&default_hit_desc_line;
591
=head2 default_hit_desc_line
593
Title : default_hit_desc_line
594
Usage : $self->default_hit_desc_line($hit, $result)
595
Function: Parses the description line information, splits based on the
596
hidden \x01 between independent descriptions, checks the lines for
597
possible web links, and adds HTML link(s) for the given hit to be
600
Returns : string containing HTML markup "<a href...")
601
The default implementation returns an HTML link to the
602
URL supplied by the remote_database_url() method
603
and using the identifier supplied by the id_parser() method.
604
It will use the NCBI GI if present, and the accession if not.
606
Args : First argument is a Bio::Search::Hit::HitI
607
Second argument is a Bio::Search::Result::ResultI
609
See Also: L<hit_link_align>, L<remote_database>, L<id_parser>
613
sub default_hit_desc_line {
614
my($self, $hit, $result) = @_;
615
my $type = ( $result->algorithm =~ /(P|X|Y)$/i ) ? 'PROTEIN' : 'NUCLEOTIDE';
616
my @descs = split /\x01/, $hit->description;
617
#my $descline = join("</br>",@descs)."</br>";
620
for my $sec (@descs) {
622
if ($sec =~ s/((?:gi\|(\d+)\|)? # optional GI
623
(\w+)\|([A-Z\d\.\_]+) # main
624
(\|[A-Z\d\_]+)?) # optional secondary ID//xms) {
625
my ($name, $gi, $db, $acc) = ($1, $2, $3, $4);
626
#$acc ||= ($rest) ? $rest : $gi;
627
$acc =~ s/^\s+(\S+)/$1/;
628
$acc =~ s/(\S+)\s+$/$1/;
630
length($self->remote_database_url($type)) > 0 ?
631
sprintf('<a href="%s">%s</a> %s',
632
sprintf($self->remote_database_url($type),
638
$descline .= "$url</br>\n";
562
643
=head2 start_report
564
645
Title : start_report