Bio/SearchIO/psl.pm

filter: Statementstmt 83.8% 145 / 173 Branchbran 67.8% 38 / 56 Conditioncond 56.6% 17 / 30 MC/DCmcdc 38.8% 7 / 18 Subroutinesub 80.0% 16 / 20 Podpod 91.6% 11 / 12 totaltotal 75.7% 234 / 309 CC 40 SCAR 24.1
CC
40
Cov
77%
within_element
42.0
next_result
15.2
characters
9.2
CRAP 11.1
« Bio/AlignIO/arp.pm ↑ Summary Bio/Search/Tiling/MapTiling.pm »
1 #
2 # BioPerl module for Bio::SearchIO::psl
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Jason Stajich <jason-at-bioperl-dot-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 =head1 NAME
15  
16 Bio::SearchIO::psl - A parser for PSL output (UCSC)
17  
18 =head1 SYNOPSIS
19  
20 use Bio::SearchIO;
21 my $parser = Bio::SearchIO->new(-file => 'file.psl',
22 -format => 'psl');
23 while( my $result = $parser->next_result ) {
24 }
25  
26 =head1 DESCRIPTION
27  
28 This is a SearchIO driver for PSL format.
29 PSL format is documented here:
30 http://genome.ucsc.edu/goldenPath/help/customTrack.html#PSL
31  
32 By default it assumes PSL output came from BLAT you can override that
33 by specifying -program_name =E<gt> 'BLASTZ' when initializing the
34 SearchIO object.
35  
36 =head1 FEEDBACK
37  
38 =head2 Mailing Lists
39  
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to
42 the Bioperl mailing list. Your participation is much appreciated.
43  
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46  
47 =head2 Support
48  
49 Please direct usage questions or support issues to the mailing list:
50  
51 I<bioperl-l@bioperl.org>
52  
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
57  
58 =head2 Reporting Bugs
59  
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted via the
62 web:
63  
64 https://github.com/bioperl/bioperl-live/issues
65  
66 =head1 AUTHOR - Jason Stajich
67  
68 Email jason-at-bioperl-dot-org
69  
70 =head1 APPENDIX
71  
72 The rest of the documentation details each of the object methods.
73 Internal methods are usually preceded with a _
74  
75 =cut
76  
77 # Let the code begin...
78  
79 package Bio::SearchIO::psl;
80 2 $Bio::SearchIO::psl::VERSION = '1.7.8';
81 2 ▶use vars qw(%MAPPING %MODEMAP $DEFAULT_WRITER_CLASS $DefaultProgramName);
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 2 ▶use Bio::Search::HSP::HSPFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 2 ▶use Bio::Search::Hit::HitFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 2 ▶use Bio::Search::Result::ResultFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 2 $DefaultProgramName = 'BLAT';
89 2 $DEFAULT_WRITER_CLASS = 'Bio::SearchIO::Writer::HitTableWriter';
90  
91 # mapping of terms to Bioperl hash keys
92 2 %MODEMAP = (
93 'PSLOutput' => 'result',
94 'Result' => 'result',
95 'Hit' => 'hit',
96 'Hsp' => 'hsp'
97 );
98  
99 2 %MAPPING = (
100 'Hsp_bit-score' => 'HSP-bits',
101 'Hsp_score' => 'HSP-score',
102 'Hsp_evalue' => 'HSP-evalue',
103 'Hsp_query-from' => 'HSP-query_start',
104 'Hsp_query-to' => 'HSP-query_end',
105 'Hsp_hit-from' => 'HSP-hit_start',
106 'Hsp_hit-to' => 'HSP-hit_end',
107 'Hsp_positive' => 'HSP-conserved',
108 'Hsp_identity' => 'HSP-identical',
109 'Hsp_mismatches' => 'HSP-mismatches',
110 'Hsp_qgapblocks' => 'HSP-query_gapblocks',
111 'Hsp_hgapblocks' => 'HSP-hit_gapblocks',
112 'Hsp_gaps' => 'HSP-hsp_gaps',
113 'Hsp_hitgaps' => 'HSP-hit_gaps',
114 'Hsp_querygaps' => 'HSP-query_gaps',
115 'Hsp_align-len' => 'HSP-hsp_length',
116 'Hsp_query-frame' => 'HSP-query_frame',
117 'Hsp_hit-frame' => 'HSP-hit_frame',
118  
119 'Hit_id' => 'HIT-name',
120 'Hit_len' => 'HIT-length',
121 'Hit_accession' => 'HIT-accession',
122 'Hit_def' => 'HIT-description',
123 'Hit_signif' => 'HIT-significance',
124 'Hit_score' => 'HIT-score',
125 'Hit_bits' => 'HIT-bits',
126  
127 'PSLOutput_program' => 'RESULT-algorithm_name',
128 'PSLOutput_version' => 'RESULT-algorithm_version',
129 'PSLOutput_query-def' => 'RESULT-query_name',
130 'PSLOutput_query-len' => 'RESULT-query_length',
131 'PSLOutput_query-acc' => 'RESULT-query_accession',
132 'PSLOutput_querydesc' => 'RESULT-query_description',
133 'PSLOutput_db' => 'RESULT-database_name',
134 'PSLOutput_db-len' => 'RESULT-database_entries',
135 'PSLOutput_db-let' => 'RESULT-database_letters',
136 );
137  
138 2 ▶use base qw(Bio::SearchIO);
Subroutine BEGIN: called CC=1 SCAR=0.0
139  
140 =head2 new
141  
142 Title : new
143 Usage : my $obj = Bio::SearchIO::psl->new();
144 Function: Builds a new Bio::SearchIO::psl object
145 Returns : an instance of Bio::SearchIO::psl
146 Args :
147  
148  
149 =cut
150  
151 3 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=7.1
152 3 my ( $self, @args ) = @_;
153 3 $self->SUPER::_initialize(@args);
154 3 my ($pname) = $self->_rearrange( [qw(PROGRAM_NAME)], @args );
155 3 ▶ $self->program_name( $pname || $DefaultProgramName );
Condition33%1/3
$pname || $Bio::SearchIO::psl::DefaultProgramName
l!l&&r!l&&!r
030
MC/DC0%0/2
$pname || $Bio::SearchIO::psl::DefaultProgramName
$pname $Bio::SearchIO::psl::DefaultProgramName
Truth table33%1/3
A || B
A= $pnameB= $Bio::SearchIO::psl::DefaultProgramName
ABresult
1X1
011
000
156 3 $self->_eventHandler->register_factory(
157 'result',
158 Bio::Search::Result::ResultFactory->new(
159 -type => 'Bio::Search::Result::GenericResult'
160 )
161 );
162  
163 3 $self->_eventHandler->register_factory(
164 'hit',
165 Bio::Search::Hit::HitFactory->new(
166 -type => 'Bio::Search::Hit::GenericHit'
167 )
168 );
169 3 $self->_eventHandler->register_factory(
170 'hsp',
171 Bio::Search::HSP::HSPFactory->new(
172 -type => 'Bio::Search::HSP::PSLHSP'
173 )
174 );
175 }
176  
177 =head2 next_result
178  
179 Title : next_result
180 Usage : my $result = $parser->next_result
181 Function: Parse the next result from the data stream
182 Returns : L<Bio::Search::Result::ResultI> or undef if no more results
183 Args : none
184  
185 =cut
186  
187 4 ▶sub next_result {
Subroutine next_result: called CC=15 SCAR=27.2
Pod documented
188 4 my ($self) = @_;
189 4 my ( $lastquery, $lasthit );
190 4 local $/ = "\n";
191 4 local $_;
192  
193 # skip over any header lines
194 4 ▶ while( defined($_ = $self->_readline) and ! /^\d+\s+\d+\s+/ ) {}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline) and not /^\d+\s+\d+\s+/) 10 4 14
Condition100%3/3
defined($_ = $self->_readline) and not /^\d+\s+\d+\s+/
!ll&&!rl&&r
2210
MC/DC100%2/2
defined($_ = $self->_readline) and not /^\d+\s+\d+\s+/
defined($_ = $self->_readline) not /^\d+\s+\d+\s+/
Truth table100%3/3
A and not(B)
A= defined($_ = $self->_readline)B= not /^\d+\s+\d+\s+/
ABresult
0X0
100
111
195 4 $self->_pushback($_);
196  
197 # now start the main parsing loop
198 4 ▶ while ( defined( $_ = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 6 3 9
199 my (
200 6 $matches, $mismatches, $rep_matches, $n_count,
201 $q_num_insert, $q_base_insert, $t_num_insert, $t_base_insert,
202 $strand, $q_name, $q_length, $q_start,
203 $q_end, $t_name, $t_length, $t_start,
204 $t_end, $block_count, $block_sizes, $q_starts,
205 $t_starts
206 ) = split;
207  
208 6 ▶ $q_length > 0 or $self->throw("parse error, invalid query length '$q_length'");
Branch: 1 branch
BranchTrueFalseTotal
$q_length > 0 or $self->throw("parse error, invalid query length '${q_length}'") 6 0 6
209 6 my $score = sprintf( "%.2f", 100 * ( $matches + $mismatches + $rep_matches ) / $q_length );
210  
211 # this is overall percent identity...
212 6 my $match_total = $matches + $mismatches + $rep_matches;
213 6 ▶ $match_total > 0
Branch: 1 branch
BranchTrueFalseTotal
$match_total > 0 or $self->throw("parse error, matches + mismatches + rep_matches must be > 0!") 6 0 6
214 or $self->throw("parse error, matches + mismatches + rep_matches must be > 0!");
215 6 my $percent_id = sprintf("%.2f", 100 * ( $matches + $rep_matches ) / $match_total );
216  
217 # Remember Jim's code is 0 based
218 6 ▶ if ( defined $lastquery
Branch: 3 branches
BranchTrueFalseTotal
if (defined $lastquery and $lastquery ne $q_name) { } 1 5 6
elsif (not defined $lastquery) { } 2 3 5
elsif ($lasthit ne $t_name) { } 0 3 3
Condition100%3/3
defined $lastquery and $lastquery ne $q_name
!ll&&!rl&&r
231
MC/DC100%2/2
defined $lastquery and $lastquery ne $q_name
defined $lastquery $lastquery ne $q_name
Truth table100%3/3
A and B
A= defined $lastqueryB= $lastquery ne $q_name
ABresult
0X0
100
111
219 && $lastquery ne $q_name )
220 {
221 1 $self->end_element( { 'Name' => 'Hit' } );
222 1 $self->end_element( { 'Name' => 'PSLOutput' } );
223 1 $self->_pushback($_);
224 1 return $self->end_document;
225 }
226 elsif ( !defined $lastquery ) {
227 2 $self->{'_result_count'}++;
228 2 $self->start_element( { 'Name' => 'PSLOutput' } );
229 2 $self->element(
230 {
231 'Name' => 'PSLOutput_program',
232 'Data' => $self->program_name
233 }
234 );
235 2 $self->element(
236 {
237 'Name' => 'PSLOutput_query-def',
238 'Data' => $q_name
239 }
240 );
241 2 $self->element(
242 {
243 'Name' => 'PSLOutput_query-len',
244 'Data' => $q_length
245 }
246 );
247 2 $self->start_element( { 'Name' => 'Hit' } );
248 2 $self->element(
249 {
250 'Name' => 'Hit_id',
251 'Data' => $t_name
252 }
253 );
254 2 $self->element(
255 {
256 'Name' => 'Hit_len',
257 'Data' => $t_length
258 }
259 );
260 2 $self->element(
261 {
262 'Name' => 'Hit_score',
263 'Data' => $score
264 }
265 );
266 }
267 elsif ( $lasthit ne $t_name ) {
268 0 $self->end_element( { 'Name' => 'Hit' } );
269 0 $self->start_element( { 'Name' => 'Hit' } );
270 0 $self->element(
271 {
272 'Name' => 'Hit_id',
273 'Data' => $t_name
274 }
275 );
276 0 $self->element(
277 {
278 'Name' => 'Hit_len',
279 'Data' => $t_length
280 }
281 );
282 0 $self->element(
283 {
284 'Name' => 'Hit_score',
285 'Data' => $score
286 }
287 );
288 }
289  
290 5 my $identical = $matches + $rep_matches;
291 5 $self->start_element( { 'Name' => 'Hsp' } );
292 5 $self->element(
293 {
294 'Name' => 'Hsp_score',
295 'Data' => $score
296 }
297 );
298 5 $self->element(
299 {
300 'Name' => 'Hsp_identity',
301 'Data' => $identical
302 }
303 );
304 5 $self->element(
305 {
306 'Name' => 'Hsp_positive',
307 'Data' => $identical
308 }
309 );
310 5 $self->element(
311 {
312 'Name' => 'Hsp_mismatches',
313 'Data' => $mismatches
314 }
315 );
316 5 $self->element(
317 {
318 'Name' => 'Hsp_gaps',
319 'Data' => $q_base_insert + $t_base_insert
320 }
321 );
322  
323 # query gaps are the number of target inserts and vice-versa
324 5 $self->element(
325 {
326 'Name' => 'Hsp_querygaps',
327 'Data' => $t_base_insert
328 }
329 );
330 5 $self->element(
331 {
332 'Name' => 'Hsp_hitgaps',
333 'Data' => $q_base_insert
334 }
335 );
336 5 ▶ if ( $strand eq '+' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strand eq '+') { } 3 2 5
337 3 $self->element(
338 {
339 'Name' => 'Hsp_query-from',
340 'Data' => $q_start + 1
341 }
342 );
343 3 $self->element(
344 {
345 'Name' => 'Hsp_query-to',
346 'Data' => $q_end
347 }
348 );
349 }
350 else {
351 2 $self->element(
352 {
353 'Name' => 'Hsp_query-to',
354 'Data' => $q_start + 1
355 }
356 );
357 2 $self->element(
358 {
359 'Name' => 'Hsp_query-from',
360 'Data' => $q_end
361 }
362 );
363 }
364  
365 5 my $hsplen =
366 ($q_base_insert +
367 $t_base_insert +
368 abs( $t_end - $t_start ) +
369 abs( $q_end - $q_start ))/2;
370  
371 5 $self->element(
372 {
373 'Name' => 'Hsp_hit-from',
374 'Data' => $t_start + 1
375 }
376 );
377 5 $self->element(
378 {
379 'Name' => 'Hsp_hit-to',
380 'Data' => $t_end
381 }
382 );
383 5 $self->element(
384 {
385 'Name' => 'Hsp_align-len',
386 'Data' => $hsplen
387 }
388 );
389  
390 # cleanup trailing commas in some output
391 5 $block_sizes =~ s/\,$//;
392 5 $q_starts =~ s/\,$//;
393 5 $t_starts =~ s/\,$//;
394 5 my @blocksizes = split( /,/, $block_sizes ); # block sizes
395 5 my @qstarts = split( /,/, $q_starts ); # starting position of each block
396 # in query
397 5 my @tstarts = split( /,/, $t_starts ); # starting position of each block
398 # in target
399 5 my ( @qgapblocks, @hgapblocks );
400  
401 5 ▶ for ( my $i = 0 ; $i < $block_count ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $block_count) 38 5 43
402 38 ▶ if ( $strand eq '+' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strand eq '+') { } 30 8 38
403 30 push @qgapblocks, [ $qstarts[$i] + 1, $blocksizes[$i] ];
404 }
405 else {
406 8 push @qgapblocks, [ $q_length - $qstarts[$i], $blocksizes[$i] ];
407 }
408 38 push @hgapblocks, [ $tstarts[$i] + 1, $blocksizes[$i] ];
409 }
410 5 $self->element(
411 {
412 'Name' => 'Hsp_qgapblocks',
413 'Data' => \@qgapblocks
414 }
415 );
416 5 $self->element(
417 {
418 'Name' => 'Hsp_hgapblocks',
419 'Data' => \@hgapblocks
420 }
421 );
422 5 $self->end_element( { 'Name' => 'Hsp' } );
423 5 $lastquery = $q_name;
424 5 $lasthit = $t_name;
425 }
426 3 ▶ if ( defined $lasthit || defined $lastquery ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lasthit or defined $lastquery) 1 2 3
Condition66%2/3
defined $lasthit or defined $lastquery
l!l&&r!l&&!r
102
MC/DC50%1/2
defined $lasthit or defined $lastquery
defined $lasthit defined $lastquery
Truth table66%2/3
A or B
A= defined $lasthitB= defined $lastquery
ABresult
1X1
011
000
427 1 $self->end_element( { 'Name' => 'Hit' } );
428 1 $self->end_element( { 'Name' => 'Result' } );
429 1 return $self->end_document;
430 }
431 }
432  
433 =head2 start_element
434  
435 Title : start_element
436 Usage : $eventgenerator->start_element
437 Function: Handles a start element event
438 Returns : none
439 Args : hashref with at least 2 keys 'Data' and 'Name'
440  
441  
442 =cut
443  
444 91 ▶sub start_element {
Subroutine start_element: called CC=4 SCAR=13.9
Pod documented
445 91 my ( $self, $data ) = @_;
446  
447 # we currently don't care about attributes
448 91 my $nm = $data->{'Name'};
449 91 ▶ if ( my $type = $MODEMAP{$nm} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = $Bio::SearchIO::psl::MODEMAP{$nm}) 9 82 91
450 9 $self->_mode($type);
451 9 ▶ if ( $self->_eventHandler->will_handle($type) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_eventHandler->will_handle($type)) 9 0 9
452 9 my $func = 'start_'.lc $type;
453 9 $self->_eventHandler->$func( $data->{'Attributes'} );
454 }
455 9 unshift @{ $self->{'_elements'} }, $type;
456 }
457 91 ▶ if ( $nm eq 'PSLOutput' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nm eq "PSLOutput") 2 89 91
458 2 $self->{'_values'} = {};
459 2 $self->{'_result'} = undef;
460 2 $self->{'_mode'} = '';
461 }
462  
463 }
464  
465 =head2 end_element
466  
467 Title : end_element
468 Usage : $eventgenerator->end_element
469 Function: Handles an end element event
470 Returns : return value from the associated end_$type event handler
471 Args : hashref with at least 2 keys 'Data' and 'Name'
472  
473  
474 =cut
475  
476 91 ▶sub end_element {
Subroutine end_element: called CC=8 SCAR=21.8
Pod documented
477 91 my ( $self, $data ) = @_;
478 91 my $nm = $data->{'Name'};
479 91 my $rc;
480  
481 # Hsp are sort of weird, in that they end when another
482 # object begins so have to detect this in end_element for now
483  
484 91 ▶ if ( my $type = $MODEMAP{$nm} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $type = $Bio::SearchIO::psl::MODEMAP{$nm}) { } 9 82 91
elsif ($Bio::SearchIO::psl::MAPPING{$nm}) { } 82 0 82
485 9 ▶ if ( $self->_eventHandler->will_handle($type) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_eventHandler->will_handle($type)) 9 0 9
486 9 my $func = 'end_'.lc $type;
487 $rc = $self->_eventHandler->$func( $self->{'_reporttype'},
488 9 $self->{'_values'} );
489 }
490 9 shift @{ $self->{'_elements'} };
491  
492 }
493 elsif ( $MAPPING{$nm} ) {
494 82 ▶ if ( ref( $MAPPING{$nm} ) =~ /hash/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Bio::SearchIO::psl::MAPPING{$nm}) =~ /hash/i) { } 0 82 82
495 0 my $key = ( keys %{ $MAPPING{$nm} } )[0];
496 $self->{'_values'}->{$key}->{ $MAPPING{$nm}->{$key} } =
497 0 $self->{'_last_data'};
498 }
499 else {
500 82 $self->{'_values'}->{ $MAPPING{$nm} } = $self->{'_last_data'};
501 }
502 }
503 else {
504 0 $self->warn(
505 __PACKAGE__ . "::end_element: unknown nm '$nm', ignoring\n" );
506 }
507 91 $self->{'_last_data'} = ''; # remove read data if we are at
508 # end of an element
509 $self->{'_result'} = $rc
510 if ( defined $nm
511 && defined $MODEMAP{$nm}
512 91 ▶ && $MODEMAP{$nm} eq 'result' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $nm and defined $Bio::SearchIO::psl::MODEMAP{$nm} and $Bio::SearchIO::psl::MODEMAP{$nm} eq "result" 2 89 91
Condition83%5/6
defined $nm and defined $Bio::SearchIO::psl::MODEMAP{$nm} and $Bio::SearchIO::psl::MODEMAP{$nm} eq "result"
!ll&&!rl&&r
8272
defined $nm and defined $Bio::SearchIO::psl::MODEMAP{$nm}
!ll&&!rl&&r
0829
MC/DC66%2/3
defined $nm and defined $Bio::SearchIO::psl::MODEMAP{$nm} and $Bio::SearchIO::psl::MODEMAP{$nm} eq "result"
defined $nm defined $Bio::SearchIO::psl::MODEMAP{$nm} $Bio::SearchIO::psl::MODEMAP{$nm} eq "result"
Truth table75%3/4
A and B and C
A= defined $nmB= defined $Bio::SearchIO::psl::MODEMAP{$nm}C= $Bio::SearchIO::psl::MODEMAP{$nm} eq "result"
ABCresult
0XX0
10X0
1100
1111
513 91 return $rc;
514  
515 }
516  
517 =head2 element
518  
519 Title : element
520 Usage : $eventhandler->element({'Name' => $name, 'Data' => $str});
521 Function: Convience method that calls start_element, characters, end_element
522 Returns : none
523 Args : Hash ref with the keys 'Name' and 'Data'
524  
525  
526 =cut
527  
528 82 ▶sub element {
Subroutine element: called CC=1 SCAR=0.0
Pod documented
529 82 my ( $self, $data ) = @_;
530 82 $self->start_element($data);
531 82 $self->characters($data);
532 82 $self->end_element($data);
533 }
534  
535 =head2 characters
536  
537 Title : characters
538 Usage : $eventgenerator->characters($str)
539 Function: Send a character events
540 Returns : none
541 Args : string
542  
543  
544 =cut
545  
546 82 ▶sub characters {
Subroutine characters: called CC=6 SCAR=22.1
Pod documented
547 82 my ( $self, $data ) = @_;
548  
549 82 ▶ return unless ( defined $data->{'Data'} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{"Data"} 0 82 82
550 82 ▶ if ( $data->{'Data'} =~ /^\s+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{"Data"} =~ /^\s+$/) 0 82 82
551 0 ▶ return unless $data->{'Name'} =~ /Hsp\_(midline|qseq|hseq)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{"Name"} =~ /Hsp\_(midline|qseq|hseq)/ 0 0 0
552 }
553  
554 82 ▶ if ( $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(qseq|hseq|midline)/) 0 82 82
Condition66%2/3
$self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(qseq|hseq|midline)/
!ll&&!rl&&r
12700
MC/DC0%0/2
$self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(qseq|hseq|midline)/
$self->in_element("hsp") $data->{"Name"} =~ /Hsp\_(qseq|hseq|midline)/
Truth table66%2/3
A and B
A= $self->in_element("hsp")B= $data->{"Name"} =~ /Hsp\_(qseq|hseq|midline)/
ABresult
0X0
100
111
555 && $data->{'Name'} =~ /Hsp\_(qseq|hseq|midline)/ )
556 {
557  
558 0 $self->{'_last_hspdata'}->{ $data->{'Name'} } .= $data->{'Data'};
559 }
560  
561 82 $self->{'_last_data'} = $data->{'Data'};
562 }
563  
564 =head2 _mode
565  
566 Title : _mode
567 Usage : $obj->_mode($newval)
568 Function:
569 Example :
570 Returns : value of _mode
571 Args : newvalue (optional)
572  
573  
574 =cut
575  
576 9 ▶sub _mode {
Subroutine _mode: called CC=2 SCAR=7.0
577 9 my ( $self, $value ) = @_;
578 9 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 9 0 9
579 9 $self->{'_mode'} = $value;
580 }
581 9 return $self->{'_mode'};
582 }
583  
584 =head2 within_element
585  
586 Title : within_element
587 Usage : if( $eventgenerator->within_element($element) ) {}
588 Function: Test if we are within a particular element
589 This is different than 'in' because within can be tested
590 for a whole block.
591 Returns : boolean
592 Args : string element name
593  
594  
595 =cut
596  
597 0 ▶sub within_element {
Subroutine within_element: not called CC=6 SCAR=37.4
Pod documented
598 0 my ( $self, $name ) = @_;
599 return 0
600 if (!defined $name && !defined $self->{'_elements'}
601 0 ▶ || scalar @{ $self->{'_elements'} } == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name || defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0 0 0 0
Condition0%0/6
not defined $name || defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0
l!l&&r!l&&!r
000
defined $name || defined $self->{'_elements'}
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $name || defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0
defined $name defined $self->{'_elements'} scalar @{$self->{"_elements"};} == 0
Truth table0%0/5
not(A || B) or C
A= defined $nameB= defined $self->{'_elements'}C= scalar @{$self->{"_elements"};} == 0
ABCresult
00X1
1X11
0111
1X00
0100
602 0 foreach ( @{ $self->{'_elements'} } ) {
603 0 ▶ if ( $_ eq $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $name) 0 0 0
604 0 return 1;
605 }
606 }
607 0 return 0;
608 }
609  
610 =head2 in_element
611  
612 Title : in_element
613 Usage : if( $eventgenerator->in_element($element) ) {}
614 Function: Test if we are in a particular element
615 This is different than 'in' because within can be tested
616 for a whole block.
617 Returns : boolean
618 Args : string element name
619  
620  
621 =cut
622  
623 82 ▶sub in_element {
Subroutine in_element: called CC=2 SCAR=7.1
Pod documented
624 82 my ( $self, $name ) = @_;
625 82 ▶ return 0 if !defined $self->{'_elements'}->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_elements"}[0] 0 82 82
626 82 return ( $self->{'_elements'}->[0] eq $name );
627 }
628  
629 =head2 start_document
630  
631 Title : start_document
632 Usage : $eventgenerator->start_document
633 Function: Handles a start document event
634 Returns : none
635 Args : none
636  
637  
638 =cut
639  
640 0 ▶sub start_document {
Subroutine start_document: not called CC=1 SCAR=6.9
Pod documented
641 0 my ($self) = @_;
642 0 $self->{'_lasttype'} = '';
643 0 $self->{'_values'} = {};
644 0 $self->{'_result'} = undef;
645 0 $self->{'_mode'} = '';
646 0 $self->{'_elements'} = [];
647 }
648  
649 =head2 end_document
650  
651 Title : end_document
652 Usage : $eventgenerator->end_document
653 Function: Handles an end document event
654 Returns : Bio::Search::Result::ResultI object
655 Args : none
656  
657  
658 =cut
659  
660 2 ▶sub end_document {
Subroutine end_document: called CC=1 SCAR=0.0
Pod documented
661 2 my ( $self, @args ) = @_;
662 2 return $self->{'_result'};
663 }
664  
665 =head2 result_count
666  
667 Title : result_count
668 Usage : my $count = $searchio->result_count
669 Function: Returns the number of results we have processed
670 Returns : integer
671 Args : none
672  
673  
674 =cut
675  
676 0 ▶sub result_count {
Subroutine result_count: not called CC=1 SCAR=6.9
Pod documented
677 0 my $self = shift;
678 0 return $self->{'_result_count'};
679 }
680  
681 0 ▶sub report_count { shift->result_count }
Subroutine report_count: not called CC=1 SCAR=6.9
Pod undocumented
682  
683 =head2 program_name
684  
685 Title : program_name
686 Usage : $obj->program_name($newval)
687 Function: Get/Set the program name
688 Returns : value of program_name (a scalar)
689 Args : on set, new value (a scalar or undef, optional)
690  
691  
692 =cut
693  
694 5 ▶sub program_name {
Subroutine program_name: called CC=3 SCAR=11.4
Pod documented
695 5 my $self = shift;
696  
697 5 ▶ $self->{'program_name'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 3 2 5
698 5 ▶ return $self->{'program_name'} || $DefaultProgramName;
Condition33%1/3
$self->{'program_name'} || $Bio::SearchIO::psl::DefaultProgramName
l!l&&r!l&&!r
500
MC/DC0%0/2
$self->{'program_name'} || $Bio::SearchIO::psl::DefaultProgramName
$self->{'program_name'} $Bio::SearchIO::psl::DefaultProgramName
Truth table33%1/3
A || B
A= $self->{'program_name'}B= $Bio::SearchIO::psl::DefaultProgramName
ABresult
1X1
011
000
699 }
700  
701 2 1;
« Bio/AlignIO/arp.pm ↑ Summary Bio/Search/Tiling/MapTiling.pm »