Bio/SearchIO/blast.pm

filter: Statementstmt 85.1% 532 / 625 Branchbran 78.6% 332 / 422 Conditioncond 75.3% 116 / 154 MC/DCmcdc 47.7% 42 / 88 Subroutinesub 91.6% 22 / 24 Podpod 92.3% 12 / 13 totaltotal 79.6% 1056 / 1326 CC 279 SCAR 63.5
CC
279
Cov
82%
next_result
731.0
end_element
14.0
BEGIN
8.0
CRAP 570.2
« Bio/Search/SearchUtils.pm ↑ Summary Bio/OntologyIO/Handlers/InterProHandler.pm »
1 #
2 # BioPerl module for Bio::SearchIO::blast
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 # POD documentation - main docs before the code
13  
14 # 20030409 - sac
15 # PSI-BLAST full parsing support. Rollout of new
16 # model which will remove Steve's old psiblast driver
17 # 20030424 - jason
18 # Megablast parsing fix as reported by Neil Saunders
19 # 20030427 - jason
20 # Support bl2seq parsing
21 # 20031124 - jason
22 # Parse more blast statistics, lambda, entropy, etc
23 # from WU-BLAST in frame-specific manner
24 # 20060216 - cjf - fixed blast parsing for BLAST v2.2.13 output
25 # 20071104 - dmessina - added support for WUBLAST -echofilter
26 # 20071121 - cjf - fixed several bugs (bugs 2391, 2399, 2409)
27  
28 =head1 NAME
29  
30 Bio::SearchIO::blast - Event generator for event based parsing of
31 blast reports
32  
33 =head1 SYNOPSIS
34  
35 # Do not use this object directly - it is used as part of the
36 # Bio::SearchIO system.
37  
38 use Bio::SearchIO;
39 my $searchio = Bio::SearchIO->new(-format => 'blast',
40 -file => 't/data/ecolitst.bls');
41 while( my $result = $searchio->next_result ) {
42 while( my $hit = $result->next_hit ) {
43 while( my $hsp = $hit->next_hsp ) {
44 # ...
45 }
46 }
47 }
48  
49 =head1 DESCRIPTION
50  
51 This object encapsulated the necessary methods for generating events
52 suitable for building Bio::Search objects from a BLAST report file.
53 Read the L<Bio::SearchIO> for more information about how to use this.
54  
55 This driver can parse:
56  
57 =over 4
58  
59 =item *
60  
61 NCBI produced plain text BLAST reports from blastall, this also
62 includes PSIBLAST, PSITBLASTN, RPSBLAST, and bl2seq reports. NCBI XML
63 BLAST output is parsed with the blastxml SearchIO driver
64  
65 =item *
66  
67 WU-BLAST all reports
68  
69 =item *
70  
71 Jim Kent's BLAST-like output from his programs (BLASTZ, BLAT)
72  
73 =item *
74  
75 BLAST-like output from Paracel BTK output
76  
77 =back
78  
79 =head2 bl2seq parsing
80  
81 Since I cannot differentiate between BLASTX and TBLASTN since bl2seq
82 doesn't report the algorithm used - I assume it is BLASTX by default -
83 you can supply the program type with -report_type in the SearchIO
84 constructor i.e.
85  
86 my $parser = Bio::SearchIO->new(-format => 'blast',
87 -file => 'bl2seq.tblastn.report',
88 -report_type => 'tblastn');
89  
90 This only really affects where the frame and strand information are
91 put - they will always be on the $hsp-E<gt>query instead of on the
92 $hsp-E<gt>hit part of the feature pair for blastx and tblastn bl2seq
93 produced reports. Hope that's clear...
94  
95 =head1 FEEDBACK
96  
97 =head2 Mailing Lists
98  
99 User feedback is an integral part of the evolution of this and other
100 Bioperl modules. Send your comments and suggestions preferably to
101 the Bioperl mailing list. Your participation is much appreciated.
102  
103 bioperl-l@bioperl.org - General discussion
104 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
105  
106 =head2 Support
107  
108 Please direct usage questions or support issues to the mailing list:
109  
110 I<bioperl-l@bioperl.org>
111  
112 rather than to the module maintainer directly. Many experienced and
113 reponsive experts will be able look at the problem and quickly
114 address it. Please include a thorough description of the problem
115 with code and data examples if at all possible.
116  
117 =head2 Reporting Bugs
118  
119 Report bugs to the Bioperl bug tracking system to help us keep track
120 of the bugs and their resolution. Bug reports can be submitted via the
121 web:
122  
123 https://github.com/bioperl/bioperl-live/issues
124  
125 =head1 AUTHOR - Jason Stajich
126  
127 Email Jason Stajich jason-at-bioperl.org
128  
129 =head1 CONTRIBUTORS
130  
131 Steve Chervitz sac-at-bioperl.org
132  
133 =head1 APPENDIX
134  
135 The rest of the documentation details each of the object methods.
136 Internal methods are usually preceded with a _
137  
138 =cut
139  
140 # Let the code begin...'
141  
142 package Bio::SearchIO::blast;
143 12 $Bio::SearchIO::blast::VERSION = '1.7.8';
144 12 ▶use Bio::SearchIO::IteratedSearchResultEventBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
145 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
146 12 ▶use vars qw(%MAPPING %MODEMAP
Subroutine BEGIN: called CC=1 SCAR=0.0
147 $DEFAULT_BLAST_WRITER_CLASS
148 $MAX_HSP_OVERLAP
149 $DEFAULT_SIGNIF
150 $DEFAULT_SCORE
151 $DEFAULTREPORTTYPE
152 12 );
153  
154  
155 12 ▶use base qw(Bio::SearchIO);
Subroutine BEGIN: called CC=1 SCAR=0.0
156 12 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
157  
158 12 ▶BEGIN {
Subroutine BEGIN: called CC=8 SCAR=20.8
159  
160 # mapping of NCBI Blast terms to Bioperl hash keys
161 12 %MODEMAP = (
162 'BlastOutput' => 'result',
163 'Iteration' => 'iteration',
164 'Hit' => 'hit',
165 'Hsp' => 'hsp'
166 );
167  
168 # This should really be done more intelligently, like with
169 # XSLT
170  
171 12 %MAPPING = (
172 'Hsp_bit-score' => 'HSP-bits',
173 'Hsp_score' => 'HSP-score',
174 'Hsp_evalue' => 'HSP-evalue',
175 'Hsp_n', => 'HSP-n',
176 'Hsp_pvalue' => 'HSP-pvalue',
177 'Hsp_query-from' => 'HSP-query_start',
178 'Hsp_query-to' => 'HSP-query_end',
179 'Hsp_hit-from' => 'HSP-hit_start',
180 'Hsp_hit-to' => 'HSP-hit_end',
181 'Hsp_positive' => 'HSP-conserved',
182 'Hsp_identity' => 'HSP-identical',
183 'Hsp_gaps' => 'HSP-hsp_gaps',
184 'Hsp_hitgaps' => 'HSP-hit_gaps',
185 'Hsp_querygaps' => 'HSP-query_gaps',
186 'Hsp_qseq' => 'HSP-query_seq',
187 'Hsp_hseq' => 'HSP-hit_seq',
188 'Hsp_midline' => 'HSP-homology_seq',
189 'Hsp_align-len' => 'HSP-hsp_length',
190 'Hsp_query-frame' => 'HSP-query_frame',
191 'Hsp_hit-frame' => 'HSP-hit_frame',
192 'Hsp_links' => 'HSP-links',
193 'Hsp_group' => 'HSP-hsp_group',
194 'Hsp_features' => 'HSP-hit_features',
195  
196 'Hit_id' => 'HIT-name',
197 'Hit_len' => 'HIT-length',
198 'Hit_accession' => 'HIT-accession',
199 'Hit_def' => 'HIT-description',
200 'Hit_signif' => 'HIT-significance',
201 # For NCBI blast, the description line contains bits.
202 # For WU-blast, the description line contains score.
203 'Hit_score' => 'HIT-score',
204 'Hit_bits' => 'HIT-bits',
205  
206 'Iteration_iter-num' => 'ITERATION-number',
207 'Iteration_converged' => 'ITERATION-converged',
208  
209 'BlastOutput_program' => 'RESULT-algorithm_name',
210 'BlastOutput_version' => 'RESULT-algorithm_version',
211 'BlastOutput_algorithm-reference' => 'RESULT-algorithm_reference',
212 'BlastOutput_rid' => 'RESULT-rid',
213 'BlastOutput_query-def' => 'RESULT-query_name',
214 'BlastOutput_query-len' => 'RESULT-query_length',
215 'BlastOutput_query-acc' => 'RESULT-query_accession',
216 'BlastOutput_query-gi' => 'RESULT-query_gi',
217 'BlastOutput_querydesc' => 'RESULT-query_description',
218 'BlastOutput_db' => 'RESULT-database_name',
219 'BlastOutput_db-len' => 'RESULT-database_entries',
220 'BlastOutput_db-let' => 'RESULT-database_letters',
221 'BlastOutput_inclusion-threshold' => 'RESULT-inclusion_threshold',
222  
223 'Parameters_matrix' => { 'RESULT-parameters' => 'matrix' },
224 'Parameters_expect' => { 'RESULT-parameters' => 'expect' },
225 'Parameters_include' => { 'RESULT-parameters' => 'include' },
226 'Parameters_sc-match' => { 'RESULT-parameters' => 'match' },
227 'Parameters_sc-mismatch' => { 'RESULT-parameters' => 'mismatch' },
228 'Parameters_gap-open' => { 'RESULT-parameters' => 'gapopen' },
229 'Parameters_gap-extend' => { 'RESULT-parameters' => 'gapext' },
230 'Parameters_filter' => { 'RESULT-parameters' => 'filter' },
231 'Parameters_allowgaps' => { 'RESULT-parameters' => 'allowgaps' },
232 'Parameters_full_dbpath' => { 'RESULT-parameters' => 'full_dbpath' },
233 'Statistics_db-len' => { 'RESULT-statistics' => 'dbentries' },
234 'Statistics_db-let' => { 'RESULT-statistics' => 'dbletters' },
235 'Statistics_hsp-len' =>
236 { 'RESULT-statistics' => 'effective_hsplength' },
237 'Statistics_query-len' => { 'RESULT-statistics' => 'querylength' },
238 'Statistics_eff-space' => { 'RESULT-statistics' => 'effectivespace' },
239 'Statistics_eff-spaceused' =>
240 { 'RESULT-statistics' => 'effectivespaceused' },
241 'Statistics_eff-dblen' =>
242 { 'RESULT-statistics' => 'effectivedblength' },
243 'Statistics_kappa' => { 'RESULT-statistics' => 'kappa' },
244 'Statistics_lambda' => { 'RESULT-statistics' => 'lambda' },
245 'Statistics_entropy' => { 'RESULT-statistics' => 'entropy' },
246 'Statistics_gapped_kappa' => { 'RESULT-statistics' => 'kappa_gapped' },
247 'Statistics_gapped_lambda' =>
248 { 'RESULT-statistics' => 'lambda_gapped' },
249 'Statistics_gapped_entropy' =>
250 { 'RESULT-statistics' => 'entropy_gapped' },
251  
252 'Statistics_framewindow' =>
253 { 'RESULT-statistics' => 'frameshiftwindow' },
254 'Statistics_decay' => { 'RESULT-statistics' => 'decayconst' },
255  
256 'Statistics_hit_to_db' => { 'RESULT-statistics' => 'Hits_to_DB' },
257 'Statistics_num_suc_extensions' =>
258 { 'RESULT-statistics' => 'num_successful_extensions' },
259 'Statistics_length_adjustment' => { 'RESULT-statistics' => 'length_adjustment' },
260 'Statistics_number_of_hsps_better_than_expect_value_cutoff_without_gapping' =>
261 { 'RESULT-statistics' => 'number_of_hsps_better_than_expect_value_cutoff_without_gapping' },
262 'Statistics_number_of_hsps_gapped' => { 'RESULT-statistics' => 'number_of_hsps_gapped' },
263 'Statistics_number_of_hsps_successfully_gapped' => { 'RESULT-statistics' => 'number_of_hsps_successfully_gapped' },
264  
265 # WU-BLAST stats
266 'Statistics_DFA_states' => { 'RESULT-statistics' => 'num_dfa_states' },
267 'Statistics_DFA_size' => { 'RESULT-statistics' => 'dfa_size' },
268 'Statistics_noprocessors' =>
269 { 'RESULT-statistics' => 'no_of_processors' },
270 'Statistics_neighbortime' =>
271 { 'RESULT-statistics' => 'neighborhood_generate_time' },
272 'Statistics_starttime' => { 'RESULT-statistics' => 'start_time' },
273 'Statistics_endtime' => { 'RESULT-statistics' => 'end_time' },
274 );
275  
276 # add WU-BLAST Frame-Based Statistics
277 12 for my $frame ( 0 .. 3 ) {
278 48 for my $strand ( '+', '-' ) {
279 96 for my $ind (
280 qw(length efflength E S W T X X_gapped E2
281 E2_gapped S2)
282 )
283 {
284 1056 $MAPPING{"Statistics_frame$strand$frame\_$ind"} =
285 { 'RESULT-statistics' => "Frame$strand$frame\_$ind" };
286 }
287 96 for my $val (qw(lambda kappa entropy )) {
288 288 for my $type (qw(used computed gapped)) {
289 864 my $key = "Statistics_frame$strand$frame\_$val\_$type";
290 864 my $val =
291 { 'RESULT-statistics' =>
292 "Frame$strand$frame\_$val\_$type" };
293 864 $MAPPING{$key} = $val;
294 }
295 }
296 }
297 }
298  
299 # add Statistics
300 12 for my $stats (
301 qw(T A X1 X2 X3 S1 S2 X1_bits X2_bits X3_bits
302 S1_bits S2_bits num_extensions
303 num_successful_extensions
304 seqs_better_than_cutoff
305 posted_date
306 search_cputime total_cputime
307 search_actualtime total_actualtime
308 no_of_processors ctxfactor)
309 )
310 {
311 264 my $key = "Statistics_$stats";
312 264 my $val = { 'RESULT-statistics' => $stats };
313 264 $MAPPING{$key} = $val;
314 }
315  
316 # add WU-BLAST Parameters
317 12 for my $param (
318 qw(span span1 span2 links warnings notes hspsepsmax
319 hspsepqmax topcomboN topcomboE postsw cpus wordmask
320 filter sort_by_pvalue sort_by_count sort_by_highscore
321 sort_by_totalscore sort_by_subjectlength noseqs gi qtype
322 qres V B Z Y M N)
323 )
324 {
325 348 my $key = "Parameters_$param";
326 348 my $val = { 'RESULT-parameters' => $param };
327 348 $MAPPING{$key} = $val;
328 }
329  
330 12 $DEFAULT_BLAST_WRITER_CLASS = 'Bio::SearchIO::Writer::HitTableWriter';
331 12 $MAX_HSP_OVERLAP = 2; # Used when tiling multiple HSPs.
332 12 $DEFAULTREPORTTYPE = 'BLASTP'; # for bl2seq
333 }
334  
335 =head2 new
336  
337 Title : new
338 Usage : my $obj = Bio::SearchIO::blast->new(%args);
339 Function: Builds a new Bio::SearchIO::blast object
340 Returns : Bio::SearchIO::blast
341 Args : Key-value pairs:
342 -fh/-file => filehandle/filename to BLAST file
343 -format => 'blast'
344 -report_type => 'blastx', 'tblastn', etc -- only for bl2seq
345 reports when you want to distinguish between
346 tblastn and blastx reports (this only controls
347 where the frame information is put - on the query
348 or subject object.
349 -inclusion_threshold => e-value threshold for inclusion in the
350 PSI-BLAST score matrix model (blastpgp)
351 -signif => float or scientific notation number to be used
352 as a P- or Expect value cutoff
353 -score => integer or scientific notation number to be used
354 as a blast score value cutoff
355 -bits => integer or scientific notation number to be used
356 as a bit score value cutoff
357 -hit_filter => reference to a function to be used for
358 filtering hits based on arbitrary criteria.
359 All hits of each BLAST report must satisfy
360 this criteria to be retained.
361 If a hit fails this test, it is ignored.
362 This function should take a
363 Bio::Search::Hit::BlastHit.pm object as its first
364 argument and return true
365 if the hit should be retained.
366 Sample filter function:
367 -hit_filter => sub { $hit = shift;
368 $hit->gaps == 0; },
369 (Note: -filt_func is synonymous with -hit_filter)
370 -overlap => integer. The amount of overlap to permit between
371 adjacent HSPs when tiling HSPs. A reasonable value is 2.
372 Default = $Bio::SearchIO::blast::MAX_HSP_OVERLAP.
373  
374 The following criteria are not yet supported:
375 (these are probably best applied within this module rather than in the
376 event handler since they would permit the parser to take some shortcuts.)
377  
378 -check_all_hits => boolean. Check all hits for significance against
379 significance criteria. Default = false.
380 If false, stops processing hits after the first
381 non-significant hit or the first hit that fails
382 the hit_filter call. This speeds parsing,
383 taking advantage of the fact that the hits
384 are processed in the order they appear in the report.
385 -min_query_len => integer to be used as a minimum for query sequence length.
386 Reports with query sequences below this length will
387 not be processed. Default = no minimum length.
388 -best => boolean. Only process the best hit of each report;
389 default = false.
390  
391 =cut
392  
393 45 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=6.9
394 45 my ( $self, @args ) = @_;
395 45 $self->SUPER::_initialize(@args);
396  
397 # Blast reports require a specialized version of the SREB due to the
398 # possibility of iterations (PSI-BLAST). Forwarding all arguments to it. An
399 # issue here is that we want to set new default object factories if none are
400 # supplied.
401  
402 45 my $handler = Bio::SearchIO::IteratedSearchResultEventBuilder->new(@args);
403 45 $self->attach_EventHandler($handler);
404  
405 # 2006-04-26 move this to the attach_handler function in this module so we
406 # can really reset the handler
407 # Optimization: caching
408 # the EventHandler since it is used a lot during the parse.
409  
410 # $self->{'_handler_cache'} = $handler;
411  
412 45 my ($rpttype ) = $self->_rearrange(
413 [
414 qw(
415 REPORT_TYPE)
416 ],
417 @args
418 );
419 45 ▶ defined $rpttype && ( $self->{'_reporttype'} = $rpttype );
Branch: 1 branch
BranchTrueFalseTotal
defined $rpttype and $self->{"_reporttype"} = $rpttype 1 44 45
420 }
421  
422 90 ▶sub attach_EventHandler {
Subroutine attach_EventHandler: called CC=1 SCAR=0.0
Pod documented
423 90 my ($self,$handler) = @_;
424  
425 90 $self->SUPER::attach_EventHandler($handler);
426  
427 # Optimization: caching the EventHandler since it is used a lot
428 # during the parse.
429  
430 90 $self->{'_handler_cache'} = $handler;
431 90 return;
432 }
433  
434 =head2 next_result
435  
436 Title : next_result
437 Usage : my $hit = $searchio->next_result;
438 Function: Returns the next Result from a search
439 Returns : Bio::Search::Result::ResultI object
440 Args : none
441  
442 =cut
443  
444 42 ▶sub next_result {
Subroutine next_result: called CC=235 SCAR=65.9
Pod documented
445 42 my ($self) = @_;
446 42 my $v = $self->verbose;
447 42 my $data = '';
448 42 my $flavor = '';
449 42 $self->{'_seentop'} = 0; # start next report at top
450  
451 42 my ( $reporttype, $seenquery, $reportline, $reportversion );
452 42 my ( $seeniteration, $found_again );
453 42 my $incl_threshold = $self->inclusion_threshold;
454 42 my $bl2seq_fix;
455 42 $self->start_document(); # let the fun begin...
456 42 my (@hit_signifs);
457 42 my $gapped_stats = 0; # for switching between gapped/ungapped
458 # lambda, K, H
459 42 local $_ = "\n"; #consistency
460 PARSER:
461 42 ▶ while ( defined( $_ = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 7203 36 7239
462 7203 ▶ next if (/^\s+$/); # skip empty lines
Branch: 1 branch
BranchTrueFalseTotal
if /^\s+$/ 1971 5232 7203
463 5232 ▶ next if (/CPU time:/);
Branch: 1 branch
BranchTrueFalseTotal
if /CPU time:/ 2 5230 5232
464 5230 ▶ next if (/^>\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if /^>\s*$/ 0 5230 5230
465 5230 ▶ next if (/[*]+\s+No hits found\s+[*]+/);
Branch: 1 branch
BranchTrueFalseTotal
if /[*]+\s+No hits found\s+[*]+/ 0 5230 5230
466 5230 ▶ if (
Branch: 22 branches
BranchTrueFalseTotal
if (/^((?:\S+?)?BLAST[NPX]?)\s+(.+)$/i or /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i) { } 33 5197 5230
elsif (/^Reference:\s+(.*)$/) { } 32 5165 5197
elsif (/^RID:\s+(.*)$/) { } 2 5163 5165
elsif (/^(Searching|Results from round)/) { } 31 5132 5163
elsif (/^Query=\s*(.*)$/) { } 43 5089 5132
elsif (/^>Unfiltered[+-]1$/) { } 0 5089 5089
elsif (/Sequences producing significant alignments:/) { } 21 5068 5089
elsif (/Sequences producing High-scoring Segment Pairs:/) { } 16 5052 5068
elsif (/^Database:\s*(.+?)\s*$/) { } 34 5018 5052
elsif (/^(?:Subject=|>)\s*(\S+)\s*(.*)?/) { } 328 4690 5018
elsif (/\s+(Plus|Minus) Strand HSPs:/i) { } 11 4679 4690
elsif ($self->in_element('hit') || $self->in_element('hsp') and /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Raw score \s+Log\-Length\sScore\s*=\s*(\d+) # Log-Length score /ox) { } 0 4679 4679
elsif ($self->in_element('hit') || $self->in_element('hsp') and /Score\s*=\s*([^,\s]+), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*P(?:\(\S+\))?\s*=\s*([^,\s]+) # P-value /ox) { } 0 4679 4679
elsif ($self->in_element('hit') || $self->in_element('hsp') and /Score\s*=\s*(\S+)\s* # Bit score \(([\d\.]+)\s*bits\), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*(?:Sum)?\s* # SUM P(?:\(\d+\))?\s*=\s*([^,\s]+) # P-value (?:\s*,\s+Group\s*\=\s*(\d+))? # HSP Group /ox) { } 385 4294 4679
elsif ($self->in_element('hit') || $self->in_element('hsp') and /^\sFeatures\s\w+\sthis\spart/mosx) { } 0 4294 4294
elsif ($self->in_element('hit') || $self->in_element('hsp') and /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Missing for BLAT pseudo-BLAST fmt \s*Expect(?:\((\d+\+?)\))?\s*=\s*([^,\s]+) # E-value /ox) { } 296 3998 4294
elsif ($self->in_element('hsp') and m[Identities\s*=\s*(\d+)\s*/\s*(\d+)\s*[\d\%\(\)]+\s* (?:,\s*Positives\s*=\s*(\d+)/(\d+)\s*[\d\%\(\)]+\s*)? # pos only valid for Protein alignments (?:\,\s*Gaps\s*=\s*(\d+)/(\d+))? # Gaps ]iox) { } 681 3317 3998
elsif ($self->in_element('hsp') and m[Strand\s*=\s*(Plus|Minus)\s*/\s*(Plus|Minus)]i) { } 59 3258 3317
elsif ($self->in_element('hsp') and /Links\s*=\s*(\S+)/ox) { } 337 2921 3258
elsif ($self->in_element('hsp') and m[Frame\s*=\s*([\+\-][1-3])\s*(/\s*([\+\-][1-3]))?]) { } 148 2773 2921
elsif (/^Parameters:/ or /^\s+Database:\s+?/ or /^\s+Subset/ or /^\s*Lambda/ or /^\s*Histogram/ or $self->in_element('hsp') and /WARNING|NOTE/) { } 35 2738 2773
elsif ($self->in_element('hsp')) { } 2612 126 2738
Condition66%2/3
/^((?:\S+?)?BLAST[NPX]?)\s+(.+)$/i or /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
l!l&&r!l&&!r
3305197
MC/DC50%1/2
/^((?:\S+?)?BLAST[NPX]?)\s+(.+)$/i or /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
/^((?:\S+?)?BLAST[NPX]?)\s+(.+)$/i /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
Truth table66%2/3
A or B
A= /^((?:\S+?)?BLAST[NPX]?)\s+(.+)$/iB= /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
ABresult
1X1
011
000
467 /^((?:\S+?)?BLAST[NPX]?)\s+(.+)$/i # NCBI BLAST, PSIBLAST
468 # RPSBLAST, MEGABLAST
469 || /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i #Paracel BTK
470 )
471 {
472 33 ($reporttype, $reportversion) = ($1, $2);
473 # need to keep track of whether this is WU-BLAST
474 33 ▶ if ($reportversion && $reportversion =~ m{WashU$}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reportversion and $reportversion =~ /WashU$/) 0 33 33
Condition33%1/3
$reportversion and $reportversion =~ /WashU$/
!ll&&!rl&&r
0330
MC/DC0%0/2
$reportversion and $reportversion =~ /WashU$/
$reportversion $reportversion =~ /WashU$/
Truth table33%1/3
A and B
A= $reportversionB= $reportversion =~ /WashU$/
ABresult
0X0
100
111
475 0 $self->{'_wublast'}++;
476 }
477 33 $self->debug("blast.pm: Start of new report: $reporttype, $reportversion\n");
478 33 ▶ if ( $self->{'_seentop'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_seentop"}) 2 31 33
479 # This handles multi-result input streams
480 2 $self->_pushback($_);
481 2 last PARSER;
482 }
483 31 $self->_start_blastoutput;
484 31 ▶ if ($reporttype =~ /RPS-BLAST/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reporttype =~ /RPS-BLAST/) 0 31 31
485 0 $reporttype .= '(BLASTP)'; # default RPS-BLAST type
486 }
487 31 $reportline = $_; # to fix the fact that RPS-BLAST output is wrong
488 31 $self->element(
489 {
490 'Name' => 'BlastOutput_program',
491 'Data' => $reporttype
492 }
493 );
494  
495 31 $self->element(
496 {
497 'Name' => 'BlastOutput_version',
498 'Data' => $reportversion
499 }
500 );
501 31 $self->element(
502 {
503 'Name' => 'BlastOutput_inclusion-threshold',
504 'Data' => $incl_threshold
505 }
506 );
507 }
508 # parse the BLAST algorithm reference
509 elsif(/^Reference:\s+(.*)$/) {
510 # want to preserve newlines for the BLAST algorithm reference
511 32 my $algorithm_reference = "$1\n";
512 32 $_ = $self->_readline;
513 # while the current line, does not match an empty line, a RID:, a
514 # Database:, or a query definition line (Query=) we are still
515 # looking at the algorithm_reference, append it to what we parsed so
516 # far
517 32 ▶ while($_ !~ /^$/ && $_ !~ /^RID:/ && $_ !~ /^Database:/ && $_ !~ /^Query=/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ =~ /^$/ or $_ =~ /^RID:/ or $_ =~ /^Database:/ or $_ =~ /^Query=/) 53 32 85
Condition77%7/9
$_ =~ /^$/ or $_ =~ /^RID:/ or $_ =~ /^Database:/ or $_ =~ /^Query=/
l!l&&r!l&&!r
32053
$_ =~ /^$/ or $_ =~ /^RID:/ or $_ =~ /^Database:/
l!l&&r!l&&!r
32053
$_ =~ /^$/ or $_ =~ /^RID:/
l!l&&r!l&&!r
31153
MC/DC50%2/4
$_ =~ /^$/ or $_ =~ /^RID:/ or $_ =~ /^Database:/ or $_ =~ /^Query=/
$_ =~ /^$/ $_ =~ /^RID:/ $_ =~ /^Database:/ $_ =~ /^Query=/
Truth table60%3/5
A or B or C or D
A= $_ =~ /^$/B= $_ =~ /^RID:/C= $_ =~ /^Database:/D= $_ =~ /^Query=/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
518 53 $algorithm_reference .= "$_";
519 53 $_ = $self->_readline;
520 }
521 # if we exited the while loop, we saw an empty line, a RID:, or a
522 # Database:, so push it back
523 32 $self->_pushback($_);
524 32 $self->element(
525 {
526 'Name' => 'BlastOutput_algorithm-reference',
527 'Data' => $algorithm_reference
528 }
529 );
530 }
531 # parse BLAST RID (Request ID)
532 elsif(/^RID:\s+(.*)$/) {
533 2 my $rid = $1;
534 2 $self->element(
535 {
536 'Name' => 'BlastOutput_rid',
537 'Data' => $rid
538 }
539 );
540 }
541 # added Windows workaround for bug 1985
542 elsif (/^(Searching|Results from round)/) {
543 31 ▶ next unless $1 =~ /Results from round/;
Branch: 1 branch
BranchTrueFalseTotal
unless $1 =~ /Results from round/ 31 0 31
544 0 $self->debug("blast.pm: Possible psi blast iterations found...\n");
545  
546 0 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 0 0 0
547 && $self->end_element( { 'Name' => 'Hsp' } );
548 0 ▶ $self->in_element('hit')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hit") and $self->end_element({"Name", "Hit"}) 0 0 0
549 && $self->end_element( { 'Name' => 'Hit' } );
550 0 ▶ if ( defined $seeniteration ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seeniteration) { } 0 0 0
551 0 ▶ $self->within_element('iteration')
Branch: 1 branch
BranchTrueFalseTotal
$self->within_element("iteration") and $self->end_element({"Name", "Iteration"}) 0 0 0
552 && $self->end_element( { 'Name' => 'Iteration' } );
553 0 $self->start_element( { 'Name' => 'Iteration' } );
554 }
555 else {
556 0 $self->start_element( { 'Name' => 'Iteration' } );
557 }
558 0 $seeniteration = 1;
559 }
560 elsif (/^Query=\s*(.*)$/) {
561 43 my $q = $1;
562 43 $self->debug("blast.pm: Query= found...$_\n");
563 43 my $size = 0;
564 43 ▶ if ( defined $seenquery ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seenquery) 4 39 43
565 4 $self->_pushback($_);
566 4 ▶ $self->_pushback($reportline) if $reportline;
Branch: 1 branch
BranchTrueFalseTotal
if $reportline 0 4 4
567 4 last PARSER;
568 }
569 39 ▶ if ( !defined $reporttype ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $reporttype) 8 31 39
570 8 $self->_start_blastoutput;
571 8 ▶ if ( defined $seeniteration ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seeniteration) { } 0 8 8
572 0 ▶ $self->in_element('iteration')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("iteration") and $self->end_element({"Name", "Iteration"}) 0 0 0
573 && $self->end_element( { 'Name' => 'Iteration' } );
574 0 $self->start_element( { 'Name' => 'Iteration' } );
575 }
576 else {
577 8 $self->start_element( { 'Name' => 'Iteration' } );
578 }
579 8 $seeniteration = 1;
580 }
581 39 $seenquery = $q;
582 39 $_ = $self->_readline;
583 39 ▶ while ( defined($_) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) 55 0 55
584 55 ▶ if (/^Database:/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^Database:/) 0 55 55
585 0 $self->_pushback($_);
586 0 last;
587 }
588 # below line fixes length issue with BLAST v2.2.13; still works
589 # with BLAST v2.2.12
590 55 ▶ if ( /\((\-?[\d,]+)\s+letters.*\)/ || /^Length=(\-?[\d,]+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/\((\-?[\d,]+)\s+letters.*\)/ or /^Length=(\-?[\d,]+)/) { } 39 16 55
Condition66%2/3
/\((\-?[\d,]+)\s+letters.*\)/ or /^Length=(\-?[\d,]+)/
l!l&&r!l&&!r
39016
MC/DC50%1/2
/\((\-?[\d,]+)\s+letters.*\)/ or /^Length=(\-?[\d,]+)/
/\((\-?[\d,]+)\s+letters.*\)/ /^Length=(\-?[\d,]+)/
Truth table66%2/3
A or B
A= /\((\-?[\d,]+)\s+letters.*\)/B= /^Length=(\-?[\d,]+)/
ABresult
1X1
011
000
591 39 $size = $1;
592 39 $size =~ s/,//g;
593 39 last;
594 }
595 else {
596 # bug 2391
597 16 ▶ $q .= ($q =~ /\w$/ && $_ =~ /^\w/) ? " $_" : $_;
Branch: 1 branch
BranchTrueFalseTotal
$q =~ /\w$/ && $_ =~ /^\w/ ? : 2 14 16
Condition100%3/3
$q =~ /\w$/ and $_ =~ /^\w/
!ll&&!rl&&r
3112
MC/DC100%2/2
$q =~ /\w$/ and $_ =~ /^\w/
$q =~ /\w$/ $_ =~ /^\w/
Truth table100%3/3
A and B
A= $q =~ /\w$/B= $_ =~ /^\w/
ABresult
0X0
100
111
598 16 $q =~ s/\s+/ /g; # this catches the newline as well
599 16 $q =~ s/^ | $//g;
600 }
601  
602 16 $_ = $self->_readline;
603 }
604 39 chomp($q);
605 39 my ( $nm, $desc ) = split( /\s+/, $q, 2 );
606 39 ▶ $self->element(
Branch: 1 branch
BranchTrueFalseTotal
if $nm 37 2 39
607 {
608 'Name' => 'BlastOutput_query-def',
609 'Data' => $nm
610 }
611 ) if $nm;
612 39 $self->element(
613 {
614 'Name' => 'BlastOutput_query-len',
615 'Data' => $size
616 }
617 );
618 39 ▶ defined $desc && $desc =~ s/\s+$//;
Branch: 1 branch
BranchTrueFalseTotal
defined $desc and $desc =~ s/\s+$// 22 17 39
619 39 $self->element(
620 {
621 'Name' => 'BlastOutput_querydesc',
622 'Data' => $desc
623 }
624 );
625 39 my ( $gi, $acc, $version ) = $self->_get_seq_identifiers($nm);
626 39 ▶ $version = defined($version) && length($version) ? ".$version" : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $version && length $version ? : 7 32 39
Condition66%2/3
defined $version and length $version
!ll&&!rl&&r
3207
MC/DC50%1/2
defined $version and length $version
defined $version length $version
Truth table66%2/3
A and B
A= defined $versionB= length $version
ABresult
0X0
100
111
627 39 ▶ $self->element(
Branch: 1 branch
BranchTrueFalseTotal
if $acc 37 2 39
628 {
629 'Name' => 'BlastOutput_query-acc',
630 'Data' => "$acc$version"
631 }
632 ) if $acc;
633  
634 # these elements are dropped with some multiquery reports; add
635 # back here
636 $self->element(
637 {
638 'Name' => 'BlastOutput_db-len',
639 'Data' => $self->{'_blsdb_length'}
640 }
641 39 ▶ ) if $self->{'_blsdb_length'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_blsdb_length"} 1 38 39
642 $self->element(
643 {
644 'Name' => 'BlastOutput_db-let',
645 'Data' => $self->{'_blsdb_letters'}
646 }
647 39 ▶ ) if $self->{'_blsdb_letters'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_blsdb_letters"} 1 38 39
648 $self->element(
649 {
650 'Name' => 'BlastOutput_db',
651 'Data' => $self->{'_blsdb'}
652 }
653 39 ▶ ) if $self->{'_blsdb_letters'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_blsdb_letters"} 1 38 39
654 }
655 # added check for WU-BLAST -echofilter option (bug 2388)
656 elsif (/^>Unfiltered[+-]1$/) {
657 # skip all of the lines of unfiltered sequence
658 0 ▶ while($_ !~ /^Database:/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ =~ /^Database:/) 0 0 0
659 0 $self->debug("Bypassing features line: $_");
660 0 $_ = $self->_readline;
661 }
662 0 $self->_pushback($_);
663 }
664 elsif (/Sequences producing significant alignments:/) {
665 21 $self->debug("blast.pm: Processing NCBI-BLAST descriptions\n");
666 21 $flavor = 'ncbi';
667  
668 # PSI-BLAST parsing needs to be fixed to specifically look
669 # for old vs new per iteration, as sorting based on duplication
670 # leads to bugs, see bug 1986
671  
672 # The next line is not necessarily whitespace in psiblast reports.
673 # Also note that we must look for the end of this section by testing
674 # for a line with a leading >. Blank lines occur with this section
675 # for psiblast.
676 21 ▶ if ( !$self->in_element('iteration') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->in_element("iteration")) 17 4 21
677 17 $self->start_element( { 'Name' => 'Iteration' } );
678 }
679  
680 # changed 8/28/2008 to exit hit table if blank line is found after an
681 # appropriate line
682 21 my $h_regex;
683 my $seen_block;
684 DESCLINE:
685 21 ▶ while ( defined( my $descline = $self->_readline() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $descline = $self->_readline)) 418 0 418
686 418 ▶ if ($descline =~ m{^\s*$}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descline =~ /^\s*$/) 41 377 418
687 41 ▶ last DESCLINE if $seen_block;
Branch: 1 branch
BranchTrueFalseTotal
if $seen_block 20 21 41
688 21 next DESCLINE;
689 }
690 # any text match is part of block...
691 377 $seen_block++;
692 # GCG multiline oddness...
693 377 ▶ if ($descline =~ /^(\S+)\s+Begin:\s\d+\s+End:\s+\d+/xms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descline =~ /^(\S+)\s+Begin:\s\d+\s+End:\s+\d+/msx) 0 377 377
694 0 my ($id, $nextline) = ($1, $self->_readline);
695 0 $nextline =~ s{^!}{};
696 0 $descline = "$id $nextline";
697 }
698 # NCBI style hit table (no N)
699 377 ▶ if ($descline =~ /(?<!cor) # negative lookahead
Branch: 2 branches
BranchTrueFalseTotal
if ($descline =~ /(?<!cor) # negative lookahead (\d*\.?(?:[\+\-eE]+)?\d+) # number (float or scientific notation) \s+ # space (\d*\.?(?:[\+\-eE]+)?\d+) # number (float or scientific notation) \s*$/msx) { } 376 1 377
elsif ($descline =~ /^CONVERGED/i) { } 0 1 1
700 (\d*\.?(?:[\+\-eE]+)?\d+) # number (float or scientific notation)
701 \s+ # space
702 (\d*\.?(?:[\+\-eE]+)?\d+) # number (float or scientific notation)
703 \s*$/xms) {
704  
705 376 my ( $score, $evalue ) = ($1, $2);
706  
707 # Some data clean-up so e-value will appear numeric to perl
708 376 $evalue =~ s/^e/1e/i;
709  
710 # This to handle no-HSP case
711 376 my @line = split ' ',$descline;
712  
713 # we want to throw away the score, evalue
714 376 pop @line, pop @line;
715  
716 # and N if it is present (of course they are not
717 # really in that order, but it doesn't matter
718 0 ▶ if ($3) { pop @line }
Branch: 1 branch
BranchTrueFalseTotal
if ($3) 0 376 376
719  
720 # add the last 2 entries s.t. we can reconstruct
721 # a minimal Hit object at the end of the day
722 376 push @hit_signifs, [ $evalue, $score, shift @line, join( ' ', @line ) ];
723 } elsif ($descline =~ /^CONVERGED/i) {
724 0 $self->element(
725 {
726 'Name' => 'Iteration_converged',
727 'Data' => 1
728 }
729 );
730 } else {
731 1 $self->_pushback($descline); # Catch leading > (end of section)
732 1 last DESCLINE;
733 }
734 }
735 }
736 elsif (/Sequences producing High-scoring Segment Pairs:/) {
737  
738 # This block is for WU-BLAST, so we don't have to check for psi-blast stuff
739 # skip the next line
740 16 $self->debug("blast.pm: Processing WU-BLAST descriptions\n");
741 16 $_ = $self->_readline();
742 16 $flavor = 'wu';
743  
744 16 ▶ if ( !$self->in_element('iteration') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->in_element("iteration")) 14 2 16
745 14 $self->start_element( { 'Name' => 'Iteration' } );
746 }
747  
748 16 ▶ while ( defined( $_ = $self->_readline() )
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline) and not /^\s+$/) 492 16 508
Condition66%2/3
defined($_ = $self->_readline) and not /^\s+$/
!ll&&!rl&&r
016492
MC/DC50%1/2
defined($_ = $self->_readline) and not /^\s+$/
defined($_ = $self->_readline) not /^\s+$/
Truth table66%2/3
A and not(B)
A= defined($_ = $self->_readline)B= not /^\s+$/
ABresult
0X0
100
111
749 && !/^\s+$/ )
750 {
751 492 my @line = split;
752 492 pop @line; # throw away first number which is for 'N'col
753  
754 # add the last 2 entries to array s.t. we can reconstruct
755 # a minimal Hit object at the end of the day
756 492 push @hit_signifs,
757 [ pop @line, pop @line, shift @line, join( ' ', @line ) ];
758 }
759  
760 }
761 elsif (/^Database:\s*(.+?)\s*$/) {
762  
763 34 $self->debug("blast.pm: Database: $1\n");
764 34 my $db = $1;
765 34 ▶ while ( defined( $_ = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 70 1 71
766 70 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s+(\-?[\d\,]+|\S+)\s+sequences\; \s+(\-?[\d,]+|\S+)\s+ # Deal with NCBI 2.2.8 OSX problems total\s+letters/ox) { } 33 37 70
767 /^\s+(\-?[\d\,]+|\S+)\s+sequences\;
768 \s+(\-?[\d,]+|\S+)\s+ # Deal with NCBI 2.2.8 OSX problems
769 total\s+letters/ox
770 )
771 {
772 33 my ( $s, $l ) = ( $1, $2 );
773 33 $s =~ s/,//g;
774 33 $l =~ s/,//g;
775 33 $self->element(
776 {
777 'Name' => 'BlastOutput_db-len',
778 'Data' => $s
779 }
780 );
781 33 $self->element(
782 {
783 'Name' => 'BlastOutput_db-let',
784 'Data' => $l
785 }
786 );
787 # cache for next round in cases with multiple queries
788 33 $self->{'_blsdb'} = $db;
789 33 $self->{'_blsdb_length'} = $s;
790 33 $self->{'_blsdb_letters'} = $l;
791 33 last;
792 }
793 else {
794 37 chomp;
795 37 $db .= $_;
796 }
797 }
798 $self->element(
799 {
800 34 'Name' => 'BlastOutput_db',
801 'Data' => $db
802 }
803 );
804 }
805  
806 # move inside of a hit
807 elsif (/^(?:Subject=|>)\s*(\S+)\s*(.*)?/) {
808 328 chomp;
809  
810 328 $self->debug("blast.pm: Hit: $1\n");
811 328 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 289 39 328
812 && $self->end_element( { 'Name' => 'Hsp' } );
813 328 ▶ $self->in_element('hit')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hit") and $self->end_element({"Name", "Hit"}) 289 39 328
814 && $self->end_element( { 'Name' => 'Hit' } );
815  
816 # special case when bl2seq reports don't have a leading
817 # Query=
818 328 ▶ if ( !$self->within_element('result') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->within_element('result')) { } 1 327 328
elsif (not $self->within_element('iteration')) { } 0 327 327
819 1 $self->_start_blastoutput;
820 1 $self->start_element( { 'Name' => 'Iteration' } );
821 }
822 elsif ( !$self->within_element('iteration') ) {
823 0 $self->start_element( { 'Name' => 'Iteration' } );
824 }
825 328 $self->start_element( { 'Name' => 'Hit' } );
826 328 my $id = $1;
827 328 my $restofline = $2;
828  
829 328 $self->debug("Starting a hit: $1 $2\n");
830 328 $self->element(
831 {
832 'Name' => 'Hit_id',
833 'Data' => $id
834 }
835 );
836 328 my ($gi, $acc, $version ) = $self->_get_seq_identifiers($id);
837 328 $self->element(
838 {
839 'Name' => 'Hit_accession',
840 'Data' => $acc
841 }
842 );
843 # add hit significance (from the hit table)
844 # this is where Bug 1986 went awry
845  
846 # Changed for Bug2409; hit->significance and hit->score/bits derived
847 # from HSPs, not hit table unless necessary
848  
849 HITTABLE:
850 328 ▶ while (my $v = shift @hit_signifs) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $v = shift @hit_signifs) 273 55 328
851 273 my $tableid = $v->[2];
852 273 ▶ if ($tableid !~ m{\Q$id\E}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $tableid =~ /\Q$id\E/) { } 0 273 273
853 0 $self->debug("Hit table ID $tableid doesn't match current hit id $id, checking next hit table entry...\n");
854 0 next HITTABLE;
855 } else {
856 273 last HITTABLE;
857 }
858 }
859 328 ▶ while ( defined( $_ = $self->_readline() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 589 0 589
860 589 ▶ next if (/^\s+$/);
Branch: 1 branch
BranchTrueFalseTotal
if /^\s+$/ 1 588 589
861 588 chomp;
862 588 ▶ if (/Length\s*=\s*([\d,]+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/Length\s*=\s*([\d,]+)/) { } 328 260 588
863 328 my $l = $1;
864 328 $l =~ s/\,//g;
865 328 $self->element(
866 {
867 'Name' => 'Hit_len',
868 'Data' => $l
869 }
870 );
871 328 last;
872 }
873 else {
874 260 ▶ if ($restofline !~ /\s$/) { # bug #3235
Branch: 1 branch
BranchTrueFalseTotal
unless ($restofline =~ /\s$/) 260 0 260
875 260 s/^\s(?!\s)/\x01/; #new line to concatenate desc lines with <soh>
876 }
877 260 ▶ $restofline .= ($restofline =~ /\w$/ && $_ =~ /^\w/) ? " $_" : $_;
Branch: 1 branch
BranchTrueFalseTotal
$restofline =~ /\w$/ && $_ =~ /^\w/ ? : 0 260 260
Condition66%2/3
$restofline =~ /\w$/ and $_ =~ /^\w/
!ll&&!rl&&r
731870
MC/DC0%0/2
$restofline =~ /\w$/ and $_ =~ /^\w/
$restofline =~ /\w$/ $_ =~ /^\w/
Truth table66%2/3
A and B
A= $restofline =~ /\w$/B= $_ =~ /^\w/
ABresult
0X0
100
111
878 260 $restofline =~ s/\s+/ /g; # this catches the newline as well
879 260 $restofline =~ s/^ | $//g;
880 }
881 }
882 328 $restofline =~ s/\s+/ /g;
883 328 $self->element(
884 {
885 'Name' => 'Hit_def',
886 'Data' => $restofline
887 }
888 );
889 }
890 elsif (/\s+(Plus|Minus) Strand HSPs:/i) {
891 11 next;
892 }
893 ▶ elsif (
Condition83%5/6
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Raw score \s+Log\-Length\sScore\s*=\s*(\d+) # Log-Length score /ox
!ll&&!rl&&r
12745520
$self->in_element("hit") or $self->in_element("hsp")
l!l&&r!l&&!r
3284224127
MC/DC0%0/3
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Raw score \s+Log\-Length\sScore\s*=\s*(\d+) # Log-Length score /ox
$self->in_element("hit") $self->in_element("hsp") /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Raw score \s+Log\-Length\sScore\s*=\s*(\d+) # Log-Length score /ox
Truth table60%3/5
A or B and C
A= $self->in_element("hit")B= $self->in_element("hsp")C= /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Raw score \s+Log\-Length\sScore\s*=\s*(\d+) # Log-Length score /ox
ABCresult
00X0
1X00
0100
1X11
0111
894 ( $self->in_element('hit') || $self->in_element('hsp') )
895 && # paracel genewise BTK
896 m/Score\s*=\s*(\S+)\s*bits\s* # Bit score
897 (?:\((\d+)\))?, # Raw score
898 \s+Log\-Length\sScore\s*=\s*(\d+) # Log-Length score
899 /ox
900 )
901 {
902 0 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 0 0 0
903 && $self->end_element( { 'Name' => 'Hsp' } );
904 0 $self->start_element( { 'Name' => 'Hsp' } );
905  
906 0 $self->debug( "Got paracel genewise HSP score=$1\n");
907  
908 # Some data clean-up so e-value will appear numeric to perl
909 0 my ( $bits, $score, $evalue ) = ( $1, $2, $3 );
910 0 $evalue =~ s/^e/1e/i;
911 0 $self->element(
912 {
913 'Name' => 'Hsp_score',
914 'Data' => $score
915 }
916 );
917 0 $self->element(
918 {
919 'Name' => 'Hsp_bit-score',
920 'Data' => $bits
921 }
922 );
923 0 $self->element(
924 {
925 'Name' => 'Hsp_evalue',
926 'Data' => $evalue
927 }
928 );
929 }
930 ▶ elsif (
Condition83%5/6
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*([^,\s]+), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*P(?:\(\S+\))?\s*=\s*([^,\s]+) # P-value /ox
!ll&&!rl&&r
12745520
$self->in_element("hit") or $self->in_element("hsp")
l!l&&r!l&&!r
3284224127
MC/DC0%0/3
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*([^,\s]+), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*P(?:\(\S+\))?\s*=\s*([^,\s]+) # P-value /ox
$self->in_element("hit") $self->in_element("hsp") /Score\s*=\s*([^,\s]+), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*P(?:\(\S+\))?\s*=\s*([^,\s]+) # P-value /ox
Truth table60%3/5
A or B and C
A= $self->in_element("hit")B= $self->in_element("hsp")C= /Score\s*=\s*([^,\s]+), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*P(?:\(\S+\))?\s*=\s*([^,\s]+) # P-value /ox
ABCresult
00X0
1X00
0100
1X11
0111
931 ( $self->in_element('hit') || $self->in_element('hsp') )
932 && # paracel hframe BTK
933 m/Score\s*=\s*([^,\s]+), # Raw score
934 \s*Expect\s*=\s*([^,\s]+), # E-value
935 \s*P(?:\(\S+\))?\s*=\s*([^,\s]+) # P-value
936 /ox
937 )
938 {
939 0 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 0 0 0
940 && $self->end_element( { 'Name' => 'Hsp' } );
941 0 $self->start_element( { 'Name' => 'Hsp' } );
942  
943 0 $self->debug( "Got paracel hframe HSP score=$1\n");
944  
945 # Some data clean-up so e-value will appear numeric to perl
946 0 my ( $score, $evalue, $pvalue ) = ( $1, $2, $3 );
947 0 ▶ $evalue = "1$evalue" if $evalue =~ /^e/;
Branch: 1 branch
BranchTrueFalseTotal
if $evalue =~ /^e/ 0 0 0
948 0 ▶ $pvalue = "1$pvalue" if $pvalue =~ /^e/;
Branch: 1 branch
BranchTrueFalseTotal
if $pvalue =~ /^e/ 0 0 0
949  
950 0 $self->element(
951 {
952 'Name' => 'Hsp_score',
953 'Data' => $score
954 }
955 );
956 0 $self->element(
957 {
958 'Name' => 'Hsp_evalue',
959 'Data' => $evalue
960 }
961 );
962 0 $self->element(
963 {
964 'Name' => 'Hsp_pvalue',
965 'Data' => $pvalue
966 }
967 );
968 }
969 ▶ elsif (
Condition100%6/6
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*(\S+)\s* # Bit score \(([\d\.]+)\s*bits\), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*(?:Sum)?\s* # SUM P(?:\(\d+\))?\s*=\s*([^,\s]+) # P-value (?:\s*,\s+Group\s*\=\s*(\d+))? # HSP Group /ox
!ll&&!rl&&r
1274167385
$self->in_element("hit") or $self->in_element("hsp")
l!l&&r!l&&!r
3284224127
MC/DC100%3/3
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*(\S+)\s* # Bit score \(([\d\.]+)\s*bits\), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*(?:Sum)?\s* # SUM P(?:\(\d+\))?\s*=\s*([^,\s]+) # P-value (?:\s*,\s+Group\s*\=\s*(\d+))? # HSP Group /ox
$self->in_element("hit") $self->in_element("hsp") /Score\s*=\s*(\S+)\s* # Bit score \(([\d\.]+)\s*bits\), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*(?:Sum)?\s* # SUM P(?:\(\d+\))?\s*=\s*([^,\s]+) # P-value (?:\s*,\s+Group\s*\=\s*(\d+))? # HSP Group /ox
Truth table100%5/5
A or B and C
A= $self->in_element("hit")B= $self->in_element("hsp")C= /Score\s*=\s*(\S+)\s* # Bit score \(([\d\.]+)\s*bits\), # Raw score \s*Expect\s*=\s*([^,\s]+), # E-value \s*(?:Sum)?\s* # SUM P(?:\(\d+\))?\s*=\s*([^,\s]+) # P-value (?:\s*,\s+Group\s*\=\s*(\d+))? # HSP Group /ox
ABCresult
00X0
1X00
0100
1X11
0111
970 ( $self->in_element('hit') || $self->in_element('hsp') )
971 && # wublast
972 m/Score\s*=\s*(\S+)\s* # Bit score
973 \(([\d\.]+)\s*bits\), # Raw score
974 \s*Expect\s*=\s*([^,\s]+), # E-value
975 \s*(?:Sum)?\s* # SUM
976 P(?:\(\d+\))?\s*=\s*([^,\s]+) # P-value
977 (?:\s*,\s+Group\s*\=\s*(\d+))? # HSP Group
978 /ox
979 )
980 { # wu-blast HSP parse
981 385 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 308 77 385
982 && $self->end_element( { 'Name' => 'Hsp' } );
983 385 $self->start_element( { 'Name' => 'Hsp' } );
984  
985 # Some data clean-up so e-value will appear numeric to perl
986 385 my ( $score, $bits, $evalue, $pvalue, $group ) =
987 ( $1, $2, $3, $4, $5 );
988 385 $evalue =~ s/^e/1e/i;
989 385 $pvalue =~ s/^e/1e/i;
990  
991 385 $self->element(
992 {
993 'Name' => 'Hsp_score',
994 'Data' => $score
995 }
996 );
997 385 $self->element(
998 {
999 'Name' => 'Hsp_bit-score',
1000 'Data' => $bits
1001 }
1002 );
1003 385 $self->element(
1004 {
1005 'Name' => 'Hsp_evalue',
1006 'Data' => $evalue
1007 }
1008 );
1009 385 $self->element(
1010 {
1011 'Name' => 'Hsp_pvalue',
1012 'Data' => $pvalue
1013 }
1014 );
1015  
1016 385 ▶ if ( defined $group ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group) 24 361 385
1017 24 $self->element(
1018 {
1019 'Name' => 'Hsp_group',
1020 'Data' => $group
1021 }
1022 );
1023 }
1024  
1025 }
1026 ▶ elsif (
Condition83%5/6
$self->in_element("hit") || $self->in_element("hsp") and /^\sFeatures\s\w+\sthis\spart/mosx
!ll&&!rl&&r
12741670
$self->in_element("hit") or $self->in_element("hsp")
l!l&&r!l&&!r
2513916127
MC/DC0%0/3
$self->in_element("hit") || $self->in_element("hsp") and /^\sFeatures\s\w+\sthis\spart/mosx
$self->in_element("hit") $self->in_element("hsp") /^\sFeatures\s\w+\sthis\spart/mosx
Truth table60%3/5
A or B and C
A= $self->in_element("hit")B= $self->in_element("hsp")C= /^\sFeatures\s\w+\sthis\spart/mosx
ABCresult
00X0
1X00
0100
1X11
0111
1027 ( $self->in_element('hit') || $self->in_element('hsp') )
1028 && # ncbi blast, works with 2.2.17
1029 m/^\sFeatures\s\w+\sthis\spart/xmso
1030 # If the line begins with "Features in/flanking this part of subject sequence:"
1031 )
1032 {
1033 0 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 0 0 0
1034 && $self->end_element( { 'Name' => 'Hsp' } );
1035 0 my $featline;
1036 0 $_ = $self->_readline;
1037 0 ▶ while($_ !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ =~ /^\s*$/) 0 0 0
1038 0 chomp;
1039 0 $featline .= $_;
1040 0 $_ = $self->_readline;
1041 }
1042 0 $self->_pushback($_);
1043 0 $featline =~ s{(?:^\s+|\s+^)}{}g;
1044 0 $featline =~ s{\n}{;}g;
1045 0 $self->start_element( { 'Name' => 'Hsp' } );
1046 0 $self->element(
1047 {
1048 'Name' => 'Hsp_features',
1049 'Data' => $featline
1050 }
1051 );
1052 0 $self->{'_seen_hsp_features'} = 1;
1053 }
1054 ▶ elsif (
Condition100%6/6
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Missing for BLAT pseudo-BLAST fmt \s*Expect(?:\((\d+\+?)\))?\s*=\s*([^,\s]+) # E-value /ox
!ll&&!rl&&r
1273871296
$self->in_element("hit") or $self->in_element("hsp")
l!l&&r!l&&!r
2513916127
MC/DC100%3/3
$self->in_element("hit") || $self->in_element("hsp") and /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Missing for BLAT pseudo-BLAST fmt \s*Expect(?:\((\d+\+?)\))?\s*=\s*([^,\s]+) # E-value /ox
$self->in_element("hit") $self->in_element("hsp") /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Missing for BLAT pseudo-BLAST fmt \s*Expect(?:\((\d+\+?)\))?\s*=\s*([^,\s]+) # E-value /ox
Truth table80%4/5
A or B and C
A= $self->in_element("hit")B= $self->in_element("hsp")C= /Score\s*=\s*(\S+)\s*bits\s* # Bit score (?:\((\d+)\))?, # Missing for BLAT pseudo-BLAST fmt \s*Expect(?:\((\d+\+?)\))?\s*=\s*([^,\s]+) # E-value /ox
ABCresult
00X0
1X00
0100
1X11
0111
1055 ( $self->in_element('hit') || $self->in_element('hsp') )
1056 && # ncbi blast, works with 2.2.17
1057 m/Score\s*=\s*(\S+)\s*bits\s* # Bit score
1058 (?:\((\d+)\))?, # Missing for BLAT pseudo-BLAST fmt
1059 \s*Expect(?:\((\d+\+?)\))?\s*=\s*([^,\s]+) # E-value
1060 /ox
1061 )
1062 { # parse NCBI blast HSP
1063 296 ▶ if( !$self->{'_seen_hsp_features'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_seen_hsp_features"}) 296 0 296
1064 296 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 45 251 296
1065 && $self->end_element( { 'Name' => 'Hsp' } );
1066 296 $self->start_element( { 'Name' => 'Hsp' } );
1067 }
1068  
1069 # Some data clean-up so e-value will appear numeric to perl
1070 296 my ( $bits, $score, $n, $evalue ) = ( $1, $2, $3, $4 );
1071 296 $evalue =~ s/^e/1e/i;
1072 296 $self->element(
1073 {
1074 'Name' => 'Hsp_score',
1075 'Data' => $score
1076 }
1077 );
1078 296 $self->element(
1079 {
1080 'Name' => 'Hsp_bit-score',
1081 'Data' => $bits
1082 }
1083 );
1084 296 $self->element(
1085 {
1086 'Name' => 'Hsp_evalue',
1087 'Data' => $evalue
1088 }
1089 );
1090 296 ▶ $self->element(
Branch: 1 branch
BranchTrueFalseTotal
if defined $n 10 286 296
1091 {
1092 'Name' => 'Hsp_n',
1093 'Data' => $n
1094 }
1095 ) if defined $n;
1096 296 ▶ $score = '' unless defined $score; # deal with BLAT which
Branch: 1 branch
BranchTrueFalseTotal
unless defined $score 0 296 296
1097 # has no score only bits
1098 296 $self->debug("Got NCBI HSP score=$score, evalue $evalue\n");
1099 }
1100 ▶ elsif (
Condition100%3/3
$self->in_element("hsp") and m[Identities\s*=\s*(\d+)\s*/\s*(\d+)\s*[\d\%\(\)]+\s* (?:,\s*Positives\s*=\s*(\d+)/(\d+)\s*[\d\%\(\)]+\s*)? # pos only valid for Protein alignments (?:\,\s*Gaps\s*=\s*(\d+)/(\d+))? # Gaps ]iox
!ll&&!rl&&r
1273190681
MC/DC100%2/2
$self->in_element("hsp") and m[Identities\s*=\s*(\d+)\s*/\s*(\d+)\s*[\d\%\(\)]+\s* (?:,\s*Positives\s*=\s*(\d+)/(\d+)\s*[\d\%\(\)]+\s*)? # pos only valid for Protein alignments (?:\,\s*Gaps\s*=\s*(\d+)/(\d+))? # Gaps ]iox
$self->in_element("hsp") m[Identities\s*=\s*(\d+)\s*/\s*(\d+)\s*[\d\%\(\)]+\s* (?:,\s*Positives\s*=\s*(\d+)/(\d+)\s*[\d\%\(\)]+\s*)? # pos only valid for Protein alignments (?:\,\s*Gaps\s*=\s*(\d+)/(\d+))? # Gaps ]iox
Truth table100%3/3
A and B
A= $self->in_element("hsp")B= m[Identities\s*=\s*(\d+)\s*/\s*(\d+)\s*[\d\%\(\)]+\s* (?:,\s*Positives\s*=\s*(\d+)/(\d+)\s*[\d\%\(\)]+\s*)? # pos only valid for Protein alignments (?:\,\s*Gaps\s*=\s*(\d+)/(\d+))? # Gaps ]iox
ABresult
0X0
100
111
1101 $self->in_element('hsp')
1102 && m/Identities\s*=\s*(\d+)\s*\/\s*(\d+)\s*[\d\%\(\)]+\s*
1103 (?:,\s*Positives\s*=\s*(\d+)\/(\d+)\s*[\d\%\(\)]+\s*)? # pos only valid for Protein alignments
1104 (?:\,\s*Gaps\s*=\s*(\d+)\/(\d+))? # Gaps
1105 /oxi
1106 )
1107 {
1108 681 $self->element(
1109 {
1110 'Name' => 'Hsp_identity',
1111 'Data' => $1
1112 }
1113 );
1114 681 $self->element(
1115 {
1116 'Name' => 'Hsp_align-len',
1117 'Data' => $2
1118 }
1119 );
1120 681 ▶ if ( defined $3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $3) { } 622 59 681
1121 622 $self->element(
1122 {
1123 'Name' => 'Hsp_positive',
1124 'Data' => $3
1125 }
1126 );
1127 }
1128 else {
1129 59 $self->element(
1130 {
1131 'Name' => 'Hsp_positive',
1132 'Data' => $1
1133 }
1134 );
1135 }
1136 681 ▶ if ( defined $6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $6) 123 558 681
1137 123 $self->element(
1138 {
1139 'Name' => 'Hsp_gaps',
1140 'Data' => $5
1141 }
1142 );
1143 }
1144  
1145 681 $self->{'_Query'} = { 'begin' => 0, 'end' => 0 };
1146 681 $self->{'_Sbjct'} = { 'begin' => 0, 'end' => 0 };
1147  
1148 681 ▶ if (/(Frame\s*=\s*.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/(Frame\s*=\s*.+)$/) 28 653 681
1149  
1150 # handle wu-blast Frame listing on same line
1151 28 $self->_pushback($1);
1152 }
1153 }
1154 ▶ elsif ( $self->in_element('hsp')
Condition100%3/3
$self->in_element("hsp") and m[Strand\s*=\s*(Plus|Minus)\s*/\s*(Plus|Minus)]i
!ll&&!rl&&r
127313159
MC/DC100%2/2
$self->in_element("hsp") and m[Strand\s*=\s*(Plus|Minus)\s*/\s*(Plus|Minus)]i
$self->in_element("hsp") m[Strand\s*=\s*(Plus|Minus)\s*/\s*(Plus|Minus)]i
Truth table100%3/3
A and B
A= $self->in_element("hsp")B= m[Strand\s*=\s*(Plus|Minus)\s*/\s*(Plus|Minus)]i
ABresult
0X0
100
111
1155 && /Strand\s*=\s*(Plus|Minus)\s*\/\s*(Plus|Minus)/i )
1156 {
1157  
1158 # consume this event ( we infer strand from start/end)
1159 59 ▶ if (!defined($reporttype)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $reporttype) 0 59 59
1160 0 $self->{'_reporttype'} = $reporttype = 'BLASTN';
1161 0 $bl2seq_fix = 1; # special case to resubmit the algorithm
1162 # reporttype
1163 }
1164 59 next;
1165 }
1166 ▶ elsif ( $self->in_element('hsp')
Condition100%3/3
$self->in_element("hsp") and /Links\s*=\s*(\S+)/ox
!ll&&!rl&&r
1272794337
MC/DC100%2/2
$self->in_element("hsp") and /Links\s*=\s*(\S+)/ox
$self->in_element("hsp") /Links\s*=\s*(\S+)/ox
Truth table100%3/3
A and B
A= $self->in_element("hsp")B= /Links\s*=\s*(\S+)/ox
ABresult
0X0
100
111
1167 && /Links\s*=\s*(\S+)/ox )
1168 {
1169 337 $self->element(
1170 {
1171 'Name' => 'Hsp_links',
1172 'Data' => $1
1173 }
1174 );
1175 }
1176 ▶ elsif ( $self->in_element('hsp')
Condition100%3/3
$self->in_element("hsp") and m[Frame\s*=\s*([\+\-][1-3])\s*(/\s*([\+\-][1-3]))?]
!ll&&!rl&&r
1272646148
MC/DC100%2/2
$self->in_element("hsp") and m[Frame\s*=\s*([\+\-][1-3])\s*(/\s*([\+\-][1-3]))?]
$self->in_element("hsp") m[Frame\s*=\s*([\+\-][1-3])\s*(/\s*([\+\-][1-3]))?]
Truth table100%3/3
A and B
A= $self->in_element("hsp")B= m[Frame\s*=\s*([\+\-][1-3])\s*(/\s*([\+\-][1-3]))?]
ABresult
0X0
100
111
1177 && /Frame\s*=\s*([\+\-][1-3])\s*(\/\s*([\+\-][1-3]))?/ )
1178 {
1179 148 ▶ my $frame1 = $1 || 0;
Condition50%1/2
$1 || 0
l!l
1480
MC/DC0%0/1
$1 || 0
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
1180 148 ▶ my $frame2 = $2 || 0;
Condition100%2/2
$2 || 0
l!l
11929
MC/DC100%1/1
$2 || 0
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
1181 # this is for bl2seq only
1182 148 ▶ if ( not defined $reporttype ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $reporttype) 2 146 148
1183 2 $bl2seq_fix = 1;
1184 2 ▶ if ( $frame1 && $frame2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frame1 and $frame2) { } 0 2 2
Condition33%1/3
$frame1 and $frame2
!ll&&!rl&&r
020
MC/DC0%0/2
$frame1 and $frame2
$frame1 $frame2
Truth table33%1/3
A and B
A= $frame1B= $frame2
ABresult
0X0
100
111
1185 0 $reporttype = 'TBLASTX'
1186 }
1187 else {
1188 # We can distinguish between BLASTX and TBLASTN from the report
1189 # (and assign $frame1 properly) by using the start/end from query.
1190 # If the report is BLASTX, the coordinates distance from query
1191 # will be 3 times the length of the alignment shown (coordinates in nt,
1192 # alignment in aa); if not then subject is the nucleotide sequence (TBLASTN).
1193 # Will have to fast-forward to query alignment line and then go back.
1194 2 my $fh = $self->_fh;
1195 2 my $file_pos = tell $fh;
1196  
1197 2 my $a_position = '';
1198 2 my $ali_length = '';
1199 2 my $b_position = '';
1200 2 ▶ while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 4 0 4
1201 4 ▶ if ($line =~ m/^(?:Query|Sbjct):?\s+(\-?\d+)?\s*(\S+)\s+(\-?\d+)?/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(?:Query|Sbjct):?\s+(\-?\d+)?\s*(\S+)\s+(\-?\d+)?/) 2 2 4
1202 2 $a_position = $1;
1203 2 my $alignment = $2;
1204 2 $b_position = $3;
1205  
1206 12 ▶ use Bio::LocatableSeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
1207 2 my $gap_symbols = $Bio::LocatableSeq::GAP_SYMBOLS;
1208 2 $alignment =~ s/[$gap_symbols]//g;
1209 2 $ali_length = length($alignment);
1210 2 last;
1211 }
1212 }
1213 2 ▶ my $coord_length = ($a_position < $b_position) ? ($b_position - $a_position + 1)
Branch: 1 branch
BranchTrueFalseTotal
$a_position < $b_position ? : 1 1 2
1214 : ($a_position - $b_position + 1);
1215 2 ▶ ($coord_length == ($ali_length * 3)) ? ($reporttype = 'BLASTX') : ($reporttype = 'TBLASTN');
Branch: 1 branch
BranchTrueFalseTotal
$coord_length == $ali_length * 3 ? : 1 1 2
1216  
1217 # Rewind filehandle to its original position to continue parsing
1218 2 seek $fh, $file_pos, 0;
1219 }
1220 2 $self->{'_reporttype'} = $reporttype;
1221 }
1222  
1223 148 my ( $queryframe, $hitframe );
1224 148 ▶ if ( $reporttype eq 'TBLASTX' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($reporttype eq 'TBLASTX') { } 119 29 148
elsif ($reporttype eq 'TBLASTN' or $reporttype eq 'PSITBLASTN') { } 10 19 29
elsif ($reporttype eq 'BLASTX' or $reporttype eq 'RPS-BLAST(BLASTP)') { } 19 0 19
1225 119 ( $queryframe, $hitframe ) = ( $frame1, $frame2 );
1226 119 $hitframe =~ s/\/\s*//g;
1227 }
1228 ▶ elsif ( $reporttype eq 'TBLASTN' || $reporttype eq 'PSITBLASTN') {
Condition66%2/3
$reporttype eq "TBLASTN" or $reporttype eq "PSITBLASTN"
l!l&&r!l&&!r
10019
MC/DC50%1/2
$reporttype eq "TBLASTN" or $reporttype eq "PSITBLASTN"
$reporttype eq "TBLASTN" $reporttype eq "PSITBLASTN"
Truth table66%2/3
A or B
A= $reporttype eq "TBLASTN"B= $reporttype eq "PSITBLASTN"
ABresult
1X1
011
000
1229 10 ( $hitframe, $queryframe ) = ( $frame1, 0 );
1230 }
1231 ▶ elsif ( $reporttype eq 'BLASTX' || $reporttype eq 'RPS-BLAST(BLASTP)') {
Condition33%1/3
$reporttype eq "BLASTX" or $reporttype eq "RPS-BLAST(BLASTP)"
l!l&&r!l&&!r
1900
MC/DC0%0/2
$reporttype eq "BLASTX" or $reporttype eq "RPS-BLAST(BLASTP)"
$reporttype eq "BLASTX" $reporttype eq "RPS-BLAST(BLASTP)"
Truth table33%1/3
A or B
A= $reporttype eq "BLASTX"B= $reporttype eq "RPS-BLAST(BLASTP)"
ABresult
1X1
011
000
1232 19 ( $queryframe, $hitframe ) = ( $frame1, 0 );
1233 # though NCBI doesn't report it, this is a special BLASTX-like
1234 # RPS-BLAST; should be handled differently
1235 19 ▶ if ($reporttype eq 'RPS-BLAST(BLASTP)') {
Branch: 1 branch
BranchTrueFalseTotal
if ($reporttype eq "RPS-BLAST(BLASTP)") 0 19 19
1236 0 $self->element(
1237 {
1238 'Name' => 'BlastOutput_program',
1239 'Data' => 'RPS-BLAST(BLASTX)'
1240 }
1241 );
1242 }
1243 }
1244 $self->element(
1245 {
1246 148 'Name' => 'Hsp_query-frame',
1247 'Data' => $queryframe
1248 }
1249 );
1250  
1251 148 $self->element(
1252 {
1253 'Name' => 'Hsp_hit-frame',
1254 'Data' => $hitframe
1255 }
1256 );
1257 }
1258 ▶ elsif (/^Parameters:/
Condition77%14/18
/^Parameters:/ or /^\s+Database:\s+?/ or /^\s+Subset/ or /^\s*Lambda/ or /^\s*Histogram/ or $self->in_element("hsp") and /WARNING|NOTE/
l!l&&r!l&&!r
3502738
/^Parameters:/ or /^\s+Database:\s+?/ or /^\s+Subset/ or /^\s*Lambda/ or /^\s*Histogram/
l!l&&r!l&&!r
3502738
/^Parameters:/ or /^\s+Database:\s+?/ or /^\s+Subset/ or /^\s*Lambda/
l!l&&r!l&&!r
3232738
/^Parameters:/ or /^\s+Database:\s+?/ or /^\s+Subset/
l!l&&r!l&&!r
3202741
/^Parameters:/ or /^\s+Database:\s+?/
l!l&&r!l&&!r
16162741
$self->in_element("hsp") and /WARNING|NOTE/
!ll&&!rl&&r
12626120
MC/DC42%3/7
/^Parameters:/ or /^\s+Database:\s+?/ or /^\s+Subset/ or /^\s*Lambda/ or /^\s*Histogram/ or $self->in_element("hsp") and /WARNING|NOTE/
/^Parameters:/ /^\s+Database:\s+?/ /^\s+Subset/ /^\s*Lambda/ /^\s*Histogram/ $self->in_element("hsp") /WARNING|NOTE/
Truth table62%5/8
A or B or C or D or E or F and G
A= /^Parameters:/B= /^\s+Database:\s+?/C= /^\s+Subset/D= /^\s*Lambda/E= /^\s*Histogram/F= $self->in_element("hsp")G= /WARNING|NOTE/
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
00000111
000000X0
00000100
1259 || /^\s+Database:\s+?/
1260 || /^\s+Subset/
1261 || /^\s*Lambda/
1262 || /^\s*Histogram/
1263 || ( $self->in_element('hsp') && /WARNING|NOTE/ ) )
1264 {
1265  
1266 # Note: Lambda check was necessary to parse
1267 # t/data/ecoli_domains.rpsblast AND to parse bl2seq
1268 35 $self->debug("blast.pm: found parameters section \n");
1269  
1270 35 ▶ $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hsp") and $self->end_element({"Name", "Hsp"}) 34 1 35
1271 && $self->end_element( { 'Name' => 'Hsp' } );
1272 35 ▶ $self->in_element('hit')
Branch: 1 branch
BranchTrueFalseTotal
$self->in_element("hit") and $self->end_element({"Name", "Hit"}) 34 1 35
1273 && $self->end_element( { 'Name' => 'Hit' } );
1274  
1275 # This is for the case when we specify -b 0 (or B=0 for WU-BLAST)
1276 # and still want to construct minimal Hit objects
1277 35 ▶ $self->_cleanup_hits(\@hit_signifs) if scalar(@hit_signifs);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @hit_signifs 3 32 35
1278 35 ▶ $self->within_element('iteration')
Branch: 1 branch
BranchTrueFalseTotal
$self->within_element("iteration") and $self->end_element({"Name", "Iteration"}) 35 0 35
1279 && $self->end_element( { 'Name' => 'Iteration' } );
1280  
1281 35 ▶ next if /^\s+Subset/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s+Subset/ 0 35 35
1282 35 ▶ my $blast = (/^(\s+Database\:)|(\s*Lambda)/) ? 'ncbi' : 'wublast';
Branch: 1 branch
BranchTrueFalseTotal
/^(\s+Database\:)|(\s*Lambda)/ ? : 19 16 35
1283 35 ▶ if (/^\s*Histogram/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*Histogram/) 0 35 35
1284 0 $blast = 'btk';
1285 }
1286  
1287 35 my $last = '';
1288  
1289 # default is that gaps are allowed
1290 35 $self->element(
1291 {
1292 'Name' => 'Parameters_allowgaps',
1293 'Data' => 'yes'
1294 }
1295 );
1296 35 ▶ while ( defined( $_ = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 1243 33 1276
1297 # If Lambda/Kappa/Entropy numbers appear first at this point,
1298 # pushback and add the header line to process it correctly
1299 1243 ▶ if (/^\s+[\d+\.]+\s+[\d+\.]+\s+[\d+\.]/ and $last eq '') {
Branch: 3 branches
BranchTrueFalseTotal
if (/^\s+[\d+\.]+\s+[\d+\.]+\s+[\d+\.]/ and $last eq '') { } 3 1240 1243
elsif (/^((?:\S+)?BLAST[NPX]?)\s+(.+)$/i or /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i) { } 2 1238 1240
elsif (/^Query=/) { } 0 1238 1238
Condition100%3/3
/^\s+[\d+\.]+\s+[\d+\.]+\s+[\d+\.]/ and $last eq ""
!ll&&!rl&&r
1178623
MC/DC100%2/2
/^\s+[\d+\.]+\s+[\d+\.]+\s+[\d+\.]/ and $last eq ""
/^\s+[\d+\.]+\s+[\d+\.]+\s+[\d+\.]/ $last eq ""
Truth table100%3/3
A and B
A= /^\s+[\d+\.]+\s+[\d+\.]+\s+[\d+\.]/B= $last eq ""
ABresult
0X0
100
111
1300 3 $self->_pushback($_);
1301 3 $self->_pushback("Lambda K H\n");
1302 3 next;
1303 }
1304 ▶ elsif (
Condition66%2/3
/^((?:\S+)?BLAST[NPX]?)\s+(.+)$/i or /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
l!l&&r!l&&!r
201238
MC/DC50%1/2
/^((?:\S+)?BLAST[NPX]?)\s+(.+)$/i or /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
/^((?:\S+)?BLAST[NPX]?)\s+(.+)$/i /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
Truth table66%2/3
A or B
A= /^((?:\S+)?BLAST[NPX]?)\s+(.+)$/iB= /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i
ABresult
1X1
011
000
1305 /^((?:\S+)?BLAST[NPX]?)\s+(.+)$/i # NCBI BLAST, PSIBLAST
1306 # RPSBLAST, MEGABLAST
1307 || /^(P?GENEWISE|HFRAME|SWN|TSWN)\s+(.+)/i #Paracel BTK
1308 )
1309 {
1310 2 $self->_pushback($_);
1311  
1312 # let's handle this in the loop
1313 2 last;
1314 }
1315 elsif (/^Query=/) {
1316 0 $self->_pushback($_);
1317 0 ▶ $self->_pushback($reportline) if $reportline;
Branch: 1 branch
BranchTrueFalseTotal
if $reportline 0 0 0
1318 0 last PARSER;
1319 }
1320  
1321 # here is where difference between wublast and ncbiblast
1322 # is better handled by different logic
1323 1238 ▶ if ( /Number of Sequences:\s+([\d\,]+)/i
Branch: 5 branches
BranchTrueFalseTotal
if (/Number of Sequences:\s+([\d\,]+)/i or /of sequences in database:\s+(\-?[\d,]+)/i) { } 49 1189 1238
elsif (/letters in database:\s+(\-?[\d,]+)/i) { } 30 1159 1189
elsif ($blast eq 'btk') { } 0 1159 1159
elsif ($blast eq 'wublast') { } 615 544 1159
elsif ($blast eq 'ncbi') { } 544 0 544
Condition100%3/3
/Number of Sequences:\s+([\d\,]+)/i or /of sequences in database:\s+(\-?[\d,]+)/i
l!l&&r!l&&!r
19301189
MC/DC100%2/2
/Number of Sequences:\s+([\d\,]+)/i or /of sequences in database:\s+(\-?[\d,]+)/i
/Number of Sequences:\s+([\d\,]+)/i /of sequences in database:\s+(\-?[\d,]+)/i
Truth table100%3/3
A or B
A= /Number of Sequences:\s+([\d\,]+)/iB= /of sequences in database:\s+(\-?[\d,]+)/i
ABresult
1X1
011
000
1324 || /of sequences in database:\s+(\-?[\d,]+)/i )
1325 {
1326 49 my $c = $1;
1327 49 $c =~ s/\,//g;
1328 49 $self->element(
1329 {
1330 'Name' => 'Statistics_db-len',
1331 'Data' => $c
1332 }
1333 );
1334 }
1335 elsif (/letters in database:\s+(\-?[\d,]+)/i) {
1336 30 my $s = $1;
1337 30 $s =~ s/,//g;
1338 30 $self->element(
1339 {
1340 'Name' => 'Statistics_db-let',
1341 'Data' => $s
1342 }
1343 );
1344 }
1345 elsif ( $blast eq 'btk' ) {
1346 0 next;
1347 }
1348 elsif ( $blast eq 'wublast' ) {
1349  
1350 # warn($_);
1351 615 ▶ if (/E=(\S+)/) {
Branch: 14 branches
BranchTrueFalseTotal
if (/E=(\S+)/) { } 18 597 615
elsif (/nogaps/) { } 1 596 597
elsif (/ctxfactor=(\S+)/) { } 16 580 596
elsif (/(postsw|links|span[12]?|warnings|notes|gi|noseqs|qres|qype)/) { } 22 558 580
elsif (/(\S+)=(\S+)/) { } 89 469 558
elsif ($last =~ /(Frame|Strand)\s+MatID\s+Matrix name/i) { } 16 453 469
elsif ($last =~ /(Frame|Strand)\s+MatID\s+Length/i) { } 16 437 453
elsif (/(\S+\s+\S+)\s+DFA:\s+(\S+)\s+\((.+)\)/) { } 14 423 437
elsif (/^\s+Time to generate neighborhood:\s+ (\S+\s+\S+\s+\S+)/x) { } 0 423 423
elsif (/processors\s+used:\s+(\d+)/) { } 14 409 423
elsif (/^\s+(\S+)\s+cpu\s+time:\s+ # cputype (\S+\s+\S+\s+\S+) # cputime \s+Elapsed:\s+(\S+)/x) { } 28 381 409
elsif (/^\s+Start:/) { } 14 367 381
elsif (/^\s+Database:\s+(.+)$/) { } 13 354 367
elsif (/^\s+Posted:\s+(.+)/) { } 13 341 354
1352 18 $self->element(
1353 {
1354 'Name' => 'Parameters_expect',
1355 'Data' => $1
1356 }
1357 );
1358 }
1359 elsif (/nogaps/) {
1360 1 $self->element(
1361 {
1362 'Name' => 'Parameters_allowgaps',
1363 'Data' => 'no'
1364 }
1365 );
1366 }
1367 elsif (/ctxfactor=(\S+)/) {
1368 16 $self->element(
1369 {
1370 'Name' => 'Statistics_ctxfactor',
1371 'Data' => $1
1372 }
1373 );
1374 }
1375 elsif (
1376 /(postsw|links|span[12]?|warnings|notes|gi|noseqs|qres|qype)/
1377 )
1378 {
1379 22 $self->element(
1380 {
1381 'Name' => "Parameters_$1",
1382 'Data' => 'yes'
1383 }
1384 );
1385 }
1386 elsif (/(\S+)=(\S+)/) {
1387 89 $self->element(
1388 {
1389 'Name' => "Parameters_$1",
1390 'Data' => $2
1391 }
1392 );
1393 }
1394 elsif ( $last =~ /(Frame|Strand)\s+MatID\s+Matrix name/i ) {
1395 16 my $firstgapinfo = 1;
1396 16 my $frame = undef;
1397 16 ▶ while ( defined($_) && !/^\s+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_ and not /^\s+$/) 70 16 86
Condition66%2/3
defined $_ and not /^\s+$/
!ll&&!rl&&r
01670
MC/DC50%1/2
defined $_ and not /^\s+$/
defined $_ not /^\s+$/
Truth table66%2/3
A and not(B)
A= defined $_B= not /^\s+$/
ABresult
0X0
100
111
1398 70 s/^\s+//;
1399 70 s/\s+$//;
1400 70 ▶ if ( $firstgapinfo
Branch: 1 branch
BranchTrueFalseTotal
if ($firstgapinfo and s/Q=(\d+),R=(\d+)\s+//x) { } 15 55 70
Condition100%3/3
$firstgapinfo and s/Q=(\d+),R=(\d+)\s+//x
!ll&&!rl&&r
342115
MC/DC100%2/2
$firstgapinfo and s/Q=(\d+),R=(\d+)\s+//x
$firstgapinfo s/Q=(\d+),R=(\d+)\s+//x
Truth table100%3/3
A and B
A= $firstgapinfoB= s/Q=(\d+),R=(\d+)\s+//x
ABresult
0X0
100
111
1401 && s/Q=(\d+),R=(\d+)\s+//x )
1402 {
1403 15 $firstgapinfo = 0;
1404  
1405 15 $self->element(
1406 {
1407 'Name' => 'Parameters_gap-open',
1408 'Data' => $1
1409 }
1410 );
1411 15 $self->element(
1412 {
1413 'Name' => 'Parameters_gap-extend',
1414 'Data' => $2
1415 }
1416 );
1417 15 my @fields = split;
1418  
1419 15 for my $type (
1420 qw(lambda_gapped
1421 kappa_gapped
1422 entropy_gapped)
1423 )
1424 {
1425 45 ▶ next if $type eq 'n/a';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "n/a" 0 45 45
1426 45 ▶ if ( !@fields ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@fields) 0 45 45
1427 0 warn "fields is empty for $type\n";
1428 0 next;
1429 }
1430 $self->element(
1431 {
1432 45 'Name' =>
1433 "Statistics_frame$frame\_$type",
1434 'Data' => shift @fields
1435 }
1436 );
1437 }
1438 }
1439 else {
1440 55 my ( $frameo, $matid, $matrix, @fields ) =
1441 split;
1442 55 ▶ if ( !defined $frame ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $frame) 16 39 55
1443  
1444 # keep some sort of default feature I guess
1445 # even though this is sort of wrong
1446 16 $self->element(
1447 {
1448 'Name' => 'Parameters_matrix',
1449 'Data' => $matrix
1450 }
1451 );
1452 16 $self->element(
1453 {
1454 'Name' => 'Statistics_lambda',
1455 'Data' => $fields[0]
1456 }
1457 );
1458 16 $self->element(
1459 {
1460 'Name' => 'Statistics_kappa',
1461 'Data' => $fields[1]
1462 }
1463 );
1464 16 $self->element(
1465 {
1466 'Name' => 'Statistics_entropy',
1467 'Data' => $fields[2]
1468 }
1469 );
1470 }
1471 55 $frame = $frameo;
1472 55 my $ii = 0;
1473 55 for my $type (
1474 qw(lambda_used
1475 kappa_used
1476 entropy_used
1477 lambda_computed
1478 kappa_computed
1479 entropy_computed)
1480 )
1481 {
1482 330 my $f = $fields[$ii];
1483 330 ▶ next unless defined $f; # deal with n/a
Branch: 1 branch
BranchTrueFalseTotal
unless defined $f 34 296 330
1484 296 ▶ if ( $f eq 'same' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f eq "same") 42 254 296
1485 42 $f = $fields[ $ii - 3 ];
1486 }
1487 296 $ii++;
1488 296 $self->element(
1489 {
1490 'Name' =>
1491 "Statistics_frame$frame\_$type",
1492 'Data' => $f
1493 }
1494 );
1495  
1496 }
1497 }
1498  
1499 # get the next line
1500 70 $_ = $self->_readline;
1501 }
1502 16 $last = $_;
1503 }
1504 elsif ( $last =~ /(Frame|Strand)\s+MatID\s+Length/i ) {
1505 16 my $frame = undef;
1506 16 ▶ while ( defined($_) && !/^\s+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_ and not /^\s+/) 0 16 16
Condition33%1/3
defined $_ and not /^\s+/
!ll&&!rl&&r
0160
MC/DC0%0/2
defined $_ and not /^\s+/
defined $_ not /^\s+/
Truth table33%1/3
A and not(B)
A= defined $_B= not /^\s+/
ABresult
0X0
100
111
1507 0 s/^\s+//;
1508 0 s/\s+$//;
1509 0 my @fields = split;
1510 0 ▶ if ( @fields <= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@fields <= 3) { } 0 0 0
1511 0 for my $type (qw(X_gapped E2_gapped S2)) {
1512 0 ▶ last unless @fields;
Branch: 1 branch
BranchTrueFalseTotal
unless @fields 0 0 0
1513 0 $self->element(
1514 {
1515 'Name' =>
1516 "Statistics_frame$frame\_$type",
1517 'Data' => shift @fields
1518 }
1519 );
1520 }
1521 }
1522 else {
1523  
1524 0 for my $type (
1525 qw(length
1526 efflength
1527 E S W T X E2 S2)
1528 )
1529 {
1530 0 $self->element(
1531 {
1532 'Name' =>
1533 "Statistics_frame$frame\_$type",
1534 'Data' => shift @fields
1535 }
1536 );
1537 }
1538 }
1539 0 $_ = $self->_readline;
1540 }
1541 16 $last = $_;
1542 }
1543 elsif (/(\S+\s+\S+)\s+DFA:\s+(\S+)\s+\((.+)\)/) {
1544 14 ▶ if ( $1 eq 'states in' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 eq 'states in') { } 14 0 14
elsif ($1 eq 'size of') { } 0 0 0
1545 14 $self->element(
1546 {
1547 'Name' => 'Statistics_DFA_states',
1548 'Data' => "$2 $3"
1549 }
1550 );
1551 }
1552 elsif ( $1 eq 'size of' ) {
1553 0 $self->element(
1554 {
1555 'Name' => 'Statistics_DFA_size',
1556 'Data' => "$2 $3"
1557 }
1558 );
1559 }
1560 }
1561 elsif (
1562 m/^\s+Time to generate neighborhood:\s+
1563 (\S+\s+\S+\s+\S+)/x
1564 )
1565 {
1566 0 $self->element(
1567 {
1568 'Name' => 'Statistics_neighbortime',
1569 'Data' => $1
1570 }
1571 );
1572 }
1573 elsif (/processors\s+used:\s+(\d+)/) {
1574 14 $self->element(
1575 {
1576 'Name' => 'Statistics_noprocessors',
1577 'Data' => $1
1578 }
1579 );
1580 }
1581 elsif (
1582 m/^\s+(\S+)\s+cpu\s+time:\s+ # cputype
1583 (\S+\s+\S+\s+\S+) # cputime
1584 \s+Elapsed:\s+(\S+)/x
1585 )
1586 {
1587 28 my $cputype = lc($1);
1588 28 $self->element(
1589 {
1590 'Name' => "Statistics_$cputype\_cputime",
1591 'Data' => $2
1592 }
1593 );
1594 28 $self->element(
1595 {
1596 'Name' => "Statistics_$cputype\_actualtime",
1597 'Data' => $3
1598 }
1599 );
1600 }
1601 elsif (/^\s+Start:/) {
1602 14 my ( $junk, $start, $stime, $end, $etime ) =
1603 split( /\s+(Start|End)\:\s+/, $_ );
1604 14 chomp($stime);
1605 14 $self->element(
1606 {
1607 'Name' => 'Statistics_starttime',
1608 'Data' => $stime
1609 }
1610 );
1611 14 chomp($etime);
1612 14 $self->element(
1613 {
1614 'Name' => 'Statistics_endtime',
1615 'Data' => $etime
1616 }
1617 );
1618 }
1619 elsif (/^\s+Database:\s+(.+)$/) {
1620 13 $self->element(
1621 {
1622 'Name' => 'Parameters_full_dbpath',
1623 'Data' => $1
1624 }
1625 );
1626  
1627 }
1628 elsif (/^\s+Posted:\s+(.+)/) {
1629 13 my $d = $1;
1630 13 chomp($d);
1631 13 $self->element(
1632 {
1633 'Name' => 'Statistics_posted_date',
1634 'Data' => $d
1635 }
1636 );
1637 }
1638 }
1639 elsif ( $blast eq 'ncbi' ) {
1640  
1641 544 ▶ if (m/^Matrix:\s+(.+)\s*$/oxi) {
Branch: 21 branches
BranchTrueFalseTotal
if (/^Matrix:\s+(.+)\s*$/iox) { } 19 525 544
elsif (/^Gapped/) { } 14 511 525
elsif (/^Lambda/) { } 33 478 511
elsif (/effective\s+search\s+space\s+used:\s+(\d+)/iox) { } 17 461 478
elsif (/effective\s+search\s+space:\s+(\d+)/iox) { } 18 443 461
elsif (/Gap\s+Penalties:\s+Existence:\s+(\d+)\, \s+Extension:\s+(\d+)/ox) { } 14 429 443
elsif (/effective\s+HSP\s+length:\s+(\d+)/) { } 19 410 429
elsif (/Number\s+of\s+HSP's\s+better\s+than\s+(\S+)\s+without\s+gapping:\s+(\d+)/) { } 11 399 410
elsif (/Number\s+of\s+HSP's\s+gapped:\s+(\d+)/) { } 0 399 399
elsif (/Number\s+of\s+HSP's\s+successfully\s+gapped:\s+(\d+)/) { } 0 399 399
elsif (/Length\s+adjustment:\s+(\d+)/) { } 0 399 399
elsif (/effective\s+length\s+of\s+query:\s+([\d\,]+)/i) { } 18 381 399
elsif (/effective\s+length\s+of\s+database:\s+([\d\,]+)/i) { } 19 362 381
elsif (/^(T|A|X1|X2|X3|S1|S2):\s+(\d+(\.\d+)?)\s+(?:\(\s*(\d+\.\d+) bits\))?/) { } 119 243 362
elsif (/frameshift\s+window\, \s+decay\s+const:\s+(\d+)\,\s+([\.\d]+)/x) { } 10 233 243
elsif (/^Number\s+of\s+Hits\s+to\s+DB:\s+(\S+)/ox) { } 19 214 233
elsif (/^Number\s+of\s+extensions:\s+(\S+)/ox) { } 19 195 214
elsif (/^Number\s+of\s+successful\s+extensions:\s+ (\S+)/ox) { } 19 176 195
elsif (/^Number\s+of\s+sequences\s+better\s+than\s+ (\S+):\s+(\d+)/ox) { } 19 157 176
elsif (/^\s+Posted\s+date:\s+(.+)/) { } 16 141 157
elsif (not /^\s+$/) { } 71 70 141
1642 19 $self->element(
1643 {
1644 'Name' => 'Parameters_matrix',
1645 'Data' => $1
1646 }
1647 );
1648 }
1649 elsif (/^Gapped/) {
1650 14 $gapped_stats = 1;
1651 }
1652 elsif (/^Lambda/) {
1653 33 $_ = $self->_readline;
1654 33 s/^\s+//;
1655 33 my ( $lambda, $kappa, $entropy ) = split;
1656 33 ▶ if ($gapped_stats) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gapped_stats) { } 14 19 33
1657 14 $self->element(
1658 {
1659 'Name' => "Statistics_gapped_lambda",
1660 'Data' => $lambda
1661 }
1662 );
1663 14 $self->element(
1664 {
1665 'Name' => "Statistics_gapped_kappa",
1666 'Data' => $kappa
1667 }
1668 );
1669 14 $self->element(
1670 {
1671 'Name' => "Statistics_gapped_entropy",
1672 'Data' => $entropy
1673 }
1674 );
1675 }
1676 else {
1677 19 $self->element(
1678 {
1679 'Name' => "Statistics_lambda",
1680 'Data' => $lambda
1681 }
1682 );
1683 19 $self->element(
1684 {
1685 'Name' => "Statistics_kappa",
1686 'Data' => $kappa
1687 }
1688 );
1689 19 $self->element(
1690 {
1691 'Name' => "Statistics_entropy",
1692 'Data' => $entropy
1693 }
1694 );
1695 }
1696 }
1697 elsif (m/effective\s+search\s+space\s+used:\s+(\d+)/oxi) {
1698 17 $self->element(
1699 {
1700 'Name' => 'Statistics_eff-spaceused',
1701 'Data' => $1
1702 }
1703 );
1704 }
1705 elsif (m/effective\s+search\s+space:\s+(\d+)/oxi) {
1706 18 $self->element(
1707 {
1708 'Name' => 'Statistics_eff-space',
1709 'Data' => $1
1710 }
1711 );
1712 }
1713 elsif (
1714 m/Gap\s+Penalties:\s+Existence:\s+(\d+)\,
1715 \s+Extension:\s+(\d+)/ox
1716 )
1717 {
1718 14 $self->element(
1719 {
1720 'Name' => 'Parameters_gap-open',
1721 'Data' => $1
1722 }
1723 );
1724 14 $self->element(
1725 {
1726 'Name' => 'Parameters_gap-extend',
1727 'Data' => $2
1728 }
1729 );
1730 }
1731 elsif (/effective\s+HSP\s+length:\s+(\d+)/) {
1732 19 $self->element(
1733 {
1734 'Name' => 'Statistics_hsp-len',
1735 'Data' => $1
1736 }
1737 );
1738 }
1739 elsif (/Number\s+of\s+HSP's\s+better\s+than\s+(\S+)\s+without\s+gapping:\s+(\d+)/) {
1740 11 $self->element(
1741 {
1742 'Name' => 'Statistics_number_of_hsps_better_than_expect_value_cutoff_without_gapping',
1743 'Data' => $2
1744 }
1745 );
1746 }
1747 elsif (/Number\s+of\s+HSP's\s+gapped:\s+(\d+)/) {
1748 0 $self->element(
1749 {
1750 'Name' => 'Statistics_number_of_hsps_gapped',
1751 'Data' => $1
1752 }
1753 );
1754 }
1755 elsif (/Number\s+of\s+HSP's\s+successfully\s+gapped:\s+(\d+)/) {
1756 0 $self->element(
1757 {
1758 'Name' => 'Statistics_number_of_hsps_successfully_gapped',
1759 'Data' => $1
1760 }
1761 );
1762 }
1763 elsif (/Length\s+adjustment:\s+(\d+)/) {
1764 0 $self->element(
1765 {
1766 'Name' => 'Statistics_length_adjustment',
1767 'Data' => $1
1768 }
1769 );
1770 }
1771 elsif (/effective\s+length\s+of\s+query:\s+([\d\,]+)/i) {
1772 18 my $c = $1;
1773 18 $c =~ s/\,//g;
1774 18 $self->element(
1775 {
1776 'Name' => 'Statistics_query-len',
1777 'Data' => $c
1778 }
1779 );
1780 }
1781 elsif (/effective\s+length\s+of\s+database:\s+([\d\,]+)/i) {
1782 19 my $c = $1;
1783 19 $c =~ s/\,//g;
1784 19 $self->element(
1785 {
1786 'Name' => 'Statistics_eff-dblen',
1787 'Data' => $c
1788 }
1789 );
1790 }
1791 elsif (
1792 /^(T|A|X1|X2|X3|S1|S2):\s+(\d+(\.\d+)?)\s+(?:\(\s*(\d+\.\d+) bits\))?/
1793 )
1794 {
1795 119 my $v = $2;
1796 119 chomp($v);
1797 119 $self->element(
1798 {
1799 'Name' => "Statistics_$1",
1800 'Data' => $v
1801 }
1802 );
1803 119 ▶ if ( defined $4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $4) 83 36 119
1804 83 $self->element(
1805 {
1806 'Name' => "Statistics_$1_bits",
1807 'Data' => $4
1808 }
1809 );
1810 }
1811 }
1812 elsif (
1813 m/frameshift\s+window\,
1814 \s+decay\s+const:\s+(\d+)\,\s+([\.\d]+)/x
1815 )
1816 {
1817 10 $self->element(
1818 {
1819 'Name' => 'Statistics_framewindow',
1820 'Data' => $1
1821 }
1822 );
1823 10 $self->element(
1824 {
1825 'Name' => 'Statistics_decay',
1826 'Data' => $2
1827 }
1828 );
1829 }
1830 elsif (m/^Number\s+of\s+Hits\s+to\s+DB:\s+(\S+)/ox) {
1831 19 $self->element(
1832 {
1833 'Name' => 'Statistics_hit_to_db',
1834 'Data' => $1
1835 }
1836 );
1837 }
1838 elsif (m/^Number\s+of\s+extensions:\s+(\S+)/ox) {
1839 19 $self->element(
1840 {
1841 'Name' => 'Statistics_num_extensions',
1842 'Data' => $1
1843 }
1844 );
1845 }
1846 elsif (
1847 m/^Number\s+of\s+successful\s+extensions:\s+
1848 (\S+)/ox
1849 )
1850 {
1851 19 $self->element(
1852 {
1853 'Name' => 'Statistics_num_suc_extensions',
1854 'Data' => $1
1855 }
1856 );
1857 }
1858 elsif (
1859 m/^Number\s+of\s+sequences\s+better\s+than\s+
1860 (\S+):\s+(\d+)/ox
1861 )
1862 {
1863 19 $self->element(
1864 {
1865 'Name' => 'Parameters_expect',
1866 'Data' => $1
1867 }
1868 );
1869 19 $self->element(
1870 {
1871 'Name' => 'Statistics_seqs_better_than_cutoff',
1872 'Data' => $2
1873 }
1874 );
1875 }
1876 elsif (/^\s+Posted\s+date:\s+(.+)/) {
1877 16 my $d = $1;
1878 16 chomp($d);
1879 16 $self->element(
1880 {
1881 'Name' => 'Statistics_posted_date',
1882 'Data' => $d
1883 }
1884 );
1885 }
1886 elsif ( !/^\s+$/ ) {
1887 #$self->debug( "unmatched stat $_");
1888 }
1889 }
1890 1238 $last = $_;
1891 }
1892 } elsif ( $self->in_element('hsp') ) {
1893 2612 $self->debug("blast.pm: Processing HSP\n");
1894 # let's read 3 lines at a time;
1895 # bl2seq hackiness... Not sure I like
1896 2612 ▶ $self->{'_reporttype'} ||= $DEFAULTREPORTTYPE;
Condition66%2/3
$self->{"_reporttype"} ||= $Bio::SearchIO::blast::DEFAULTREPORTTYPE
l!l&&r!l&&!r
260660
MC/DC0%0/2
$self->{"_reporttype"} ||= $Bio::SearchIO::blast::DEFAULTREPORTTYPE
$self->{"_reporttype"} $Bio::SearchIO::blast::DEFAULTREPORTTYPE
Truth table66%2/3
A ||= B
A= $self->{"_reporttype"}B= $Bio::SearchIO::blast::DEFAULTREPORTTYPE
ABresult
1X1
011
000
1897 2612 my %data = (
1898 'Query' => '',
1899 'Mid' => '',
1900 'Hit' => ''
1901 );
1902 2612 my $len;
1903 2612 ▶ for ( my $i = 0 ; defined($_) && $i < 3 ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_ and $i < 3) 7822 2612 10434
Condition66%2/3
defined $_ and $i < 3
!ll&&!rl&&r
026127822
MC/DC50%1/2
defined $_ and $i < 3
defined $_ $i < 3
Truth table66%2/3
A and B
A= defined $_B= $i < 3
ABresult
0X0
100
111
1904 # $self->debug("$i: $_") if $v;
1905 7822 ▶ if ( ( $i == 0 && /^\s+$/) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 and /^\s+$/ or /^\s*(?:Lambda|Minus|Plus|Score)/i) 0 7822 7822
Condition50%3/6
$i == 0 and /^\s+$/ or /^\s*(?:Lambda|Minus|Plus|Score)/i
l!l&&r!l&&!r
007822
$i == 0 and /^\s+$/
!ll&&!rl&&r
521026120
MC/DC0%0/3
$i == 0 and /^\s+$/ or /^\s*(?:Lambda|Minus|Plus|Score)/i
$i == 0 /^\s+$/ /^\s*(?:Lambda|Minus|Plus|Score)/i
Truth table40%2/5
A and B or C
A= $i == 0B= /^\s+$/C= /^\s*(?:Lambda|Minus|Plus|Score)/i
ABCresult
11X1
0X11
1011
0X00
1000
1906 /^\s*(?:Lambda|Minus|Plus|Score)/i
1907 ) {
1908 0 ▶ $self->_pushback($_) if defined $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 0 0 0
1909 0 $self->end_element( { 'Name' => 'Hsp' } );
1910 0 last;
1911 }
1912 7822 chomp;
1913 7822 ▶ if (/^((Query|Sbjct):?\s+(\-?\d+)?\s*)(\S+)\s+(\-?\d+)?/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^((Query|Sbjct):?\s+(\-?\d+)?\s*)(\S+)\s+(\-?\d+)?/) { } 5224 2598 7822
elsif (/^((Query|Sbjct):?\s+(\-?0+)\s*)/) { } 0 2598 2598
1914 5224 my ( $full, $type, $start, $str, $end ) =
1915 ( $1, $2, $3, $4, $5 );
1916  
1917 5224 ▶ if ( $str eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str eq '-') { } 28 5196 5224
1918 28 ▶ $i = 3 if $type eq 'Sbjct';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Sbjct" 14 14 28
1919 }
1920 else {
1921 5196 $data{$type} = $str;
1922 }
1923 5224 $len = length($full);
1924 $self->{"\_$type"}->{'begin'} = $start
1925 5224 ▶ unless $self->{"_$type"}->{'begin'};
Branch: 1 branch
BranchTrueFalseTotal
unless $$self{"_$type"}{"begin"} 1362 3862 5224
1926 5224 $self->{"\_$type"}->{'end'} = $end;
1927 } elsif (/^((Query|Sbjct):?\s+(\-?0+)\s*)/) {
1928 # Bug from NCBI's BLAST: unaligned output
1929 0 $_ = $self->_readline() for 0..1;
1930 0 last;
1931 } else {
1932 2598 ▶ $self->throw("no data for midline $_")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ and defined $len 0 2598 2598
Condition33%1/3
defined $_ and defined $len
!ll&&!rl&&r
002598
MC/DC0%0/2
defined $_ and defined $len
defined $_ defined $len
Truth table33%1/3
A and B
A= defined $_B= defined $len
ABresult
0X0
100
111
1933 unless ( defined $_ && defined $len );
1934 2598 $data{'Mid'} = substr( $_, $len );
1935 }
1936 7822 $_ = $self->_readline();
1937 }
1938 $self->characters(
1939 {
1940 'Name' => 'Hsp_qseq',
1941 2612 'Data' => $data{'Query'}
1942 }
1943 );
1944 $self->characters(
1945 {
1946 'Name' => 'Hsp_hseq',
1947 2612 'Data' => $data{'Sbjct'}
1948 }
1949 );
1950 $self->characters(
1951 {
1952 'Name' => 'Hsp_midline',
1953 2612 'Data' => $data{'Mid'}
1954 }
1955 );
1956 }
1957 else {
1958 #$self->debug("blast.pm: unrecognized line $_");
1959 }
1960 }
1961  
1962 42 $self->debug("blast.pm: End of BlastOutput\n");
1963 42 ▶ if ( $self->{'_seentop'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_seentop"}) 40 2 42
1964 40 ▶ $self->within_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
$self->within_element("hsp") and $self->end_element({"Name", "Hsp"}) 5 35 40
1965 && $self->end_element( { 'Name' => 'Hsp' } );
1966 40 ▶ $self->within_element('hit')
Branch: 1 branch
BranchTrueFalseTotal
$self->within_element("hit") and $self->end_element({"Name", "Hit"}) 5 35 40
1967 && $self->end_element( { 'Name' => 'Hit' } );
1968 # cleanup extra hits
1969 40 ▶ $self->_cleanup_hits(\@hit_signifs) if scalar(@hit_signifs);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @hit_signifs 0 40 40
1970 40 ▶ $self->within_element('iteration')
Branch: 1 branch
BranchTrueFalseTotal
$self->within_element("iteration") and $self->end_element({"Name", "Iteration"}) 5 35 40
1971 && $self->end_element( { 'Name' => 'Iteration' } );
1972 40 ▶ if ($bl2seq_fix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bl2seq_fix) 2 38 40
1973 2 $self->element(
1974 {
1975 'Name' => 'BlastOutput_program',
1976 'Data' => $reporttype
1977 }
1978 );
1979 }
1980 40 $self->end_element( { 'Name' => 'BlastOutput' } );
1981 }
1982 42 return $self->end_document();
1983 }
1984  
1985 # Private method for internal use only.
1986 40 ▶sub _start_blastoutput {
Subroutine _start_blastoutput: called CC=1 SCAR=0.0
1987 40 my $self = shift;
1988 40 $self->start_element( { 'Name' => 'BlastOutput' } );
1989 40 $self->{'_seentop'} = 1;
1990 40 $self->{'_result_count'}++;
1991 40 $self->{'_handler_rc'} = undef;
1992 }
1993  
1994 =head2 _will_handle
1995  
1996 Title : _will_handle
1997 Usage : Private method. For internal use only.
1998 if( $self->_will_handle($type) ) { ... }
1999 Function: Provides an optimized way to check whether or not an element of a
2000 given type is to be handled.
2001 Returns : Reference to EventHandler object if the element type is to be handled.
2002 undef if the element type is not to be handled.
2003 Args : string containing type of element.
2004  
2005 Optimizations:
2006  
2007 =over 2
2008  
2009 =item 1
2010  
2011 Using the cached pointer to the EventHandler to minimize repeated
2012 lookups.
2013  
2014 =item 2
2015  
2016 Caching the will_handle status for each type that is encountered so
2017 that it only need be checked by calling
2018 handler-E<gt>will_handle($type) once.
2019  
2020 =back
2021  
2022 This does not lead to a major savings by itself (only 5-10%). In
2023 combination with other optimizations, or for large parse jobs, the
2024 savings good be significant.
2025  
2026 To test against the unoptimized version, remove the parentheses from
2027 around the third term in the ternary " ? : " operator and add two
2028 calls to $self-E<gt>_eventHandler().
2029  
2030 =cut
2031  
2032 3368 ▶sub _will_handle {
Subroutine _will_handle: called CC=3 SCAR=11.0
2033 3368 my ( $self, $type ) = @_;
2034 3368 my $handler = $self->{'_handler_cache'};
2035 my $will_handle =
2036 defined( $self->{'_will_handle_cache'}->{$type} )
2037 ? $self->{'_will_handle_cache'}->{$type}
2038 3368 ▶ : ( $self->{'_will_handle_cache'}->{$type} =
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_will_handle_cache'}{$type} ? : 3209 159 3368
2039 $handler->will_handle($type) );
2040  
2041 3368 ▶ return $will_handle ? $handler : undef;
Branch: 1 branch
BranchTrueFalseTotal
$will_handle ? : 3368 0 3368
2042 }
2043  
2044 =head2 start_element
2045  
2046 Title : start_element
2047 Usage : $eventgenerator->start_element
2048 Function: Handles a start element event
2049 Returns : none
2050 Args : hashref with at least 2 keys 'Data' and 'Name'
2051  
2052 =cut
2053  
2054 1684 ▶sub start_element {
Subroutine start_element: called CC=6 SCAR=18.0
Pod documented
2055 1684 my ( $self, $data ) = @_;
2056  
2057 # we currently don't care about attributes
2058 1684 my $nm = $data->{'Name'};
2059 1684 my $type = $MODEMAP{$nm};
2060 1684 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 1684 0 1684
2061 1684 my $handler = $self->_will_handle($type);
2062 1684 ▶ if ($handler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handler) 1684 0 1684
2063 1684 my $func = sprintf( "start_%s", lc $type );
2064 1684 $self->{'_handler_rc'} = $handler->$func( $data->{'Attributes'} );
2065 }
2066 #else {
2067 #$self->debug( # changed 4/29/2006 to play nice with other event handlers
2068 # "Bio::SearchIO::InternalParserError ".
2069 # "\nCan't handle elements of type \'$type.\'"
2070 #);
2071 #}
2072 1684 unshift @{ $self->{'_elements'} }, $type;
2073 1684 ▶ if ( $type eq 'result' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'result') { } 40 1644 1684
2074 40 $self->{'_values'} = {};
2075 40 $self->{'_result'} = undef;
2076 } else {
2077 # cleanup some things
2078 1644 ▶ if ( defined $self->{'_values'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_values"}) 1644 0 1644
2079 1644 foreach my $k (
2080 44608 grep { /^\U$type\-/ }
2081 1644 keys %{ $self->{'_values'} }
2082 )
2083 {
2084 15870 delete $self->{'_values'}->{$k};
2085 }
2086 }
2087 }
2088 }
2089 }
2090  
2091 =head2 end_element
2092  
2093 Title : end_element
2094 Usage : $eventgenerator->end_element
2095 Function: Handles an end element event
2096 Returns : hashref with an element's worth of data
2097 Args : hashref with at least 2 keys 'Data' and 'Name'
2098  
2099  
2100 =cut
2101  
2102 17783 ▶sub end_element {
Subroutine end_element: called CC=14 SCAR=26.4
Pod documented
2103 17783 my ( $self, $data ) = @_;
2104  
2105 17783 my $nm = $data->{'Name'};
2106 17783 my $type;
2107 my $rc;
2108 # cache these (TODO: we should probably cache all cross-report data)
2109 17783 ▶ if ( $nm eq 'BlastOutput_program' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nm eq "BlastOutput_program") 33 17750 17783
2110 33 ▶ if ( $self->{'_last_data'} =~ /(t?blast[npx])/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_last_data"} =~ /(t?blast[npx])/i) 32 1 33
2111 32 $self->{'_reporttype'} = uc $1;
2112 }
2113 33 ▶ $self->{'_reporttype'} ||= $DEFAULTREPORTTYPE;
Condition66%2/3
$self->{"_reporttype"} ||= $Bio::SearchIO::blast::DEFAULTREPORTTYPE
l!l&&r!l&&!r
3210
MC/DC0%0/2
$self->{"_reporttype"} ||= $Bio::SearchIO::blast::DEFAULTREPORTTYPE
$self->{"_reporttype"} $Bio::SearchIO::blast::DEFAULTREPORTTYPE
Truth table66%2/3
A ||= B
A= $self->{"_reporttype"}B= $Bio::SearchIO::blast::DEFAULTREPORTTYPE
ABresult
1X1
011
000
2114 }
2115  
2116 17783 ▶ if ( $nm eq 'BlastOutput_version' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nm eq "BlastOutput_version") 31 17752 17783
2117 31 $self->{'_reportversion'} = $self->{'_last_data'};
2118 }
2119  
2120 # Hsps are sort of weird, in that they end when another
2121 # object begins so have to detect this in end_element for now
2122 17783 ▶ if ( $nm eq 'Hsp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nm eq "Hsp") 681 17102 17783
2123 681 foreach (qw(Hsp_qseq Hsp_midline Hsp_hseq Hsp_features)) {
2124 $self->element(
2125 {
2126 'Name' => $_,
2127 'Data' => $self->{'_last_hspdata'}->{$_}
2128 }
2129 2724 ▶ ) if defined $self->{'_last_hspdata'}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_last_hspdata"}{$_} 2029 695 2724
2130 }
2131 681 $self->{'_last_hspdata'} = {};
2132 $self->element(
2133 {
2134 'Name' => 'Hsp_query-from',
2135 681 'Data' => $self->{'_Query'}->{'begin'}
2136 }
2137 );
2138 $self->element(
2139 {
2140 'Name' => 'Hsp_query-to',
2141 681 'Data' => $self->{'_Query'}->{'end'}
2142 }
2143 );
2144  
2145 $self->element(
2146 {
2147 'Name' => 'Hsp_hit-from',
2148 681 'Data' => $self->{'_Sbjct'}->{'begin'}
2149 }
2150 );
2151 $self->element(
2152 {
2153 'Name' => 'Hsp_hit-to',
2154 681 'Data' => $self->{'_Sbjct'}->{'end'}
2155 }
2156 );
2157  
2158 # } elsif( $nm eq 'Iteration' ) {
2159 # Nothing special needs to be done here.
2160 }
2161 17783 ▶ if ( $type = $MODEMAP{$nm} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type = $Bio::SearchIO::blast::MODEMAP{$nm}) { } 1684 16099 17783
elsif ($Bio::SearchIO::blast::MAPPING{$nm}) { } 15977 122 16099
2162 1684 my $handler = $self->_will_handle($type);
2163 1684 ▶ if ($handler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handler) 1684 0 1684
2164 1684 my $func = sprintf( "end_%s", lc $type );
2165 1684 $rc = $handler->$func( $self->{'_reporttype'}, $self->{'_values'} );
2166 }
2167 1684 shift @{ $self->{'_elements'} };
2168  
2169 }
2170 elsif ( $MAPPING{$nm} ) {
2171 15977 ▶ if ( ref( $MAPPING{$nm} ) =~ /hash/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Bio::SearchIO::blast::MAPPING{$nm}) =~ /hash/i) { } 1292 14685 15977
2172  
2173 # this is where we shove in the data from the
2174 # hashref info about params or statistics
2175 1292 my $key = ( keys %{ $MAPPING{$nm} } )[0];
2176 $self->{'_values'}->{$key}->{ $MAPPING{$nm}->{$key} } =
2177 1292 $self->{'_last_data'};
2178 }
2179 else {
2180 14685 $self->{'_values'}->{ $MAPPING{$nm} } = $self->{'_last_data'};
2181 }
2182 }
2183 else {
2184 #$self->debug("blast.pm: unknown nm $nm, ignoring\n");
2185 }
2186 17783 $self->{'_last_data'} = ''; # remove read data if we are at
2187 # end of an element
2188 17783 ▶ $self->{'_result'} = $rc if ( defined $type && $type eq 'result' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type eq "result" 40 17743 17783
Condition100%3/3
defined $type and $type eq "result"
!ll&&!rl&&r
16099164440
MC/DC100%2/2
defined $type and $type eq "result"
defined $type $type eq "result"
Truth table100%3/3
A and B
A= defined $typeB= $type eq "result"
ABresult
0X0
100
111
2189 17783 $self->{'_seen_hsp_features'} = 0;
2190 17783 return $rc;
2191 }
2192  
2193 =head2 element
2194  
2195 Title : element
2196 Usage : $eventhandler->element({'Name' => $name, 'Data' => $str});
2197 Function: Convenience method that calls start_element, characters, end_element
2198 Returns : none
2199 Args : Hash ref with the keys 'Name' and 'Data'
2200  
2201  
2202 =cut
2203  
2204 16099 ▶sub element {
Subroutine element: called CC=1 SCAR=0.0
Pod documented
2205 16099 my ( $self, $data ) = @_;
2206 # Note that start element isn't needed for character data
2207 # Not too SAX-y, though
2208 #$self->start_element($data);
2209 16099 $self->characters($data);
2210 16099 $self->end_element($data);
2211 }
2212  
2213 =head2 characters
2214  
2215 Title : characters
2216 Usage : $eventgenerator->characters($str)
2217 Function: Send a character events
2218 Returns : none
2219 Args : string
2220  
2221  
2222 =cut
2223  
2224 23935 ▶sub characters {
Subroutine characters: called CC=6 SCAR=17.9
Pod documented
2225 23935 my ( $self, $data ) = @_;
2226 23935 ▶ if ( $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->in_element("hsp") and $data->{"Name"} =~ /^Hsp\_(qseq|hseq|midline)$/) 9865 14070 23935
Condition100%3/3
$self->in_element("hsp") and $data->{"Name"} =~ /^Hsp\_(qseq|hseq|midline)$/
!ll&&!rl&&r
608479869865
MC/DC100%2/2
$self->in_element("hsp") and $data->{"Name"} =~ /^Hsp\_(qseq|hseq|midline)$/
$self->in_element("hsp") $data->{"Name"} =~ /^Hsp\_(qseq|hseq|midline)$/
Truth table100%3/3
A and B
A= $self->in_element("hsp")B= $data->{"Name"} =~ /^Hsp\_(qseq|hseq|midline)$/
ABresult
0X0
100
111
2227 && $data->{'Name'} =~ /^Hsp\_(qseq|hseq|midline)$/ )
2228 {
2229 $self->{'_last_hspdata'}->{ $data->{'Name'} } .= $data->{'Data'}
2230 9865 ▶ if defined $data->{'Data'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"Data"} 9851 14 9865
2231 }
2232 23935 ▶ return unless ( defined $data->{'Data'} && $data->{'Data'} !~ /^\s+$/ );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{"Data"} and not $data->{"Data"} =~ /^\s+$/ 31 23904 23935
Condition66%2/3
defined $data->{"Data"} and not $data->{"Data"} =~ /^\s+$/
!ll&&!rl&&r
31023904
MC/DC50%1/2
defined $data->{"Data"} and not $data->{"Data"} =~ /^\s+$/
defined $data->{"Data"} not $data->{"Data"} =~ /^\s+$/
Truth table66%2/3
A and not(B)
A= defined $data->{"Data"}B= not $data->{"Data"} =~ /^\s+$/
ABresult
0X0
100
111
2233 23904 $self->{'_last_data'} = $data->{'Data'};
2234 }
2235  
2236 =head2 within_element
2237  
2238 Title : within_element
2239 Usage : if( $eventgenerator->within_element($element) ) {}
2240 Function: Test if we are within a particular element
2241 This is different than 'in' because within can be tested
2242 for a whole block.
2243 Returns : boolean
2244 Args : string element name
2245  
2246 See Also: L<in_element>
2247  
2248 =cut
2249  
2250 810 ▶sub within_element {
Subroutine within_element: called CC=6 SCAR=18.2
Pod documented
2251 810 my ( $self, $name ) = @_;
2252 return 0
2253 if ( !defined $name && !defined $self->{'_elements'}
2254 810 ▶ || scalar @{ $self->{'_elements'} } == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name || defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0 1 809 810
Condition50%3/6
not defined $name || defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0
l!l&&r!l&&!r
01809
defined $name || defined $self->{'_elements'}
l!l&&r!l&&!r
81000
MC/DC33%1/3
not defined $name || defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0
defined $name defined $self->{'_elements'} scalar @{$self->{"_elements"};} == 0
Truth table40%2/5
not(A || B) or C
A= defined $nameB= defined $self->{'_elements'}C= scalar @{$self->{"_elements"};} == 0
ABCresult
00X1
1X11
0111
1X00
0100
2255 809 foreach ( @{ $self->{'_elements'} } ) {
2256 1136 ▶ if ( $_ eq $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $name) 704 432 1136
2257 704 return 1;
2258 }
2259 }
2260 105 return 0;
2261 }
2262  
2263 =head2 in_element
2264  
2265 Title : in_element
2266 Usage : if( $eventgenerator->in_element($element) ) {}
2267 Function: Test if we are in a particular element
2268 This is different than 'within_element' because within
2269 can be tested for a whole block.
2270 Returns : boolean
2271 Args : string element name
2272  
2273 See Also: L<within_element>
2274  
2275 =cut
2276  
2277 88113 ▶sub in_element {
Subroutine in_element: called CC=2 SCAR=6.9
Pod documented
2278 88113 my ( $self, $name ) = @_;
2279 88113 ▶ return 0 if !defined $self->{'_elements'}->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_elements"}[0] 4 88109 88113
2280 88109 return ( $self->{'_elements'}->[0] eq $name );
2281 }
2282  
2283 =head2 start_document
2284  
2285 Title : start_document
2286 Usage : $eventgenerator->start_document
2287 Function: Handle a start document event
2288 Returns : none
2289 Args : none
2290  
2291  
2292 =cut
2293  
2294 42 ▶sub start_document {
Subroutine start_document: called CC=1 SCAR=0.0
Pod documented
2295 42 my ($self) = @_;
2296 42 $self->{'_lasttype'} = '';
2297 42 $self->{'_values'} = {};
2298 42 $self->{'_result'} = undef;
2299 42 $self->{'_elements'} = [];
2300 }
2301  
2302 =head2 end_document
2303  
2304 Title : end_document
2305 Usage : $eventgenerator->end_document
2306 Function: Handles an end document event
2307 Returns : Bio::Search::Result::ResultI object
2308 Args : none
2309  
2310  
2311 =cut
2312  
2313 42 ▶sub end_document {
Subroutine end_document: called CC=1 SCAR=0.0
Pod documented
2314 42 my ( $self, @args ) = @_;
2315  
2316 #$self->debug("blast.pm: end_document\n");
2317 42 return $self->{'_result'};
2318 }
2319  
2320 5 ▶sub write_result {
Subroutine write_result: called CC=2 SCAR=8.4
Pod documented
2321 5 my ( $self, $blast, @args ) = @_;
2322  
2323 5 ▶ if ( not defined( $self->writer ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->writer) 0 5 5
2324 0 $self->warn("Writer not defined. Using a $DEFAULT_BLAST_WRITER_CLASS");
2325 0 $self->writer( $DEFAULT_BLAST_WRITER_CLASS->new() );
2326 }
2327 5 $self->SUPER::write_result( $blast, @args );
2328 }
2329  
2330 0 ▶sub result_count {
Subroutine result_count: not called CC=1 SCAR=6.9
Pod documented
2331 0 my $self = shift;
2332 0 return $self->{'_result_count'};
2333 }
2334  
2335 0 ▶sub report_count { shift->result_count }
Subroutine report_count: not called CC=1 SCAR=6.9
Pod undocumented
2336  
2337 =head2 inclusion_threshold
2338  
2339 Title : inclusion_threshold
2340 Usage : my $incl_thresh = $isreb->inclusion_threshold;
2341 : $isreb->inclusion_threshold(1e-5);
2342 Function: Get/Set the e-value threshold for inclusion in the PSI-BLAST
2343 score matrix model (blastpgp) that was used for generating the reports
2344 being parsed.
2345 Returns : number (real)
2346 Default value: $Bio::SearchIO::IteratedSearchResultEventBuilder::DEFAULT_INCLUSION_THRESHOLD
2347 Args : number (real) (e.g., 0.0001 or 1e-4 )
2348  
2349 =cut
2350  
2351 =head2 max_significance
2352  
2353 Usage : $obj->max_significance();
2354 Purpose : Set/Get the P or Expect value used as significance screening cutoff.
2355 This is the value of the -signif parameter supplied to new().
2356 Hits with P or E-value above this are skipped.
2357 Returns : Scientific notation number with this format: 1.0e-05.
2358 Argument : Scientific notation number or float (when setting)
2359 Comments : Screening of significant hits uses the data provided on the
2360 : description line. For NCBI BLAST1 and WU-BLAST, this data
2361 : is P-value. for NCBI BLAST2 it is an Expect value.
2362  
2363 =cut
2364  
2365 =head2 signif
2366  
2367 Synonym for L<max_significance()|max_significance>
2368  
2369 =cut
2370  
2371 =head2 min_score
2372  
2373 Usage : $obj->min_score();
2374 Purpose : Set/Get the Blast score used as screening cutoff.
2375 This is the value of the -score parameter supplied to new().
2376 Hits with scores below this are skipped.
2377 Returns : Integer or scientific notation number.
2378 Argument : Integer or scientific notation number (when setting)
2379 Comments : Screening of significant hits uses the data provided on the
2380 : description line.
2381  
2382 =cut
2383  
2384 =head2 min_query_length
2385  
2386 Usage : $obj->min_query_length();
2387 Purpose : Gets the query sequence length used as screening criteria.
2388 This is the value of the -min_query_len parameter supplied to new().
2389 Hits with sequence length below this are skipped.
2390 Returns : Integer
2391 Argument : n/a
2392  
2393 =cut
2394  
2395 =head2 best_hit_only
2396  
2397 Title : best_hit_only
2398 Usage : print "only getting best hit.\n" if $obj->best_hit_only;
2399 Purpose : Set/Get the indicator for whether or not to process only
2400 : the best BlastHit.
2401 Returns : Boolean (1 | 0)
2402 Argument : Boolean (1 | 0) (when setting)
2403  
2404 =cut
2405  
2406 =head2 check_all_hits
2407  
2408 Title : check_all_hits
2409 Usage : print "checking all hits.\n" if $obj->check_all_hits;
2410 Purpose : Set/Get the indicator for whether or not to process all hits.
2411 : If false, the parser will stop processing hits after the
2412 : the first non-significance hit or the first hit that fails
2413 : any hit filter.
2414 Returns : Boolean (1 | 0)
2415 Argument : Boolean (1 | 0) (when setting)
2416  
2417 =cut
2418  
2419 # general private method used to make minimal hits from leftover
2420 # data in the hit table
2421  
2422 3 ▶sub _cleanup_hits {
Subroutine _cleanup_hits: called CC=5 SCAR=16.3
2423 3 my ($self, $hits) = @_;
2424 3 ▶ while ( my $v = shift @{ $hits }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $v = shift @{$hits;}) 595 3 598
2425 595 ▶ next unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 595 595
2426 595 $self->start_element( { 'Name' => 'Hit' } );
2427 595 my $id = $v->[2];
2428 595 my $desc = $v->[3];
2429 595 $self->element(
2430 {
2431 'Name' => 'Hit_id',
2432 'Data' => $id
2433 }
2434 );
2435 595 my ($gi, $acc, $version ) = $self->_get_seq_identifiers($id);
2436 595 $self->element(
2437 {
2438 'Name' => 'Hit_accession',
2439 'Data' => $acc
2440 }
2441 );
2442 595 ▶ if ( defined $v ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) 595 0 595
2443 595 $self->element(
2444 {
2445 'Name' => 'Hit_signif',
2446 'Data' => $v->[0]
2447 }
2448 );
2449 595 ▶ if (exists $self->{'_wublast'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'_wublast'}) { } 0 595 595
2450 0 $self->element(
2451 {
2452 'Name' => 'Hit_score',
2453 'Data' => $v->[1]
2454 }
2455 );
2456 } else {
2457 595 $self->element(
2458 {
2459 'Name' => 'Hit_bits',
2460 'Data' => $v->[1]
2461 }
2462 );
2463 }
2464  
2465 }
2466 $self->element(
2467 {
2468 595 'Name' => 'Hit_def',
2469 'Data' => $desc
2470 }
2471 );
2472 595 $self->end_element( { 'Name' => 'Hit' } );
2473 }
2474 }
2475  
2476  
2477 12 1;
2478  
2479 __END__
« Bio/Search/SearchUtils.pm ↑ Summary Bio/OntologyIO/Handlers/InterProHandler.pm »