Bio/SearchIO/Writer/HTMLResultWriter.pm

filter: Statementstmt 76.8% 193 / 251 Branchbran 44.5% 65 / 146 Conditioncond 30.6% 27 / 88 MC/DCmcdc 0.0% 0 / 52 Subroutinesub 88.8% 24 / 27 Podpod 86.3% 19 / 22 totaltotal 55.9% 328 / 586 CC 112 SCAR 51.8
CC
112
Cov
59%
to_string
345.9
algorithm_reference
56.0
default_hit_desc_line
14.6
CRAP 178.3
« Bio/SeqIO/embl.pm ↑ Summary Bio/OntologyIO/Handlers/InterPro_BioSQL_Handler.pm »
1 #
2 # BioPerl module for Bio::SearchIO::Writer::HTMLResultWriter
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason@bioperl.org>
7 #
8 # Copyright Jason Stajich
9 #
10 # You may distribute this module under the same terms as perl itself
11  
12 # Changes 2003-07-31 (jason)
13 # Gary has cleaned up the code a lot to produce better looking HTML
14  
15 # POD documentation - main docs before the code
16  
17 =head1 NAME
18  
19 Bio::SearchIO::Writer::HTMLResultWriter - write a Bio::Search::ResultI in HTML
20  
21 =head1 SYNOPSIS
22  
23 use Bio::SearchIO;
24 use Bio::SearchIO::Writer::HTMLResultWriter;
25  
26 my $in = Bio::SearchIO->new(-format => 'blast',
27 -file => shift @ARGV);
28  
29 my $writer = Bio::SearchIO::Writer::HTMLResultWriter->new();
30 my $out = Bio::SearchIO->new(-writer => $writer);
31 $out->write_result($in->next_result);
32  
33  
34 # to filter your output
35 my $MinLength = 100; # need a variable with scope outside the method
36 sub hsp_filter {
37 my $hsp = shift;
38 return 1 if $hsp->length('total') > $MinLength;
39 }
40 sub result_filter {
41 my $result = shift;
42 return $hsp->num_hits > 0;
43 }
44  
45 my $writer = Bio::SearchIO::Writer::HTMLResultWriter->new
46 (-filters => { 'HSP' => \&hsp_filter} );
47 my $out = Bio::SearchIO->new(-writer => $writer);
48 $out->write_result($in->next_result);
49  
50 # can also set the filter via the writer object
51 $writer->filter('RESULT', \&result_filter);
52  
53 =head1 DESCRIPTION
54  
55 This object implements the SearchWriterI interface which will produce
56 a set of HTML for a specific L<Bio::Search::Report::ReportI> interface.
57  
58 See L<Bio::SearchIO::SearchWriterI> for more info on the filter method.
59  
60 =head1 FEEDBACK
61  
62 =head2 Mailing Lists
63  
64 User feedback is an integral part of the evolution of this and other
65 Bioperl modules. Send your comments and suggestions preferably to
66 the Bioperl mailing list. Your participation is much appreciated.
67  
68 bioperl-l@bioperl.org - General discussion
69 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
70  
71 =head2 Support
72  
73 Please direct usage questions or support issues to the mailing list:
74  
75 I<bioperl-l@bioperl.org>
76  
77 rather than to the module maintainer directly. Many experienced and
78 reponsive experts will be able look at the problem and quickly
79 address it. Please include a thorough description of the problem
80 with code and data examples if at all possible.
81  
82 =head2 Reporting Bugs
83  
84 Report bugs to the Bioperl bug tracking system to help us keep track
85 of the bugs and their resolution. Bug reports can be submitted via the
86 web:
87  
88 https://github.com/bioperl/bioperl-live/issues
89  
90 =head1 AUTHOR - Jason Stajich
91  
92 Email jason-at-bioperl-dot-org
93  
94 =head1 CONTRIBUTORS
95  
96 Gary Williams G.Williams@hgmp.mrc.ac.uk
97  
98 =head1 APPENDIX
99  
100 The rest of the documentation details each of the object methods.
101 Internal methods are usually preceded with a _
102  
103 =cut
104  
105  
106 package Bio::SearchIO::Writer::HTMLResultWriter;
107 2 $Bio::SearchIO::Writer::HTMLResultWriter::VERSION = '1.7.8';
108 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
109 2 ▶use vars qw(%RemoteURLDefault
Subroutine BEGIN: called CC=1 SCAR=0.0
110 2 $MaxDescLen $DATE $AlignmentLineWidth $Revision);
111  
112 # Object preamble - inherits from Bio::Root::RootI
113  
114 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
115 2 $Revision = '$Id$';
116 2 $DATE = localtime(time);
117 2 %RemoteURLDefault = (
118 'PROTEIN' => 'https://www.ncbi.nlm.nih.gov/protein?term=%s',
119 'NUCLEOTIDE' => 'https://www.ncbi.nlm.nih.gov/nucleotide?term=%s'
120 );
121 2 $MaxDescLen = 60;
122 2 $AlignmentLineWidth = 60;
123 }
124  
125  
126 2 ▶use base qw(Bio::Root::Root Bio::SearchIO::SearchWriterI);
Subroutine BEGIN: called CC=1 SCAR=0.0
127  
128 =head2 new
129  
130 Title : new
131 Usage : my $obj = Bio::SearchIO::Writer::HTMLResultWriter->new();
132 Function: Builds a new Bio::SearchIO::Writer::HTMLResultWriter object
133 Returns : Bio::SearchIO::Writer::HTMLResultWriter
134 Args : -filters => hashref with any or all of the keys (HSP HIT RESULT)
135 which have values pointing to a subroutine reference
136 which will expect to get a
137 -nucleotide_url => URL sprintf string base for the nt sequences
138 -protein_url => URL sprintf string base for the aa sequences
139 -no_wublastlinks => boolean. Do not display WU-BLAST lines
140 even if they are parsed out.
141 Links = (1)
142  
143 =cut
144  
145 1 ▶sub new {
Subroutine new: called CC=6 SCAR=25.1
Pod documented
146 1 my($class,@args) = @_;
147  
148 1 my $self = $class->SUPER::new(@args);
149 1 my ($p,$n,$filters,
150 $nowublastlinks) = $self->_rearrange([qw(PROTEIN_URL
151 NUCLEOTIDE_URL
152 FILTERS
153 NO_WUBLASTLINKS)],@args);
154 1 ▶ $self->remote_database_url('p',$p || $RemoteURLDefault{'PROTEIN'});
Condition33%1/3
$p || $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'PROTEIN'}
l!l&&r!l&&!r
010
MC/DC0%0/2
$p || $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'PROTEIN'}
$p $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'PROTEIN'}
Truth table33%1/3
A || B
A= $pB= $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'PROTEIN'}
ABresult
1X1
011
000
155 1 ▶ $self->remote_database_url('n',$n || $RemoteURLDefault{'NUCLEOTIDE'});
Condition33%1/3
$n || $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'NUCLEOTIDE'}
l!l&&r!l&&!r
010
MC/DC0%0/2
$n || $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'NUCLEOTIDE'}
$n $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'NUCLEOTIDE'}
Truth table33%1/3
A || B
A= $nB= $Bio::SearchIO::Writer::HTMLResultWriter::RemoteURLDefault{'NUCLEOTIDE'}
ABresult
1X1
011
000
156 1 $self->no_wublastlinks(! $nowublastlinks);
157 1 ▶ if( defined $filters ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $filters) 0 1 1
158 0 ▶ if( !ref($filters) =~ /HASH/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ref($filters) =~ /HASH/i) { } 0 0 0
159 0 $self->warn("Did not provide a hashref for the FILTERS option, ignoring.");
160 } else {
161 0 ▶ while( my ($type,$code) = each %{$filters} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$filters;}) 0 0 0
162 0 $self->filter($type,$code);
163 }
164 }
165 }
166  
167 1 return $self;
168 }
169  
170 =head2 remote_database_url
171  
172 Title : remote_database_url
173 Usage : $obj->remote_database_url($type,$newval)
174 Function: This should return or set a string that contains a %s which can be
175 filled in with sprintf.
176 Returns : value of remote_database_url
177 Args : $type - 'PROTEIN' or 'P' for protein URLS
178 'NUCLEOTIDE' or 'N' for nucleotide URLS
179 $value - new value to set [optional]
180  
181  
182 =cut
183  
184 82 ▶sub remote_database_url{
Subroutine remote_database_url: called CC=4 SCAR=15.2
Pod documented
185 82 my ($self,$type,$value) = @_;
186 82 ▶ if( ! defined $type || $type !~ /^(P|N)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type and $type =~ /^(P|N)/i) 0 82 82
Condition33%1/3
defined $type and $type =~ /^(P|N)/i
!ll&&!rl&&r
0082
MC/DC0%0/2
defined $type and $type =~ /^(P|N)/i
defined $type $type =~ /^(P|N)/i
Truth table33%1/3
A and B
A= defined $typeB= $type =~ /^(P|N)/i
ABresult
0X0
100
111
187 0 $self->warn("Must provide a type (PROTEIN or NUCLEOTIDE)");
188 0 return '';
189 }
190 82 $type = uc $1;
191 82 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 80 82
192 2 $self->{'remote_database_url'}->{$type} = $value;
193 }
194 82 return $self->{'remote_database_url'}->{$type};
195 }
196  
197 =head2 to_string
198  
199 Purpose : Produces data for each Search::Result::ResultI in a string.
200 : This is an abstract method. For some useful implementations,
201 : see ResultTableWriter.pm, HitTableWriter.pm,
202 : and HSPTableWriter.pm.
203 Usage : print $writer->to_string( $result_obj, @args );
204 Argument : $result_obj = A Bio::Search::Result::ResultI object
205 : @args = any additional arguments used by your implementation.
206 Returns : String containing data for each search Result or any of its
207 : sub-objects (Hits and HSPs).
208 Throws : n/a
209  
210 =cut
211  
212 1 ▶sub to_string {
Subroutine to_string: called CC=69 SCAR=58.5
Pod documented
213 1 my ($self,$result,$num) = @_;
214 1 ▶ $num ||= 0;
Condition50%1/2
$num ||= 0
l!l
10
MC/DC0%0/1
$num ||= 0
$num
Truth table50%1/2
A
A= $num
Aresult
11
00
215 1 ▶ return unless defined $result;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 0 1 1
216 1 my $links = $self->no_wublastlinks;
217 1 my ($resultfilter,$hitfilter, $hspfilter) = ( $self->filter('RESULT'),
218 $self->filter('HIT'),
219 $self->filter('HSP') );
220 0 ▶ return '' if( defined $resultfilter && ! &{$resultfilter}($result) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $resultfilter and not &{$resultfilter;}($result) 0 1 1
Condition33%1/3
defined $resultfilter and not &{$resultfilter;}($result)
!ll&&!rl&&r
100
MC/DC0%0/2
defined $resultfilter and not &{$resultfilter;}($result)
defined $resultfilter not &{$resultfilter;}($result)
Truth table33%1/3
A and not(B)
A= defined $resultfilterB= not &{$resultfilter;}($result)
ABresult
0X0
100
111
221  
222 1 my ($qtype,$dbtype,$dbseqtype,$type);
223 1 my $alg = $result->algorithm;
224 # This is actually wrong for the FASTAs I think
225 1 ▶ if( $alg =~ /T(FAST|BLAST)([XY])/i ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($alg =~ /T(FAST|BLAST)([XY])/i) { } 1 0 1
elsif ($alg =~ /T(FAST|BLAST)N/i) { } 0 0 0
elsif ($alg =~ /(FAST|BLAST)N/i or $alg =~ /(WABA|EXONERATE)/i) { } 0 0 0
elsif ($alg =~ /(FAST|BLAST)P/ or $alg =~ /SSEARCH|HMM(PFAM|SEARCH)/i) { } 0 0 0
elsif ($alg =~ /(FAST|BLAST)[XY]/i) { } 0 0 0
226 1 $qtype = $dbtype = 'translated';
227 1 $dbseqtype = $type = 'PROTEIN';
228 } elsif( $alg =~ /T(FAST|BLAST)N/i ) {
229 0 $qtype = '';
230 0 $dbtype = 'translated';
231 0 $type = 'PROTEIN';
232 0 $dbseqtype = 'NUCLEOTIDE';
233 ▶ } elsif( $alg =~ /(FAST|BLAST)N/i ||
Condition0%0/3
$alg =~ /(FAST|BLAST)N/i or $alg =~ /(WABA|EXONERATE)/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$alg =~ /(FAST|BLAST)N/i or $alg =~ /(WABA|EXONERATE)/i
$alg =~ /(FAST|BLAST)N/i $alg =~ /(WABA|EXONERATE)/i
Truth table0%0/3
A or B
A= $alg =~ /(FAST|BLAST)N/iB= $alg =~ /(WABA|EXONERATE)/i
ABresult
1X1
011
000
234 $alg =~ /(WABA|EXONERATE)/i ) {
235 0 $qtype = $dbtype = '';
236 0 $type = $dbseqtype = 'NUCLEOTIDE';
237 ▶ } elsif( $alg =~ /(FAST|BLAST)P/ ||
Condition0%0/3
$alg =~ /(FAST|BLAST)P/ or $alg =~ /SSEARCH|HMM(PFAM|SEARCH)/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$alg =~ /(FAST|BLAST)P/ or $alg =~ /SSEARCH|HMM(PFAM|SEARCH)/i
$alg =~ /(FAST|BLAST)P/ $alg =~ /SSEARCH|HMM(PFAM|SEARCH)/i
Truth table0%0/3
A or B
A= $alg =~ /(FAST|BLAST)P/B= $alg =~ /SSEARCH|HMM(PFAM|SEARCH)/i
ABresult
1X1
011
000
238 $alg =~ /SSEARCH|HMM(PFAM|SEARCH)/i ) {
239 0 $qtype = $dbtype = '';
240 0 $type = $dbseqtype = 'PROTEIN';
241 } elsif( $alg =~ /(FAST|BLAST)[XY]/i ) {
242 0 $qtype = 'translated';
243 0 $dbtype = 'PROTEIN';
244 0 $dbseqtype = $type = 'PROTEIN';
245 } else {
246 0 $self->warn("algorithm was ", $result->algorithm, " couldn't match\n");
247 }
248
249
250 1 ▶ my %baselens = ( 'Sbjct:' => ( $dbtype eq 'translated' ) ? 3 : 1,
Branch: 2 branches
BranchTrueFalseTotal
$dbtype eq 'translated' ? : 1 0 1
$qtype eq 'translated' ? : 1 0 1
251 'Query:' => ( $qtype eq 'translated' ) ? 3 : 1);
252  
253 1 my $str;
254 1 ▶ if( $num <= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num <= 1) 1 0 1
255 1 $str = &{$self->start_report}($result);
256 }
257  
258 1 $str .= &{$self->title}($result);
259  
260 1 ▶ $str .= $result->algorithm_reference || $self->algorithm_reference($result);
Condition33%1/3
$result->algorithm_reference || $self->algorithm_reference($result)
l!l&&r!l&&!r
100
MC/DC0%0/2
$result->algorithm_reference || $self->algorithm_reference($result)
$result->algorithm_reference $self->algorithm_reference($result)
Truth table33%1/3
A || B
A= $result->algorithm_referenceB= $self->algorithm_reference($result)
ABresult
1X1
011
000
261 1 $str .= &{$self->introduction}($result);
262  
263 1 $str .= "<table border=0>
264 <tr><th>Sequences producing significant alignments:</th>
265 <th>Score<br>(bits)</th><th>E<br>value</th></tr>";
266  
267 1 my $hspstr = '<p><p>';
268 1 ▶ if( $result->can('rewind')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->can("rewind")) 1 0 1
269 1 $result->rewind(); # support stream based parsing routines
270 }
271  
272 1 ▶ while( my $hit = $result->next_hit ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hit = $result->next_hit) 20 1 21
273 0 ▶ next if( $hitfilter && ! &{$hitfilter}($hit) );
Branch: 1 branch
BranchTrueFalseTotal
if $hitfilter and not &{$hitfilter;}($hit) 0 20 20
Condition33%1/3
$hitfilter and not &{$hitfilter;}($hit)
!ll&&!rl&&r
2000
MC/DC0%0/2
$hitfilter and not &{$hitfilter;}($hit)
$hitfilter not &{$hitfilter;}($hit)
Truth table33%1/3
A and not(B)
A= $hitfilterB= not &{$hitfilter;}($hit)
ABresult
0X0
100
111
274 20 my $nm = $hit->name();
275
276 20 ▶ $self->debug( "no $nm for name (".$hit->description(). "\n")
Branch: 1 branch
BranchTrueFalseTotal
unless $nm 0 20 20
277 unless $nm;
278 20 my ($gi,$acc) = &{$self->id_parser}($nm);
279 20 my $p = "%-$MaxDescLen". "s";
280 20 my $descsub;
281 20 ▶ if( length($hit->description) > ($MaxDescLen - 3) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $hit->description > $Bio::SearchIO::Writer::HTMLResultWriter::MaxDescLen - 3) { } 20 0 20
282 20 $descsub = sprintf($p,
283 substr($hit->description,0,$MaxDescLen-3) . "...");
284 } else {
285 0 $descsub = sprintf($p,$hit->description);
286 }
287  
288 20 my $url_desc = &{$self->hit_link_desc()}($self,$hit, $result);
289 20 my $url_align = &{$self->hit_link_align()}($self,$hit, $result);
290  
291 20 my @hsps = $hit->hsps;
292
293 20 ▶ if( ! @hsps ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @hsps) { } 0 20 20
294 # no HSPs so no link
295 0 ▶ $str .= sprintf('<tr><td>%s %s</td><td>%s</td><td>%.2g</td></tr>'."\n",
Branch: 4 branches
BranchTrueFalseTotal
$hit->bits ? : 0 0 0
defined $hsps[0] ? : 0 0 0
$hit->significance ? : 0 0 0
defined $hsps[0] ? : 0 0 0
296 $url_desc, $descsub,
297 ($hit->bits ? $hit->bits :
298 (defined $hsps[0] ? $hsps[0]->bits : ' ')),
299 ( $hit->significance ? $hit->significance :
300 (defined $hsps[0] ? $hsps[0]->evalue : ' '))
301 );
302 } else {
303 # failover to first HSP if the data does not contain a
304 # bitscore/significance value for the Hit (NCBI XML data for one)
305  
306 20 ▶ $str .= sprintf('<tr><td>%s %s</td><td>%s</td><td><a href="#%s">%.2g</a></td></tr>'."\n",
Branch: 4 branches
BranchTrueFalseTotal
$hit->bits ? : 20 0 20
defined $hsps[0] ? : 0 0 0
$hit->significance ? : 20 0 20
defined $hsps[0] ? : 0 0 0
307 $url_desc, $descsub,
308 ($hit->bits ? $hit->bits :
309 (defined $hsps[0] ? $hsps[0]->bits : ' ')),
310 $acc,
311 ( $hit->significance ? $hit->significance :
312 (defined $hsps[0] ? $hsps[0]->evalue : ' '))
313 );
314 20 my $dline = &{$self->hit_desc_line}($self, $hit, $result);
315 20 $hspstr .= "<a name=\"$acc\">\n".
316 sprintf("><b>%s</b> %s</br><dd>Length = %s</dd><p>\n\n", $url_align,
317 $dline , &_numwithcommas($hit->length));
318 20 my $ct = 0;
319 20 foreach my $hsp (@hsps ) {
320 0 ▶ next if( $hspfilter && ! &{$hspfilter}($hsp) );
Branch: 1 branch
BranchTrueFalseTotal
if $hspfilter and not &{$hspfilter;}($hsp) 0 21 21
Condition33%1/3
$hspfilter and not &{$hspfilter;}($hsp)
!ll&&!rl&&r
2100
MC/DC0%0/2
$hspfilter and not &{$hspfilter;}($hsp)
$hspfilter not &{$hspfilter;}($hsp)
Truth table33%1/3
A and not(B)
A= $hspfilterB= not &{$hspfilter;}($hsp)
ABresult
0X0
100
111
321 21 ▶ $hspstr .= sprintf(" Score = %s bits (%s), Expect = %s",
Condition37%3/8
$hsp->bits || $hsp->score
l!l&&r!l&&!r
2100
$hsp->score || $hsp->bits
l!l&&r!l&&!r
2100
$hsp->evalue || ''
l!l
210
MC/DC0%0/2
$hsp->bits || $hsp->score
$hsp->bits $hsp->score
MC/DC0%0/2
$hsp->score || $hsp->bits
$hsp->score $hsp->bits
MC/DC0%0/1
$hsp->evalue || ''
$hsp->evalue
Truth table33%1/3
A || B
A= $hsp->bitsB= $hsp->score
ABresult
1X1
011
000
Truth table33%1/3
A || B
A= $hsp->scoreB= $hsp->bits
ABresult
1X1
011
000
Truth table50%1/2
A
A= $hsp->evalue
Aresult
11
00
322 $hsp->bits || $hsp->score,
323 $hsp->score || $hsp->bits,
324 $hsp->evalue || '');
325 21 ▶ if( defined $hsp->pvalue ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hsp->pvalue) 0 21 21
326 0 $hspstr .= ", P = ".$hsp->pvalue;
327 }
328 21 $hspstr .= "<br>\n";
329 21 $hspstr .= sprintf(" Identities = %d/%d (%d%%)",
330 ( $hsp->frac_identical('total') *
331 $hsp->length('total')),
332 $hsp->length('total'),
333 $hsp->frac_identical('total') * 100);
334  
335 21 ▶ if( $type eq 'PROTEIN' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "PROTEIN") 21 0 21
336 21 $hspstr .= sprintf(", Positives = %d/%d (%d%%)",
337 ( $hsp->frac_conserved('total') *
338 $hsp->length('total')),
339 $hsp->length('total'),
340 $hsp->frac_conserved('total') * 100);
341 }
342 21 ▶ if( $hsp->gaps ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hsp->gaps) 0 21 21
343 0 $hspstr .= sprintf(", Gaps = %d/%d (%d%%)",
344 $hsp->gaps('total'),
345 $hsp->length('total'),
346 (100 * $hsp->gaps('total') /
347 $hsp->length('total')));
348 }
349  
350 21 my ($hframe,$qframe) = ( $hsp->hit->frame, $hsp->query->frame);
351 21 my ($hstrand,$qstrand) = ($hsp->hit->strand,$hsp->query->strand);
352 # so TBLASTX will have Query/Hit frames
353 # BLASTX will have Query frame
354 # TBLASTN will have Hit frame
355 21 ▶ if( $hstrand || $qstrand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hstrand or $qstrand) 21 0 21
Condition33%1/3
$hstrand or $qstrand
l!l&&r!l&&!r
2100
MC/DC0%0/2
$hstrand or $qstrand
$hstrand $qstrand
Truth table33%1/3
A or B
A= $hstrandB= $qstrand
ABresult
1X1
011
000
356 21 $hspstr .= ", Frame = ";
357 21 my ($signq, $signh);
358 21 ▶ unless( $hstrand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hstrand) { } 21 0 21
359 0 $hframe = undef;
360 # if strand is null or 0 then it is protein
361 # and this no frame
362 } else {
363 21 ▶ $signh = $hstrand < 0 ? '-' : '+';
Branch: 1 branch
BranchTrueFalseTotal
$hstrand < 0 ? : 5 16 21
364 }
365 21 ▶ unless( $qstrand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qstrand) { } 21 0 21
366 0 $qframe = undef;
367 # if strand is null or 0 then it is protein
368 } else {
369 21 ▶ $signq =$qstrand < 0 ? '-' : '+';
Branch: 1 branch
BranchTrueFalseTotal
$qstrand < 0 ? : 7 14 21
370 }
371 # remember bioperl stores frames as 0,1,2 (GFF way)
372 # BLAST reports reports as 1,2,3 so
373 # we have to add 1 to the frame values
374 21 ▶ if( defined $hframe && ! defined $qframe) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $hframe and not defined $qframe) { } 0 21 21
elsif (defined $qframe and not defined $hframe) { } 0 21 21
Condition33%1/3
defined $hframe and not defined $qframe
!ll&&!rl&&r
0210
MC/DC0%0/2
defined $hframe and not defined $qframe
defined $hframe not defined $qframe
Truth table33%1/3
A and not(B)
A= defined $hframeB= not defined $qframe
ABresult
0X0
100
111
375 0 $hspstr .= "$signh".($hframe+1);
376 ▶ } elsif( defined $qframe && ! defined $hframe) {
Condition33%1/3
defined $qframe and not defined $hframe
!ll&&!rl&&r
0210
MC/DC0%0/2
defined $qframe and not defined $hframe
defined $qframe not defined $hframe
Truth table33%1/3
A and not(B)
A= defined $qframeB= not defined $hframe
ABresult
0X0
100
111
377 0 $hspstr .= "$signq".($qframe+1);
378 } else {
379 21 $hspstr .= sprintf(" %s%d / %s%d",
380 $signq,$qframe+1,
381 $signh, $hframe+1);
382 }
383 }
384 21 ▶ if($links &&
Branch: 1 branch
BranchTrueFalseTotal
if ($links and $hsp->can("links") and defined(my $lnks = $hsp->links)) 0 21 21
Condition33%2/6
$links and $hsp->can("links") and defined(my $lnks = $hsp->links)
!ll&&!rl&&r
0210
$links and $hsp->can("links")
!ll&&!rl&&r
0021
MC/DC0%0/3
$links and $hsp->can("links") and defined(my $lnks = $hsp->links)
$links $hsp->can("links") defined(my $lnks = $hsp->links)
Truth table25%1/4
A and B and C
A= $linksB= $hsp->can("links")C= defined(my $lnks = $hsp->links)
ABCresult
0XX0
10X0
1100
1111
385 $hsp->can('links') && defined(my $lnks = $hsp->links) ) {
386 0 $hspstr .= sprintf("<br>\nLinks = %s\n",$lnks);
387 }
388  
389 21 $hspstr .= "</a><p>\n<pre>";
390  
391 21 ▶ my @hspvals = ( {'name' => 'Query:',
Branch: 4 branches
BranchTrueFalseTotal
$qstrand >= 0 ? : 14 7 21
$qstrand >= 0 ? : 14 7 21
$hstrand >= 0 ? : 16 5 21
$hstrand >= 0 ? : 16 5 21
Condition50%2/4
$qstrand || 1
l!l
210
$hstrand || 1
l!l
210
MC/DC0%0/1
$qstrand || 1
$qstrand
MC/DC0%0/1
$hstrand || 1
$hstrand
Truth table50%1/2
A
A= $qstrand
Aresult
11
00
Truth table50%1/2
A
A= $hstrand
Aresult
11
00
392 'seq' => $hsp->query_string,
393 'start' => ($qstrand >= 0 ?
394 $hsp->query->start :
395 $hsp->query->end),
396 'end' => ($qstrand >= 0 ?
397 $hsp->query->end :
398 $hsp->query->start),
399 'index' => 0,
400 'direction' => $qstrand || 1
401 },
402 { 'name' => ' 'x6,
403 'seq' => $hsp->homology_string,
404 'start' => undef,
405 'end' => undef,
406 'index' => 0,
407 'direction' => 1
408 },
409 { 'name' => 'Sbjct:',
410 'seq' => $hsp->hit_string,
411 'start' => ($hstrand >= 0 ?
412 $hsp->hit->start :
413 $hsp->hit->end),
414 'end' => ($hstrand >= 0 ?
415 $hsp->hit->end :
416 $hsp->hit->start),
417 'index' => 0,
418 'direction' => $hstrand || 1
419 }
420 );
421  
422  
423 # let's set the expected length (in chars) of the starting number
424 # in an alignment block so we can have things line up
425 # Just going to try and set to the largest
426  
427 85 my ($numwidth) = sort { $b <=> $a }(length($hspvals[0]->{'start'}),
428 length($hspvals[0]->{'end'}),
429 length($hspvals[2]->{'start'}),
430 21 length($hspvals[2]->{'end'}));
431 21 my $count = 0;
432 21 ▶ while ( $count < $hsp->length('total') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < $hsp->length("total")) 21 21 42
433 21 foreach my $v ( @hspvals ) {
434 63 my $piece = substr($v->{'seq'}, $v->{'index'} + $count,
435 $AlignmentLineWidth);
436 63 my $cp = $piece;
437 63 my $plen = scalar ( $cp =~ tr/\-//);
438 63 my ($start,$end) = ('','');
439 63 ▶ if( defined $v->{'start'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v->{"start"}) 42 21 63
440 42 $start = $v->{'start'};
441 # since strand can be + or - use the direction
442 # to signify which whether to add or subtract from end
443 my $d = $v->{'direction'} * ( $AlignmentLineWidth - $plen )*
444 42 $baselens{$v->{'name'}};
445 42 ▶ if( length($piece) < $AlignmentLineWidth ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $piece < $Bio::SearchIO::Writer::HTMLResultWriter::AlignmentLineWidth) 42 0 42
446 $d = (length($piece) - $plen) * $v->{'direction'} *
447 42 $baselens{$v->{'name'}};
448 }
449 42 $end = $v->{'start'} + $d - $v->{'direction'};
450 42 $v->{'start'} += $d;
451 }
452 $hspstr .= sprintf("%s %-".$numwidth."s %s %s\n",
453 63 $v->{'name'},
454 $start,
455 $piece,
456 $end
457 );
458 }
459 21 $count += $AlignmentLineWidth;
460 21 $hspstr .= "\n\n";
461 }
462 21 $hspstr .= "</pre>\n";
463 }
464 }
465 # $hspstr .= "</pre>\n";
466 }
467  
468 1 $str .= "</table><p>\n".$hspstr;
469 1 my ($pav, $sav) = ($result->available_parameters, $result->available_statistics);
470 1 ▶ if ($pav || $sav) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pav or $sav) 1 0 1
Condition33%1/3
$pav or $sav
l!l&&r!l&&!r
100
MC/DC0%0/2
$pav or $sav
$pav $sav
Truth table33%1/3
A or B
A= $pavB= $sav
ABresult
1X1
011
000
471 # make table of search statistics and end the web page
472 1 $str .= "<p><p><hr><h2>Search Parameters</h2>";
473 1 ▶ if ($pav) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pav) 1 0 1
474 1 $str .= "<table border=1><tr><th>Parameter</th><th>Value</th>\n";
475 1 foreach my $param ( sort $result->available_parameters ) {
476 3 $str .= "<tr><td>$param</td><td>". $result->get_parameter($param) ."</td></tr>\n";
477 }
478 1 $str .= "</table>";
479 }
480
481 1 ▶ if ($sav) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sav) 1 0 1
482 1 $str .= "<p><h2>Search Statistics</h2><table border=1><tr><th>Statistic</th><th>Value</th></tr>\n";
483 1 foreach my $stat ( sort $result->available_statistics ) {
484 27 $str .= "<tr><td>$stat</td><td>". $result->get_statistic($stat). "</td>\n";
485 }
486 1 $str .= "</tr></table>";
487 }
488 }
489 1 $str .= $self->footer() . "<P>\n";
490 1 return $str;
491 }
492  
493 =head2 hit_link_desc
494  
495 Title : hit_link_desc
496 Usage : $self->hit_link_desc(\&link_function);
497 Function: Get/Set the function which provides an HTML
498 link(s) for the given hit to be used
499 within the description section at the top of the BLAST report.
500 This allows a person reading the report within
501 a web browser to go to one or more database entries for
502 the given hit from the description section.
503 Returns : Function reference
504 Args : Function reference
505 See Also: L<default_hit_link_desc()>
506  
507 =cut
508  
509 20 ▶sub hit_link_desc{
Subroutine hit_link_desc: called CC=3 SCAR=12.5
Pod documented
510 20 my( $self, $code ) = @_;
511 20 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 20 20
512 0 $self->{'_hit_link_desc'} = $code;
513 }
514 20 ▶ return $self->{'_hit_link_desc'} || \&default_hit_link_desc;
Condition50%1/2
$self->{'_hit_link_desc'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_hit_link_desc
l!l
020
MC/DC0%0/1
$self->{'_hit_link_desc'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_hit_link_desc
$self->{'_hit_link_desc'}
Truth table50%1/2
A
A= $self->{'_hit_link_desc'}
Aresult
11
00
515 }
516  
517 =head2 default_hit_link_desc
518  
519 Title : default_hit_link_desc
520 Usage : $self->default_hit_link_desc($hit, $result)
521 Function: Provides an HTML link(s) for the given hit to be used
522 within the description section at the top of the BLAST report.
523 This allows a person reading the report within
524 a web browser to go to one or more database entries for
525 the given hit from the description section.
526 Returns : string containing HTML markup "<a href...")
527  
528 The default implementation returns an HTML link to the
529 URL supplied by the remote_database_url() method
530 and using the identifier supplied by the id_parser() method.
531 It will use the NCBI GI if present, and the accession if not.
532  
533 Args : First argument is a Bio::Search::Hit::HitI
534 Second argument is a Bio::Search::Result::ResultI
535  
536 See Also: L<hit_link_align>, L<remote_database>, L<id_parser>
537  
538 =cut
539  
540 40 ▶sub default_hit_link_desc {
Subroutine default_hit_link_desc: called CC=4 SCAR=15.0
Pod documented
541 40 my($self, $hit, $result) = @_;
542 40 ▶ my $type = ( $result->algorithm =~ /(P|X|Y)$/i ) ? 'PROTEIN' : 'NUCLEOTIDE';
Branch: 1 branch
BranchTrueFalseTotal
$result->algorithm =~ /(P|X|Y)$/i ? : 40 0 40
543 40 my ($gi,$acc) = &{$self->id_parser}($hit->name);
544  
545 40 ▶ my $url = length($self->remote_database_url($type)) > 0 ?
Branch: 1 branch
BranchTrueFalseTotal
length $self->remote_database_url($type) > 0 ? : 40 0 40
Condition33%1/3
$gi || $acc
l!l&&r!l&&!r
0400
MC/DC0%0/2
$gi || $acc
$gi $acc
Truth table33%1/3
A || B
A= $giB= $acc
ABresult
1X1
011
000
546 sprintf('<a href="%s">%s</a>',
547 sprintf($self->remote_database_url($type),$gi || $acc),
548 $hit->name()) : $hit->name();
549  
550 40 return $url;
551 }
552  
553  
554 =head2 hit_link_align
555  
556 Title : hit_link_align
557 Usage : $self->hit_link_align(\&link_function);
558 Function: Get/Set the function which provides an HTML link(s)
559 for the given hit to be used
560 within the HSP alignment section of the BLAST report.
561 This allows a person reading the report within
562 a web browser to go to one or more database entries for
563 the given hit from the alignment section.
564 Returns : string containing HTML markup "<a href...")
565  
566 The default implementation delegates to hit_link_desc().
567  
568 Args : First argument is a Bio::Search::Hit::HitI
569 Second argument is a Bio::Search::Result::ResultI
570  
571 See Also: L<hit_link_desc>, L<remote_database>, L<id_parser>
572  
573 =cut
574  
575 20 ▶sub hit_link_align {
Subroutine hit_link_align: called CC=3 SCAR=12.5
Pod documented
576 20 my ($self,$code) = @_;
577 20 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 20 20
578 0 $self->{'_hit_link_align'} = $code;
579 }
580 20 ▶ return $self->{'_hit_link_align'} || \&default_hit_link_desc;
Condition50%1/2
$self->{'_hit_link_align'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_hit_link_desc
l!l
020
MC/DC0%0/1
$self->{'_hit_link_align'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_hit_link_desc
$self->{'_hit_link_align'}
Truth table50%1/2
A
A= $self->{'_hit_link_align'}
Aresult
11
00
581 }
582  
583 =head2 hit_desc_line
584  
585 Title : hit_desc_line
586 Usage : $self->hit_desc_line(\&link_function);
587 Function: Get/Set the function which provides HTML for the description
588 information from a hit. This allows one to parse
589 the rest of the description and split up lines, add links, etc.
590 Returns : Function reference
591 Args : Function reference
592 See Also: L<default_hit_link_desc()>
593  
594 =cut
595  
596 20 ▶sub hit_desc_line{
Subroutine hit_desc_line: called CC=3 SCAR=12.5
Pod documented
597 20 my( $self, $code ) = @_;
598 20 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 20 20
599 0 $self->{'_hit_desc_line'} = $code;
600 }
601 20 ▶ return $self->{'_hit_desc_line'} || \&default_hit_desc_line;
Condition50%1/2
$self->{'_hit_desc_line'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_hit_desc_line
l!l
020
MC/DC0%0/1
$self->{'_hit_desc_line'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_hit_desc_line
$self->{'_hit_desc_line'}
Truth table50%1/2
A
A= $self->{'_hit_desc_line'}
Aresult
11
00
602 }
603  
604 =head2 default_hit_desc_line
605  
606 Title : default_hit_desc_line
607 Usage : $self->default_hit_desc_line($hit, $result)
608 Function: Parses the description line information, splits based on the
609 hidden \x01 between independent descriptions, checks the lines for
610 possible web links, and adds HTML link(s) for the given hit to be
611 used.
612  
613 Returns : string containing HTML markup "<a href...")
614 The default implementation returns an HTML link to the
615 URL supplied by the remote_database_url() method
616 and using the identifier supplied by the id_parser() method.
617 It will use the NCBI GI if present, and the accession if not.
618  
619 Args : First argument is a Bio::Search::Hit::HitI
620 Second argument is a Bio::Search::Result::ResultI
621  
622 See Also: L<hit_link_align>, L<remote_database>, L<id_parser>
623  
624 =cut
625  
626 20 ▶sub default_hit_desc_line {
Subroutine default_hit_desc_line: called CC=7 SCAR=26.8
Pod documented
627 20 my($self, $hit, $result) = @_;
628 20 ▶ my $type = ( $result->algorithm =~ /(P|X|Y)$/i ) ? 'PROTEIN' : 'NUCLEOTIDE';
Branch: 1 branch
BranchTrueFalseTotal
$result->algorithm =~ /(P|X|Y)$/i ? : 20 0 20
629 20 my @descs = split /\x01/, $hit->description;
630 #my $descline = join("</br>",@descs)."</br>";
631 20 my $descline = '';
632 #return $descline;
633 20 for my $sec (@descs) {
634 20 my $url = '';
635 20 ▶ if ($sec =~ s/((?:gi\|(\d+)\|)? # optional GI
Branch: 1 branch
BranchTrueFalseTotal
if ($sec =~ s/((?:gi\|(\d+)\|)? # optional GI (\w+)\|([A-Z\d\.\_]+) # main (\|[A-Z\d\_]+)?) # optional secondary ID //msx) { } 0 20 20
636 (\w+)\|([A-Z\d\.\_]+) # main
637 (\|[A-Z\d\_]+)?) # optional secondary ID//xms) {
638 0 my ($name, $gi, $db, $acc) = ($1, $2, $3, $4);
639 #$acc ||= ($rest) ? $rest : $gi;
640 0 $acc =~ s/^\s+(\S+)/$1/;
641 0 $acc =~ s/(\S+)\s+$/$1/;
642 0 ▶ $url =
Branch: 1 branch
BranchTrueFalseTotal
length $self->remote_database_url($type) > 0 ? : 0 0 0
Condition0%0/6
$gi || $acc || $db
l!l&&r!l&&!r
000
$gi or $acc
l!l&&r!l&&!r
000
MC/DC0%0/3
$gi || $acc || $db
$gi $acc $db
Truth table0%0/4
A or B || C
A= $giB= $accC= $db
ABCresult
1XX1
01X1
0011
0000
643 length($self->remote_database_url($type)) > 0 ?
644 sprintf('<a href="%s">%s</a> %s',
645 sprintf($self->remote_database_url($type),
646 $gi || $acc || $db),
647 $name, $sec) : $sec;
648 } else {
649 20 $url = $sec;
650 }
651 20 $descline .= "$url</br>\n";
652 }
653 20 return $descline;
654 }
655  
656 =head2 start_report
657  
658 Title : start_report
659 Usage : $index->start_report( CODE )
660 Function: Stores or returns the code to
661 write the start of the <HTML> block, the <TITLE> block
662 and the start of the <BODY> block of HTML. Useful
663 for (for instance) specifying alternative
664 HTML if you are embedding the output in
665 an HTML page which you have already started.
666 (For example a routine returning a null string).
667 Returns \&default_start_report (see below) if not
668 set.
669 Example : $index->start_report( \&my_start_report )
670 Returns : ref to CODE if called without arguments
671 Args : CODE
672  
673 =cut
674  
675 1 ▶sub start_report {
Subroutine start_report: called CC=3 SCAR=12.5
Pod documented
676 1 my( $self, $code ) = @_;
677 1 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 1 1
678 0 $self->{'_start_report'} = $code;
679 }
680 1 ▶ return $self->{'_start_report'} || \&default_start_report;
Condition50%1/2
$self->{'_start_report'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_start_report
l!l
01
MC/DC0%0/1
$self->{'_start_report'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_start_report
$self->{'_start_report'}
Truth table50%1/2
A
A= $self->{'_start_report'}
Aresult
11
00
681 }
682  
683 =head2 default_start_report
684  
685 Title : default_start_report
686 Usage : $self->default_start_report($result)
687 Function: The default method to call when starting a report.
688 Returns : sting
689 Args : First argument is a Bio::Search::Result::ResultI
690  
691 =cut
692  
693 1 ▶sub default_start_report {
Subroutine default_start_report: called CC=1 SCAR=0.0
Pod documented
694 1 my ($result) = @_;
695 1 return sprintf(
696 qq{<HTML>
697 <HEAD> <CENTER><TITLE>Bioperl Reformatted HTML of %s output with Bioperl Bio::SearchIO system</TITLE></CENTER></HEAD>
698 <!------------------------------------------------------------------->
699 <!-- Generated by Bio::SearchIO::Writer::HTMLResultWriter -->
700 <!-- %s -->
701 <!-- http://bioperl.org -->
702 <!------------------------------------------------------------------->
703 <BODY BGCOLOR="WHITE">
704 },$result->algorithm,$Revision);
705
706 }
707  
708 =head2 title
709  
710 Title : title
711 Usage : $self->title($CODE)
712  
713 Function: Stores or returns the code to provide HTML for the given
714 BLAST report that will appear at the top of the BLAST report
715 HTML output. Useful for (for instance) specifying
716 alternative routines to write your own titles.
717 Returns \&default_title (see below) if not
718 set.
719 Example : $index->title( \&my_title )
720 Returns : ref to CODE if called without arguments
721 Args : CODE
722  
723 =cut
724  
725 1 ▶sub title {
Subroutine title: called CC=3 SCAR=12.5
Pod documented
726 1 my( $self, $code ) = @_;
727 1 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 1 1
728 0 $self->{'_title'} = $code;
729 }
730 1 ▶ return $self->{'_title'} || \&default_title;
Condition50%1/2
$self->{'_title'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_title
l!l
01
MC/DC0%0/1
$self->{'_title'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_title
$self->{'_title'}
Truth table50%1/2
A
A= $self->{'_title'}
Aresult
11
00
731 }
732  
733 =head2 default_title
734  
735 Title : default_title
736 Usage : $self->default_title($result)
737 Function: Provides HTML for the given BLAST report that will appear
738 at the top of the BLAST report HTML output.
739 Returns : string containing HTML markup
740 The default implementation returns <CENTER> <H1> HTML
741 containing text such as:
742 "Bioperl Reformatted HTML of BLASTP Search Report
743 for gi|1786183|gb|AAC73113.1|"
744 Args : First argument is a Bio::Search::Result::ResultI
745  
746 =cut
747  
748 1 ▶sub default_title {
Subroutine default_title: called CC=1 SCAR=0.0
Pod documented
749 1 my ($result) = @_;
750  
751 1 return sprintf(
752 qq{<CENTER><H1><a href="http://bioperl.org">Bioperl</a> Reformatted HTML of %s Search Report<br> for %s</H1></CENTER>},
753 $result->algorithm,
754 $result->query_name());
755 }
756  
757  
758 =head2 introduction
759  
760 Title : introduction
761 Usage : $self->introduction($CODE)
762  
763 Function: Stores or returns the code to provide HTML for the given
764 BLAST report detailing the query and the
765 database information.
766 Useful for (for instance) specifying
767 routines returning alternative introductions.
768 Returns \&default_introduction (see below) if not
769 set.
770 Example : $index->introduction( \&my_introduction )
771 Returns : ref to CODE if called without arguments
772 Args : CODE
773  
774 =cut
775  
776 1 ▶sub introduction {
Subroutine introduction: called CC=3 SCAR=12.5
Pod documented
777 1 my( $self, $code ) = @_;
778 1 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 1 1
779 0 $self->{'_introduction'} = $code;
780 }
781 1 ▶ return $self->{'_introduction'} || \&default_introduction;
Condition50%1/2
$self->{'_introduction'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_introduction
l!l
01
MC/DC0%0/1
$self->{'_introduction'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_introduction
$self->{'_introduction'}
Truth table50%1/2
A
A= $self->{'_introduction'}
Aresult
11
00
782 }
783  
784 =head2 default_introduction
785  
786 Title : default_introduction
787 Usage : $self->default_introduction($result)
788 Function: Outputs HTML to provide the query
789 and the database information
790 Returns : string containing HTML
791 Args : First argument is a Bio::Search::Result::ResultI
792 Second argument is string holding literature citation
793  
794 =cut
795  
796 1 ▶sub default_introduction {
Subroutine default_introduction: called CC=1 SCAR=0.0
Pod documented
797 1 my ($result) = @_;
798  
799 1 return sprintf(
800 qq{
801 <b>Query=</b> %s %s<br><dd>(%s letters)</dd>
802 <p>
803 <b>Database:</b> %s<br><dd>%s sequences; %s total letters<p></dd>
804 <p>
805 },
806 $result->query_name,
807 $result->query_description,
808 &_numwithcommas($result->query_length),
809 $result->database_name(),
810 &_numwithcommas($result->database_entries()),
811 &_numwithcommas($result->database_letters()),
812 );
813 }
814  
815 =head2 end_report
816  
817 Title : end_report
818 Usage : $self->end_report()
819 Function: The method to call when ending a report, this is
820 mostly for cleanup for formats which require you to
821 have something at the end of the document (</BODY></HTML>)
822 for HTML
823 Returns : string
824 Args : none
825  
826 =cut
827  
828 1 ▶sub end_report {
Subroutine end_report: called CC=1 SCAR=0.0
Pod documented
829 1 return "</BODY>\n</HTML>\n";
830 }
831  
832 # copied from Bio::Index::Fasta
833 # useful here as well
834  
835 =head2 id_parser
836  
837 Title : id_parser
838 Usage : $index->id_parser( CODE )
839 Function: Stores or returns the code used by record_id to
840 parse the ID for record from a string. Useful
841 for (for instance) specifying a different
842 parser for different flavours of FASTA file.
843 Returns \&default_id_parser (see below) if not
844 set. If you supply your own id_parser
845 subroutine, then it should expect a fasta
846 description line. An entry will be added to
847 the index for each string in the list returned.
848 Example : $index->id_parser( \&my_id_parser )
849 Returns : ref to CODE if called without arguments
850 Args : CODE
851  
852 =cut
853  
854 60 ▶sub id_parser {
Subroutine id_parser: called CC=3 SCAR=12.5
Pod documented
855 60 my( $self, $code ) = @_;
856
857 60 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 60 60
858 0 $self->{'_id_parser'} = $code;
859 }
860 60 ▶ return $self->{'_id_parser'} || \&default_id_parser;
Condition50%1/2
$self->{'_id_parser'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_id_parser
l!l
060
MC/DC0%0/1
$self->{'_id_parser'} || \&Bio::SearchIO::Writer::HTMLResultWriter::default_id_parser
$self->{'_id_parser'}
Truth table50%1/2
A
A= $self->{'_id_parser'}
Aresult
11
00
861 }
862  
863  
864  
865 =head2 default_id_parser
866  
867 Title : default_id_parser
868 Usage : $id = default_id_parser( $header )
869 Function: The default Fasta ID parser for Fasta.pm
870 Returns $1 from applying the regexp /^>\s*(\S+)/
871 to $header.
872 Returns : ID string
873 The default implementation checks for NCBI-style
874 identifiers in the given string ('gi|12345|AA54321').
875 For these IDs, it extracts the GI and accession and
876 returns a two-element list of strings (GI, acc).
877 Args : a fasta header line string
878  
879 =cut
880  
881 60 ▶sub default_id_parser {
Subroutine default_id_parser: called CC=4 SCAR=17.3
Pod documented
882 60 my ($string) = @_;
883 60 my ($gi,$acc);
884 60 ▶ if( $string =~ s/gi\|(\d+)\|?// )
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/gi\|(\d+)\|?//) 0 60 60
885 0 { $gi = $1; $acc = $1;}
886
887 60 ▶ if( $string =~ /(\w+)\|([A-Z\d\.\_]+)(\|[A-Z\d\_]+)?/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /(\w+)\|([A-Z\d\.\_]+)(\|[A-Z\d\_]+)?/) { } 60 0 60
888 60 ▶ $acc = defined $2 ? $2 : $1;
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 60 0 60
889 } else {
890 0 $acc = $string;
891 0 $acc =~ s/^\s+(\S+)/$1/;
892 0 $acc =~ s/(\S+)\s+$/$1/;
893 }
894 60 return ($gi,$acc);
895 }
896
897 0 ▶sub MIN { $a <=> $b ? $a : $b; }
Subroutine MIN: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$a <=> $b ? : 0 0 0
898 0 ▶sub MAX { $a <=> $b ? $b : $a; }
Subroutine MAX: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$a <=> $b ? : 0 0 0
899  
900 1 ▶sub footer {
Subroutine footer: called CC=1 SCAR=0.0
Pod undocumented
901 1 my ($self) = @_;
902 1 return "<hr><h5>Produced by Bioperl module ".ref($self)." on $DATE<br>Revision: $Revision</h5>\n"
903
904 }
905  
906 =head2 algorithm_reference
907  
908 Title : algorithm_reference
909 Usage : my $reference = $writer->algorithm_reference($result);
910 Function: Returns the appropriate Bibliographic reference for the
911 algorithm format being produced
912 Returns : String
913 Args : L<Bio::Search::Result::ResultI> to reference
914  
915  
916 =cut
917  
918 0 ▶sub algorithm_reference {
Subroutine algorithm_reference: not called CC=7 SCAR=40.3
Pod documented
919 0 my ($self,$result) = @_;
920 0 ▶ return '' if( ! defined $result || !ref($result) ||
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result and ref $result and $result->isa("Bio::Search::Result::ResultI") 0 0 0
Condition0%0/6
defined $result and ref $result and $result->isa("Bio::Search::Result::ResultI")
!ll&&!rl&&r
000
defined $result and ref $result
!ll&&!rl&&r
000
MC/DC0%0/3
defined $result and ref $result and $result->isa("Bio::Search::Result::ResultI")
defined $result ref $result $result->isa("Bio::Search::Result::ResultI")
Truth table0%0/4
A and B and C
A= defined $resultB= ref $resultC= $result->isa("Bio::Search::Result::ResultI")
ABCresult
0XX0
10X0
1100
1111
921 ! $result->isa('Bio::Search::Result::ResultI')) ;
922 0 ▶ if( $result->algorithm =~ /BLAST/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($result->algorithm =~ /BLAST/i) { } 0 0 0
elsif ($result->algorithm =~ /FAST/i) { } 0 0 0
923 0 my $res = $result->algorithm . ' ' . $result->algorithm_version . "<p>";
924 0 ▶ if( $result->algorithm_version =~ /WashU/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->algorithm_version =~ /WashU/i) { } 0 0 0
925 0 return $res .
926 "Copyright (C) 1996-2000 Washington University, Saint Louis, Missouri USA.<br>
927 All Rights Reserved.<p>
928 <b>Reference:</b> Gish, W. (1996-2000) <a href=\"http://blast.wustl.edu\">http://blast.wustl.edu</a><p>";
929 } else {
930 0 return $res .
931 "<b>Reference:</b> Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer,<br>
932 Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997),<br>
933 \"Gapped BLAST and PSI-BLAST: a new generation of protein database search<br>
934 programs\", Nucleic Acids Res. 25:3389-3402.<p>";
935  
936 }
937 } elsif( $result->algorithm =~ /FAST/i ) {
938 0 return $result->algorithm . " " . $result->algorithm_version . "<br>" .
939 "\n<b>Reference:</b> Pearson et al, Genomics (1997) 46:24-36<p>";
940 } else {
941 0 return '';
942 }
943 }
944  
945 # from Perl Cookbook 2.17
946 23 ▶sub _numwithcommas {
Subroutine _numwithcommas: called CC=1 SCAR=0.0
947 23 my $num = reverse( $_[0] );
948 23 $num =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g;
949 23 return scalar reverse $num;
950 }
951  
952 =head2 Methods Bio::SearchIO::SearchWriterI
953  
954 L<Bio::SearchIO::SearchWriterI> inherited methods.
955  
956 =head2 filter
957  
958 Title : filter
959 Usage : $writer->filter('hsp', \&hsp_filter);
960 Function: Filter out either at HSP,Hit,or Result level
961 Returns : none
962 Args : string => data type,
963 CODE reference
964  
965  
966 =cut
967  
968  
969 =head2 no_wublastlinks
970  
971 Title : no_wublastlinks
972 Usage : $obj->no_wublastlinks($newval)
973 Function: Get/Set boolean value regarding whether or not to display
974 Link = (1)
975 type output in the report output (WU-BLAST only)
976 Returns : boolean
977 Args : on set, new boolean value (a scalar or undef, optional)
978  
979  
980 =cut
981  
982 2 ▶sub no_wublastlinks{
Subroutine no_wublastlinks: called CC=2 SCAR=6.9
Pod documented
983 2 my $self = shift;
984  
985 2 ▶ return $self->{'no_wublastlinks'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 1 2
986 1 return $self->{'no_wublastlinks'};
987 }
988  
989 2 1;
« Bio/SeqIO/embl.pm ↑ Summary Bio/OntologyIO/Handlers/InterPro_BioSQL_Handler.pm »