lib/Bio/SearchIO/hmmer2.pm

filter: Statementstmt 92.0% 302 / 328 Branchbran 81.8% 162 / 198 Conditioncond 84.6% 66 / 78 MC/DCmcdc 75.0% 33 / 44 Subroutinesub 93.3% 14 / 15 Podpod 100% 10 / 10 totaltotal 87.2% 587 / 673 CC 129 SCAR 44.4
CC
129
Cov
88%
next_result
119.8
end_element
17.3
within_element
6.9
CRAP 85.0
« lib/Bio/SearchIO/hmmer3.pm ↑ Summary lib/Bio/Tools/Hmmpfam.pm »
1 #
2 # BioPerl module for Bio::SearchIO::hmmer2
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 =head1 NAME
15  
16 Bio::SearchIO::hmmer2 - A parser for HMMER output (hmmpfam, hmmsearch)
17  
18 =head1 SYNOPSIS
19  
20 # do not use this class directly it is available through Bio::SearchIO
21 use Bio::SearchIO;
22 my $in = Bio::SearchIO->new(-format => 'hmmer2',
23 -file => 't/data/L77119.hmmer');
24 while( my $result = $in->next_result ) {
25 # this is a Bio::Search::Result::HMMERResult object
26 print $result->query_name(), " for HMM ", $result->hmm_name(), "\n";
27 while( my $hit = $result->next_hit ) {
28 print $hit->name(), "\n";
29 while( my $hsp = $hit->next_hsp ) {
30 print "length is ", $hsp->length(), "\n";
31 }
32 }
33 }
34  
35 =head1 DESCRIPTION
36  
37 This object implements a parser for HMMER output.
38  
39 =head1 FEEDBACK
40  
41 =head2 Mailing Lists
42  
43 User feedback is an integral part of the evolution of this and other
44 Bioperl modules. Send your comments and suggestions preferably to
45 the Bioperl mailing list. Your participation is much appreciated.
46  
47 bioperl-l@bioperl.org - General discussion
48 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49  
50 =head2 Support
51  
52 Please direct usage questions or support issues to the mailing list:
53  
54 I<bioperl-l@bioperl.org>
55  
56 rather than to the module maintainer directly. Many experienced and
57 reponsive experts will be able look at the problem and quickly
58 address it. Please include a thorough description of the problem
59 with code and data examples if at all possible.
60  
61 =head2 Reporting Bugs
62  
63 Report bugs to the Bioperl bug tracking system to help us keep track
64 of the bugs and their resolution. Bug reports can be submitted via the
65 web:
66  
67 https://github.com/bioperl/bioperl-live/issues
68  
69 =head1 AUTHOR - Jason Stajich
70  
71 Email jason-at-bioperl.org
72  
73 =head1 APPENDIX
74  
75 The rest of the documentation details each of the object methods.
76 Internal methods are usually preceded with a _
77  
78 =cut
79  
80 # Let the code begin...
81  
82 package Bio::SearchIO::hmmer2;
83 3 $Bio::SearchIO::hmmer2::VERSION = '1.7.3';
84 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 3 ▶use Bio::Factory::ObjectFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 3 ▶use vars qw(%MAPPING %MODEMAP
Subroutine BEGIN: called CC=1 SCAR=0.0
89 3 );
90  
91 3 ▶use base qw(Bio::SearchIO::hmmer);
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95 # mapping of HMMER items to Bioperl hash keys
96 3 %MODEMAP = (
97 'HMMER_Output' => 'result',
98 'Hit' => 'hit',
99 'Hsp' => 'hsp'
100 );
101  
102 3 %MAPPING = (
103 'Hsp_bit-score' => 'HSP-bits',
104 'Hsp_score' => 'HSP-score',
105 'Hsp_evalue' => 'HSP-evalue',
106 'Hsp_query-from' => 'HSP-query_start',
107 'Hsp_query-to' => 'HSP-query_end',
108 'Hsp_hit-from' => 'HSP-hit_start',
109 'Hsp_hit-to' => 'HSP-hit_end',
110 'Hsp_positive' => 'HSP-conserved',
111 'Hsp_identity' => 'HSP-identical',
112 'Hsp_gaps' => 'HSP-hsp_gaps',
113 'Hsp_hitgaps' => 'HSP-hit_gaps',
114 'Hsp_querygaps' => 'HSP-query_gaps',
115 'Hsp_qseq' => 'HSP-query_seq',
116 'Hsp_csline' => 'HSP-cs_seq',
117 'Hsp_hseq' => 'HSP-hit_seq',
118 'Hsp_midline' => 'HSP-homology_seq',
119 'Hsp_align-len' => 'HSP-hsp_length',
120 'Hsp_query-frame' => 'HSP-query_frame',
121 'Hsp_hit-frame' => 'HSP-hit_frame',
122  
123 'Hit_id' => 'HIT-name',
124 'Hit_len' => 'HIT-length',
125 'Hit_accession' => 'HIT-accession',
126 'Hit_desc' => 'HIT-description',
127 'Hit_signif' => 'HIT-significance',
128 'Hit_score' => 'HIT-score',
129  
130 'HMMER_program' => 'RESULT-algorithm_name',
131 'HMMER_version' => 'RESULT-algorithm_version',
132 'HMMER_query-def' => 'RESULT-query_name',
133 'HMMER_query-len' => 'RESULT-query_length',
134 'HMMER_query-acc' => 'RESULT-query_accession',
135 'HMMER_querydesc' => 'RESULT-query_description',
136 'HMMER_hmm' => 'RESULT-hmm_name',
137 'HMMER_seqfile' => 'RESULT-sequence_file',
138 'HMMER_db' => 'RESULT-database_name',
139 );
140 }
141  
142 =head2 next_result
143  
144 Title : next_result
145 Usage : my $hit = $searchio->next_result;
146 Function: Returns the next Result from a search
147 Returns : Bio::Search::Result::ResultI object
148 Args : none
149  
150 =cut
151  
152 20 ▶sub next_result {
Subroutine next_result: called CC=98 SCAR=47.9
Pod documented
153 20 my ($self) = @_;
154 20 my $seentop = 0;
155 20 my $reporttype;
156 20 my ( $buffer, $last, @hitinfo, @hspinfo, %hspinfo, %hitinfo );
157 20 local $/ = "\n";
158  
159 20 my $verbose = $self->verbose; # cache for speed?
160 20 $self->start_document();
161  
162 20 ▶ while ( defined( $buffer = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($buffer = $self->_readline)) 478 3 481
163 478 my $lineorig = $buffer;
164  
165 478 chomp $buffer;
166 478 ▶ if ($buffer =~ /^HMMER\s+(\S+)\s+\((.+)\)/o) {
Branch: 7 branches
BranchTrueFalseTotal
if ($buffer =~ /^HMMER\s+(\S+)\s+\((.+)\)/o) { } 17 461 478
elsif ($buffer =~ s/^HMM file:\s+//o) { } 17 444 461
elsif ($buffer =~ s/^Sequence\s+(file|database):\s+//o) { } 17 427 444
elsif ($buffer =~ s/^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:\s+//o) { } 18 409 427
elsif ($buffer =~ s/^Accession:\s+//o) { } 9 400 409
elsif ($buffer =~ s/^Description:\s+//o) { } 9 391 400
elsif (defined $self->{'_reporttype'} and $self->{'_reporttype'} eq 'HMMSEARCH' || $self->{'_reporttype'} eq 'HMMPFAM') { } 375 16 391
167 17 my ( $prog, $version ) = split( /\s+/, $buffer );
168 17 ▶ if ($seentop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seentop) 0 17 17
169 0 $self->_pushback($buffer);
170 0 $self->end_element( { 'Name' => 'HMMER_Output' } );
171 0 return $self->end_document();
172 }
173 17 $self->{'_hmmidline'} = $buffer;
174 17 $self->start_element( { 'Name' => 'HMMER_Output' } );
175 17 $self->{'_result_count'}++;
176 17 $seentop = 1;
177 17 ▶ if ( defined $last ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last) 17 0 17
178 17 ($reporttype) = split( /\s+/, $last );
179 17 ▶ $reporttype = uc($reporttype) if defined $reporttype;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reporttype 16 1 17
180 17 $self->element(
181 {
182 'Name' => 'HMMER_program',
183 'Data' => $reporttype
184 }
185 );
186 }
187 $self->element(
188 {
189 17 'Name' => 'HMMER_version',
190 'Data' => $version
191 }
192 );
193 }
194 elsif ($buffer =~ s/^HMM file:\s+//o) {
195 17 $self->{'_hmmfileline'} = $lineorig;
196 17 $self->element(
197 {
198 'Name' => 'HMMER_hmm',
199 'Data' => $buffer
200 }
201 );
202 }
203 elsif ($buffer =~ s/^Sequence\s+(file|database):\s+//o) {
204 17 $self->{'_hmmseqline'} = $lineorig;
205 17 ▶ if ( $1 eq 'database' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq "database") 5 12 17
206 5 $self->element(
207 {
208 'Name' => 'HMMER_db',
209 'Data' => $buffer
210 }
211 );
212 }
213 $self->element(
214 {
215 17 'Name' => 'HMMER_seqfile',
216 'Data' => $buffer
217 }
218 );
219 }
220 elsif ($buffer =~ s/^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:\s+//o) {
221 18 ▶ if ( !$seentop ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seentop) 1 17 18
222  
223 # we're in a multi-query report
224 1 $self->_pushback($lineorig);
225 1 $self->_pushback( $self->{'_hmmseqline'} );
226 1 $self->_pushback( $self->{'_hmmfileline'} );
227 1 $self->_pushback( $self->{'_hmmidline'} );
228 1 next;
229 }
230 17 $buffer =~ s/\s+$//;
231 17 $self->element(
232 {
233 'Name' => 'HMMER_query-def',
234 'Data' => $buffer
235 }
236 );
237 }
238 elsif ($buffer =~ s/^Accession:\s+//o) {
239 9 $buffer =~ s/\s+$//;
240 9 $self->element(
241 {
242 'Name' => 'HMMER_query-acc',
243 'Data' => $buffer
244 }
245 );
246 }
247 elsif ($buffer =~ s/^Description:\s+//o) {
248 9 $buffer =~ s/\s+$//;
249 9 $self->element(
250 {
251 'Name' => 'HMMER_querydesc',
252 'Data' => $buffer
253 }
254 );
255 }
256 ▶ elsif ( defined $self->{'_reporttype'}
Condition83%5/6
defined $self->{"_reporttype"} and $self->{"_reporttype"} eq "HMMSEARCH" || $self->{"_reporttype"} eq "HMMPFAM"
!ll&&!rl&&r
016375
$self->{"_reporttype"} eq "HMMSEARCH" or $self->{"_reporttype"} eq "HMMPFAM"
l!l&&r!l&&!r
26211316
MC/DC66%2/3
defined $self->{"_reporttype"} and $self->{"_reporttype"} eq "HMMSEARCH" || $self->{"_reporttype"} eq "HMMPFAM"
defined $self->{"_reporttype"} $self->{"_reporttype"} eq "HMMSEARCH" $self->{"_reporttype"} eq "HMMPFAM"
Truth table75%3/4
A and B or C
A= defined $self->{"_reporttype"}B= $self->{"_reporttype"} eq "HMMSEARCH"C= $self->{"_reporttype"} eq "HMMPFAM"
ABCresult
0XX0
1000
11X1
1011
257 && ( $self->{'_reporttype'} eq 'HMMSEARCH'
258 || $self->{'_reporttype'} eq 'HMMPFAM' )
259 ) {
260 # PROCESS RESULTS HERE
261 375 ▶ if ($buffer =~ /^Scores for (?:complete sequences|sequence family)/o) {
Branch: 4 branches
BranchTrueFalseTotal
if ($buffer =~ /^Scores for (?:complete sequences|sequence family)/o) { } 17 358 375
elsif ($buffer =~ /^Parsed for domains:/o) { } 17 341 358
elsif ($buffer =~ /^Alignments of top/o) { } 13 328 341
elsif ($buffer =~ /^Histogram/o or $buffer =~ m[^//]o) { } 17 311 328
262 17 ▶ while ( defined( $buffer = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($buffer = $self->_readline)) 3177 0 3177
263 3177 ▶ last if ($buffer =~ /^\s+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $buffer =~ /^\s+$/ 17 3160 3177
264 3160 ▶ next if ( $buffer =~ /^Model\s+Description/o
Branch: 1 branch
BranchTrueFalseTotal
if $buffer =~ /^Model\s+Description/o or $buffer =~ /^Sequence\s+Description/o or $buffer =~ /^\-\-\-/o 34 3126 3160
Condition100%6/6
$buffer =~ /^Model\s+Description/o or $buffer =~ /^Sequence\s+Description/o or $buffer =~ /^\-\-\-/o
l!l&&r!l&&!r
17173126
$buffer =~ /^Model\s+Description/o or $buffer =~ /^Sequence\s+Description/o
l!l&&r!l&&!r
1253143
MC/DC100%3/3
$buffer =~ /^Model\s+Description/o or $buffer =~ /^Sequence\s+Description/o or $buffer =~ /^\-\-\-/o
$buffer =~ /^Model\s+Description/o $buffer =~ /^Sequence\s+Description/o $buffer =~ /^\-\-\-/o
Truth table100%4/4
A or B or C
A= $buffer =~ /^Model\s+Description/oB= $buffer =~ /^Sequence\s+Description/oC= $buffer =~ /^\-\-\-/o
ABCresult
1XX1
01X1
0011
0000
265 || $buffer =~ /^Sequence\s+Description/o
266 || $buffer =~ /^\-\-\-/o );
267  
268 3126 chomp $buffer;
269 3126 my @line = split( /\s+/, $buffer );
270 3126 my ( $name, $domaintotal, $evalue, $score ) =
271 ( shift @line, pop @line, pop @line, pop @line );
272 3126 my $desc = join( ' ', @line );
273 3126 push @hitinfo, [ $name, $desc, $score, $evalue, $domaintotal ];
274 3126 $hitinfo{$name} = $#hitinfo;
275 }
276 }
277 elsif ($buffer =~ /^Parsed for domains:/o) {
278 17 @hspinfo = ();
279  
280 17 ▶ while ( defined( $buffer = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($buffer = $self->_readline)) 5039 0 5039
281 5039 ▶ last if ($buffer =~ /^\s+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $buffer =~ /^\s+$/ 17 5022 5039
282 5022 ▶ if ($buffer =~ m!^//!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ m[^//]) 0 5022 5022
283 0 $self->_pushback($buffer);
284 0 last;
285 }
286 5022 ▶ next if ( $buffer =~ /^(?:Model|Sequence)\s+Domain/ || $buffer =~ /^\-\-\-/ );
Branch: 1 branch
BranchTrueFalseTotal
if $buffer =~ /^(?:Model|Sequence)\s+Domain/ or $buffer =~ /^\-\-\-/ 34 4988 5022
Condition100%3/3
$buffer =~ /^(?:Model|Sequence)\s+Domain/ or $buffer =~ /^\-\-\-/
l!l&&r!l&&!r
17174988
MC/DC100%2/2
$buffer =~ /^(?:Model|Sequence)\s+Domain/ or $buffer =~ /^\-\-\-/
$buffer =~ /^(?:Model|Sequence)\s+Domain/ $buffer =~ /^\-\-\-/
Truth table100%3/3
A or B
A= $buffer =~ /^(?:Model|Sequence)\s+Domain/B= $buffer =~ /^\-\-\-/
ABresult
1X1
011
000
287  
288 4988 chomp $buffer;
289 4988 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (() = $buffer =~ m[^(\S+)\s+ # domain name (\d+)/(\d+)\s+ # domain num out of num (\d+)\s+(\d+)\s+ # seq start, end (\S+)\s+ # seq coverage (\d+)\s+(\d+)\s+ # hmm start, end (\S+)\s+ # hmm coverage (\S+)\s+ # score (\S+) # evalue \s*$]ox) 4988 0 4988
290 my ( $name, $domainct, $domaintotal,
291 $seq_start, $seq_end, $seq_cov,
292 $hmm_start, $hmm_end, $hmm_cov,
293 $score, $evalue )
294 = ( $buffer =~
295 m!^(\S+)\s+ # domain name
296 (\d+)/(\d+)\s+ # domain num out of num
297 (\d+)\s+(\d+)\s+ # seq start, end
298 (\S+)\s+ # seq coverage
299 (\d+)\s+(\d+)\s+ # hmm start, end
300 (\S+)\s+ # hmm coverage
301 (\S+)\s+ # score
302 (\S+) # evalue
303 \s*$!ox
304 )
305 ) {
306 4988 my $hindex = $hitinfo{$name};
307 4988 ▶ if ( !defined $hindex ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $hindex) 0 4988 4988
308 0 push @hitinfo,
309 [ $name, '', $score, $evalue, $domaintotal ];
310 0 $hitinfo{$name} = $#hitinfo;
311 0 $hindex = $#hitinfo;
312 }
313  
314 4988 my $info = $hitinfo[$hindex];
315 4988 ▶ if ( !defined $info ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $info) 0 4988 4988
316 0 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 0 0 0
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 0 0 0
317 0 $self->warn(
318 "Incomplete Sequence information, can't find $name hitinfo says $hitinfo{$name}"
319 );
320 }
321 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
322 0 $self->warn(
323 "Incomplete Domain information, can't find $name hitinfo says $hitinfo{$name}"
324 );
325 }
326 0 next;
327 }
328  
329 # Try to get HMM and Sequence lengths from the alignment information
330 4988 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 4864 124 4988
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 124 0 124
331 # For Hmmsearch, if seq coverage ends in ']' it means that the alignment
332 # runs until the end. In that case add the END coordinate to @hitinfo
333 # to use it as Hit Length
334 4864 ▶ if ( $seq_cov =~ m/\]$/
Branch: 1 branch
BranchTrueFalseTotal
if ($seq_cov =~ /\]$/ and scalar @{$hitinfo[$hindex];} == 5) 48 4816 4864
Condition66%2/3
$seq_cov =~ /\]$/ and scalar @{$hitinfo[$hindex];} == 5
!ll&&!rl&&r
4816048
MC/DC50%1/2
$seq_cov =~ /\]$/ and scalar @{$hitinfo[$hindex];} == 5
$seq_cov =~ /\]$/ scalar @{$hitinfo[$hindex];} == 5
Truth table66%2/3
A and B
A= $seq_cov =~ /\]$/B= scalar @{$hitinfo[$hindex];} == 5
ABresult
0X0
100
111
335 48 and scalar @{ $hitinfo[$hindex] } == 5
336 ) {
337 48 push @{ $hitinfo[$hindex] }, $seq_end ;
338 }
339 # For Hmmsearch, if hmm coverage ends in ']', it means that the alignment
340 # runs until the end. In that case use the END coordinate as Query Length
341 4864 ▶ if ( $hmm_cov =~ m/\]$/
Branch: 1 branch
BranchTrueFalseTotal
if ($hmm_cov =~ /\]$/ and not exists $self->{"_values"}{"RESULT-query_length"}) 5 4859 4864
Condition66%2/3
$hmm_cov =~ /\]$/ and not exists $self->{"_values"}{"RESULT-query_length"}
!ll&&!rl&&r
048595
MC/DC50%1/2
$hmm_cov =~ /\]$/ and not exists $self->{"_values"}{"RESULT-query_length"}
$hmm_cov =~ /\]$/ not exists $self->{"_values"}{"RESULT-query_length"}
Truth table66%2/3
A and not(B)
A= $hmm_cov =~ /\]$/B= not exists $self->{"_values"}{"RESULT-query_length"}
ABresult
0X0
100
111
342 and not exists $self->{_values}->{'RESULT-query_length'}
343 ) {
344 5 $self->element(
345 { 'Name' => 'HMMER_query-len',
346 'Data' => $hmm_end
347 }
348 );
349 }
350 }
351 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
352 # For Hmmpfam, if hmm coverage ends in ']' it means that the alignment
353 # runs until the end. In that case add the END coordinate to @hitinfo
354 # to use it as Hit Length
355 124 ▶ if ( $hmm_cov =~ m/\]$/
Branch: 1 branch
BranchTrueFalseTotal
if ($hmm_cov =~ /\]$/ and scalar @{$hitinfo[$hindex];} == 5) 70 54 124
Condition100%3/3
$hmm_cov =~ /\]$/ and scalar @{$hitinfo[$hindex];} == 5
!ll&&!rl&&r
50470
MC/DC100%2/2
$hmm_cov =~ /\]$/ and scalar @{$hitinfo[$hindex];} == 5
$hmm_cov =~ /\]$/ scalar @{$hitinfo[$hindex];} == 5
Truth table100%3/3
A and B
A= $hmm_cov =~ /\]$/B= scalar @{$hitinfo[$hindex];} == 5
ABresult
0X0
100
111
356 74 and scalar @{ $hitinfo[$hindex] } == 5
357 ) {
358 70 push @{ $hitinfo[$hindex] }, $hmm_end ;
359 }
360 # For Hmmpfam, if seq coverage ends in ']', it means that the alignment
361 # runs until the end. In that case use the END coordinate as Query Length
362 124 ▶ if ( $seq_cov =~ m/\]$/
Branch: 1 branch
BranchTrueFalseTotal
if ($seq_cov =~ /\]$/ and not exists $self->{"_values"}{"RESULT-query_length"}) 2 122 124
Condition66%2/3
$seq_cov =~ /\]$/ and not exists $self->{"_values"}{"RESULT-query_length"}
!ll&&!rl&&r
12202
MC/DC50%1/2
$seq_cov =~ /\]$/ and not exists $self->{"_values"}{"RESULT-query_length"}
$seq_cov =~ /\]$/ not exists $self->{"_values"}{"RESULT-query_length"}
Truth table66%2/3
A and not(B)
A= $seq_cov =~ /\]$/B= not exists $self->{"_values"}{"RESULT-query_length"}
ABresult
0X0
100
111
363 and not exists $self->{_values}->{'RESULT-query_length'}
364 ) {
365 2 $self->element(
366 { 'Name' => 'HMMER_query-len',
367 'Data' => $seq_end
368 }
369 );
370 }
371 }
372  
373 4988 my @vals = ($seq_start, $seq_end,
374 $hmm_start, $hmm_end,
375 $score, $evalue);
376 4988 push @hspinfo, [ $name, @vals ];
377 }
378 }
379 }
380 elsif ($buffer =~ /^Alignments of top/o) {
381 13 my ( $prelength, $count, $width );
382 13 $count = 0;
383 13 my %domaincounter;
384 13 my $second_tier = 0;
385 13 my $csline = '';
386  
387 13 ▶ while ( defined( $buffer = $self->_readline ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($buffer = $self->_readline)) 1254 0 1254
388 1254 ▶ next if ( $buffer =~ /^Align/o );
Branch: 1 branch
BranchTrueFalseTotal
if $buffer =~ /^Align/o 0 1254 1254
389  
390 1254 ▶ if ( $buffer =~ m/^Histogram/o
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /^Histogram/o or $buffer =~ m[^//]o or $buffer =~ /^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:/o) 13 1241 1254
Condition83%5/6
$buffer =~ /^Histogram/o or $buffer =~ m[^//]o or $buffer =~ /^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:/o
l!l&&r!l&&!r
1301241
$buffer =~ /^Histogram/o or $buffer =~ m[^//]o
l!l&&r!l&&!r
1121241
MC/DC66%2/3
$buffer =~ /^Histogram/o or $buffer =~ m[^//]o or $buffer =~ /^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:/o
$buffer =~ /^Histogram/o $buffer =~ m[^//]o $buffer =~ /^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:/o
Truth table75%3/4
A or B or C
A= $buffer =~ /^Histogram/oB= $buffer =~ m[^//]oC= $buffer =~ /^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:/o
ABCresult
1XX1
01X1
0011
0000
391 || $buffer =~ m!^//!o
392 || $buffer =~ m/^Query(?:\s+(?:sequence|HMM))?(?:\s+\d+)?:/o
393 ) {
394 13 ▶ if ( $self->in_element('hsp') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->in_element("hsp")) 13 0 13
395 13 $self->end_element( { 'Name' => 'Hsp' } );
396 }
397 13 ▶ if ( $self->within_element('hit') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->within_element("hit")) 13 0 13
398 13 $self->end_element( { 'Name' => 'Hit' } );
399 }
400 13 $self->_pushback($buffer);
401 13 last;
402 }
403  
404 1241 chomp $buffer;
405 1241 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (() = $buffer =~ /^\s*(.+): \s+ domain \s+ (\d+) \s+ of \s+ (\d+) , \s+ from \s+ (\d+) \s+ to \s+ (\d+)/x) { } 128 1113 1241
406 my ( $name, $domainct, $domaintotal,
407 $from, $to )
408 = ( $buffer =~
409 m/^\s*(.+):
410 \s+ domain \s+ (\d+) \s+ of \s+ (\d+) ,
411 \s+ from \s+ (\d+) \s+ to \s+ (\d+)/x
412 )
413 ) {
414 128 $domaincounter{$name}++;
415 128 ▶ if ( $self->within_element('hit') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->within_element("hit")) 115 13 128
416 115 ▶ if ( $self->within_element('hsp') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->within_element("hsp")) 115 0 115
417 115 $self->end_element( { 'Name' => 'Hsp' } );
418 }
419 115 $self->end_element( { 'Name' => 'Hit' } );
420 }
421  
422 128 my $info = [ @{ $hitinfo[ $hitinfo{$name} ] } ];
423 128 ▶ if ( !defined $info
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $info or $info->[0] ne $name) 0 128 128
Condition33%1/3
not defined $info or $info->[0] ne $name
l!l&&r!l&&!r
00128
MC/DC0%0/2
not defined $info or $info->[0] ne $name
not defined $info $info->[0] ne $name
Truth table33%1/3
not(A) or B
A= not defined $infoB= $info->[0] ne $name
ABresult
1X1
011
000
424 || $info->[0] ne $name
425 ) {
426 0 $self->warn(
427 "Somehow the Model table order does not match the order in the domains (got "
428 . $info->[0]
429 . ", expected $name). We're back loading this from the alignment information instead"
430 );
431 0 $info = [
432 $name, '',
433 $buffer =~ /score \s+ ([^,\s]+), \s+E\s+=\s+ (\S+)/ox,
434 $domaintotal
435 ];
436 0 push @hitinfo, $info;
437 0 $hitinfo{$name} = $#hitinfo;
438 }
439  
440 128 $self->start_element( { 'Name' => 'Hit' } );
441 $self->element(
442 {
443 'Name' => 'Hit_id',
444 128 'Data' => shift @{$info}
445 }
446 );
447 $self->element(
448 {
449 'Name' => 'Hit_desc',
450 128 'Data' => shift @{$info}
451 }
452 );
453 $self->element(
454 {
455 'Name' => 'Hit_score',
456 128 'Data' => shift @{$info}
457 }
458 );
459 $self->element(
460 {
461 'Name' => 'Hit_signif',
462 128 'Data' => shift @{$info}
463 }
464 );
465 128 my $dom_total = shift @{$info};
466 128 ▶ if (my $hit_end = shift @{$info}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hit_end = shift @{$info;}) 76 52 128
467 76 $self->element(
468 {
469 'Name' => 'Hit_len',
470 'Data' => $hit_end
471 }
472 );
473 }
474  
475 128 $self->start_element( { 'Name' => 'Hsp' } );
476 128 my $HSPinfo = shift @hspinfo;
477 128 my $id = shift @$HSPinfo;
478  
479 128 ▶ if ( $id ne $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id ne $name) 0 128 128
480 0 $self->throw(
481 "Somehow the domain list details do not match "
482 . "the table (got $id, expected $name)"
483 );
484 }
485  
486 128 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 4 124 128
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 124 0 124
487 4 $self->element(
488 {
489 'Name' => 'Hsp_hit-from',
490 'Data' => shift @$HSPinfo
491 }
492 );
493 4 $self->element(
494 {
495 'Name' => 'Hsp_hit-to',
496 'Data' => shift @$HSPinfo
497 }
498 );
499 4 $self->element(
500 {
501 'Name' => 'Hsp_query-from',
502 'Data' => shift @$HSPinfo
503 }
504 );
505 4 $self->element(
506 {
507 'Name' => 'Hsp_query-to',
508 'Data' => shift @$HSPinfo
509 }
510 );
511 }
512 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
513 124 $self->element(
514 {
515 'Name' => 'Hsp_query-from',
516 'Data' => shift @$HSPinfo
517 }
518 );
519 124 $self->element(
520 {
521 'Name' => 'Hsp_query-to',
522 'Data' => shift @$HSPinfo
523 }
524 );
525 124 $self->element(
526 {
527 'Name' => 'Hsp_hit-from',
528 'Data' => shift @$HSPinfo
529 }
530 );
531 124 $self->element(
532 {
533 'Name' => 'Hsp_hit-to',
534 'Data' => shift @$HSPinfo
535 }
536 );
537 }
538 $self->element(
539 {
540 128 'Name' => 'Hsp_score',
541 'Data' => shift @$HSPinfo
542 }
543 );
544 128 $self->element(
545 {
546 'Name' => 'Hsp_evalue',
547 'Data' => shift @$HSPinfo
548 }
549 );
550  
551 128 ▶ if ( $domaincounter{$name} == $domaintotal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($domaincounter{$name} == $domaintotal) 122 6 128
552 122 $hitinfo[ $hitinfo{$name} ] = undef;
553 }
554 }
555 else {
556  
557 # Might want to change this so that it
558 # accumulates all the of the alignment lines into
559 # three array slots and then tests for the
560 # end of the line
561 1113 ▶ if ($buffer =~ m/^\s+(?:CS|RF)\s+/o && $count == 0) {
Branch: 7 branches
BranchTrueFalseTotal
if ($buffer =~ /^\s+(?:CS|RF)\s+/o and $count == 0) { } 104 1009 1113
elsif ($buffer =~ /^(\s+ \*->) (\S+)/ox) { } 128 881 1009
elsif ($buffer =~ /^(\s+) (\S+) <-?\*? \s*$/ox) { } 26 855 881
elsif ($count != 1 and $buffer =~ /^\s+$/o or length $buffer == 0 or $buffer =~ /^\s+\-?\*\s*$/ or $buffer =~ /^\s+\S+\s+\-\s+\-\s*$/) { } 259 596 855
elsif ($count == 0) { } 96 500 596
elsif ($count == 1) { } 250 250 500
elsif ($count == 2) { } 250 0 250
Condition66%2/3
$buffer =~ /^\s+(?:CS|RF)\s+/o and $count == 0
!ll&&!rl&&r
10090104
MC/DC50%1/2
$buffer =~ /^\s+(?:CS|RF)\s+/o and $count == 0
$buffer =~ /^\s+(?:CS|RF)\s+/o $count == 0
Truth table66%2/3
A and B
A= $buffer =~ /^\s+(?:CS|RF)\s+/oB= $count == 0
ABresult
0X0
100
111
562 # Buffer the CS line now and process it later at
563 # midline point, where $prelength and width will be known
564 104 $csline = $buffer;
565 104 next;
566 }
567 elsif ($buffer =~ /^(\s+ \*->) (\S+)/ox) {
568 # start of domain
569 128 $prelength = CORE::length($1);
570 128 $width = 0;
571  
572 # deal with fact that start and stop is on same line
573 128 my $data = $2;
574 128 ▶ if ($data =~ s/<-?\*?\s*$//)
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/<-?\*?\s*$//) 102 26 128
575 {
576 102 $width = CORE::length($data);
577 }
578  
579 128 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 4 124 128
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 124 0 124
580 4 $self->element(
581 {
582 'Name' => 'Hsp_qseq',
583 'Data' => $data
584 }
585 );
586 }
587 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
588 124 $self->element(
589 {
590 'Name' => 'Hsp_hseq',
591 'Data' => $data
592 }
593 );
594 }
595 128 $count = 0;
596 128 $second_tier = 0;
597 }
598 elsif ($buffer =~ /^(\s+) (\S+) <-?\*? \s*$/ox) {
599 # end of domain
600 26 ▶ $prelength -= 3 unless ( $second_tier++ );
Branch: 1 branch
BranchTrueFalseTotal
unless $second_tier++ 10 16 26
601 26 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 4 22 26
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 22 0 22
602 4 $self->element(
603 {
604 'Name' => 'Hsp_qseq',
605 'Data' => $2
606 }
607 );
608 }
609 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
610 22 $self->element(
611 {
612 'Name' => 'Hsp_hseq',
613 'Data' => $2
614 }
615 );
616 }
617 26 $width = CORE::length($2);
618 26 $count = 0;
619 }
620 ▶ elsif ( ( $count != 1 && $buffer =~ /^\s+$/o )
Condition100%12/12
$count != 1 and $buffer =~ /^\s+$/o or length $buffer == 0 or $buffer =~ /^\s+\-?\*\s*$/ or $buffer =~ /^\s+\S+\s+\-\s+\-\s*$/
l!l&&r!l&&!r
2572596
$count != 1 and $buffer =~ /^\s+$/o or length $buffer == 0 or $buffer =~ /^\s+\-?\*\s*$/
l!l&&r!l&&!r
2552598
$count != 1 and $buffer =~ /^\s+$/o or length $buffer == 0
l!l&&r!l&&!r
2253600
$count != 1 and $buffer =~ /^\s+$/o
!ll&&!rl&&r
2506032
MC/DC100%5/5
$count != 1 and $buffer =~ /^\s+$/o or length $buffer == 0 or $buffer =~ /^\s+\-?\*\s*$/ or $buffer =~ /^\s+\S+\s+\-\s+\-\s*$/
$count != 1 $buffer =~ /^\s+$/o length $buffer == 0 $buffer =~ /^\s+\-?\*\s*$/ $buffer =~ /^\s+\S+\s+\-\s+\-\s*$/
Truth table66%6/9
A and B or C or D or E
A= $count != 1B= $buffer =~ /^\s+$/oC= length $buffer == 0D= $buffer =~ /^\s+\-?\*\s*$/E= $buffer =~ /^\s+\S+\s+\-\s+\-\s*$/
ABCDEresult
11XXX1
0X1XX1
101XX1
0X01X1
1001X1
0X0011
100011
0X0000
100000
621 || CORE::length($buffer) == 0
622 || $buffer =~ /^\s+\-?\*\s*$/
623 || $buffer =~ /^\s+\S+\s+\-\s+\-\s*$/ )
624 {
625 259 next;
626 }
627 elsif ( $count == 0 ) {
628 96 ▶ $prelength -= 3 unless ( $second_tier++ );
Branch: 1 branch
BranchTrueFalseTotal
unless $second_tier++ 16 80 96
629 96 ▶ unless ( defined $prelength ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $prelength) 0 96 96
630  
631 # $self->warn("prelength not set");
632 0 next;
633 }
634 96 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 20 76 96
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 76 0 76
635 20 $self->element(
636 {
637 'Name' => 'Hsp_qseq',
638 'Data' => substr( $buffer, $prelength )
639 }
640 );
641 }
642 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
643 76 $self->element(
644 {
645 'Name' => 'Hsp_hseq',
646 'Data' => substr( $buffer, $prelength )
647 }
648 );
649 }
650 }
651 elsif ( $count == 1 ) {
652 250 ▶ if ( !defined $prelength ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $prelength) 0 250 250
653 0 $self->warn("prelength not set");
654 }
655 250 ▶ if ($width) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width) { } 128 122 250
656 128 $self->element(
657 {
658 'Name' => 'Hsp_midline',
659 'Data' => substr( $buffer, $prelength, $width )
660 }
661 );
662 128 ▶ if ($csline ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($csline ne "") 54 74 128
663 54 $self->element(
664 {
665 'Name' => 'Hsp_csline',
666 'Data' => substr( $csline, $prelength, $width )
667  
668 }
669 );
670 54 $csline = '';
671 }
672 }
673 else {
674 122 $self->element(
675 {
676 'Name' => 'Hsp_midline',
677 'Data' => substr( $buffer, $prelength )
678 }
679 );
680 122 ▶ if ($csline ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($csline ne "") 50 72 122
681 50 $self->element(
682 {
683 'Name' => 'Hsp_csline',
684 'Data' => substr( $csline, $prelength )
685 }
686 );
687 50 $csline = '';
688 }
689 }
690 }
691 elsif ( $count == 2 ) {
692 250 ▶ if ( $buffer =~ /^\s+(\S+)\s+(\d+|\-)\s+(\S*)\s+(\d+|\-)/o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer =~ /^\s+(\S+)\s+(\d+|\-)\s+(\S*)\s+(\d+|\-)/o) { } 250 0 250
693 250 ▶ if ($self->{'_reporttype'} eq 'HMMSEARCH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_reporttype'} eq 'HMMSEARCH') { } 28 222 250
elsif ($self->{'_reporttype'} eq 'HMMPFAM') { } 222 0 222
694 28 $self->element(
695 {
696 'Name' => 'Hsp_hseq',
697 'Data' => $3
698 }
699 );
700 }
701 elsif ($self->{'_reporttype'} eq 'HMMPFAM') {
702 222 $self->element(
703 {
704 'Name' => 'Hsp_qseq',
705 'Data' => $3
706 }
707 );
708 }
709 }
710 else {
711 0 $self->warn("unrecognized line ($count): $buffer\n");
712 }
713 }
714 750 ▶ $count = 0 if $count++ >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $count++ >= 2 250 500 750
715 }
716 }
717 }
718 ▶ elsif ( $buffer =~ /^Histogram/o || $buffer =~ m!^//!o ) {
Condition100%3/3
$buffer =~ /^Histogram/o or $buffer =~ m[^//]o
l!l&&r!l&&!r
512311
MC/DC100%2/2
$buffer =~ /^Histogram/o or $buffer =~ m[^//]o
$buffer =~ /^Histogram/o $buffer =~ m[^//]o
Truth table100%3/3
A or B
A= $buffer =~ /^Histogram/oB= $buffer =~ m[^//]o
ABresult
1X1
011
000
719 17 my %domaincounter;
720  
721 17 ▶ while ( my $HSPinfo = shift @hspinfo ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $HSPinfo = shift @hspinfo) 4860 17 4877
722 4860 my $id = shift @$HSPinfo;
723 4860 $domaincounter{$id}++;
724  
725 4860 my $info = [ @{ $hitinfo[ $hitinfo{$id} ] } ];
726 4860 ▶ next unless defined $info;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info 0 4860 4860
727  
728 4860 $self->start_element( { 'Name' => 'Hit' } );
729 $self->element(
730 {
731 'Name' => 'Hit_id',
732 4860 'Data' => shift @{$info}
733 }
734 );
735 $self->element(
736 {
737 'Name' => 'Hit_desc',
738 4860 'Data' => shift @{$info}
739 }
740 );
741 $self->element(
742 {
743 'Name' => 'Hit_score',
744 4860 'Data' => shift @{$info}
745 }
746 );
747 $self->element(
748 {
749 'Name' => 'Hit_signif',
750 4860 'Data' => shift @{$info}
751 }
752 );
753 4860 my $domaintotal = shift @{$info};
754 4860 ▶ if (my $hit_end = shift @{$info}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hit_end = shift @{$info;}) 56 4804 4860
755 56 $self->element(
756 {
757 'Name' => 'Hit_len',
758 'Data' => $hit_end
759 }
760 );
761 }
762  
763 # Histogram is exclusive of Hmmsearch, not found in Hmmpfam,
764 # so just use Hmmsearch start/end order (first hit, then query)
765 4860 $self->start_element( { 'Name' => 'Hsp' } );
766 4860 $self->element(
767 {
768 'Name' => 'Hsp_hit-from',
769 'Data' => shift @$HSPinfo
770 }
771 );
772 4860 $self->element(
773 {
774 'Name' => 'Hsp_hit-to',
775 'Data' => shift @$HSPinfo
776 }
777 );
778 4860 $self->element(
779 {
780 'Name' => 'Hsp_query-from',
781 'Data' => shift @$HSPinfo
782 }
783 );
784 4860 $self->element(
785 {
786 'Name' => 'Hsp_query-to',
787 'Data' => shift @$HSPinfo
788 }
789 );
790 4860 $self->element(
791 {
792 'Name' => 'Hsp_score',
793 'Data' => shift @$HSPinfo
794 }
795 );
796 4860 $self->element(
797 {
798 'Name' => 'Hsp_evalue',
799 'Data' => shift @$HSPinfo
800 }
801 );
802 4860 $self->end_element( { 'Name' => 'Hsp' } );
803 4860 $self->end_element( { 'Name' => 'Hit' } );
804  
805 4860 ▶ if ( $domaincounter{$id} == $domaintotal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($domaincounter{$id} == $domaintotal) 3004 1856 4860
806 3004 $hitinfo[ $hitinfo{$id} ] = undef;
807 }
808 }
809 17 @hitinfo = ();
810 17 %hitinfo = ();
811 17 last;
812 }
813 # uncomment to see missed lines with verbose on
814 #else {
815 # $self->debug($buffer);
816 #}
817 }
818 460 $last = $buffer;
819 }
820 20 ▶ $self->end_element( { 'Name' => 'HMMER_Output' } ) unless !$seentop;
Branch: 1 branch
BranchTrueFalseTotal
if $seentop 17 3 20
821 20 return $self->end_document();
822 }
823  
824 =head2 start_element
825  
826 Title : start_element
827 Usage : $eventgenerator->start_element
828 Function: Handles a start element event
829 Returns : none
830 Args : hashref with at least 2 keys 'Data' and 'Name'
831  
832  
833 =cut
834  
835 91030 ▶sub start_element {
Subroutine start_element: called CC=5 SCAR=16.1
Pod documented
836 91030 my ( $self, $data ) = @_;
837  
838 # we currently don't care about attributes
839 91030 my $nm = $data->{'Name'};
840 91030 my $type = $MODEMAP{$nm};
841 91030 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 9993 81037 91030
842 9993 ▶ if ( $self->_eventHandler->will_handle($type) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_eventHandler->will_handle($type)) 9993 0 9993
843 9993 my $func = sprintf( "start_%s", lc $type );
844 9993 $self->_eventHandler->$func( $data->{'Attributes'} );
845 }
846 9993 unshift @{ $self->{'_elements'} }, $type;
847 }
848 91030 ▶ if ( defined $type
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type and $type eq "result") 17 91013 91030
Condition100%3/3
defined $type and $type eq "result"
!ll&&!rl&&r
81037997617
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
849 && $type eq 'result' )
850 {
851 17 $self->{'_values'} = {};
852 17 $self->{'_result'} = undef;
853 }
854 }
855  
856 =head2 end_element
857  
858 Title : start_element
859 Usage : $eventgenerator->end_element
860 Function: Handles an end element event
861 Returns : none
862 Args : hashref with at least 2 keys 'Data' and 'Name'
863  
864  
865 =cut
866  
867 91030 ▶sub end_element {
Subroutine end_element: called CC=17 SCAR=28.5
Pod documented
868 91030 my ( $self, $data ) = @_;
869 91030 my $nm = $data->{'Name'};
870 91030 my $type = $MODEMAP{$nm};
871 91030 my $rc;
872  
873 91030 ▶ if ( $nm eq 'HMMER_program' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nm eq "HMMER_program") 17 91013 91030
874 17 ▶ if ( $self->{'_last_data'} =~ /(HMM\S+)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_last_data"} =~ /(HMM\S+)/i) 16 1 17
875 16 $self->{'_reporttype'} = uc $1;
876 }
877 }
878  
879 # Hsp are sort of weird, in that they end when another
880 # object begins so have to detect this in end_element for now
881 91030 ▶ if ( $nm eq 'Hsp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nm eq "Hsp") 4988 86042 91030
882 4988 foreach my $line (qw(Hsp_csline Hsp_qseq Hsp_midline Hsp_hseq)) {
883 19952 my $data = $self->{'_last_hspdata'}->{$line};
884 19952 ▶ if ($data && $line eq 'Hsp_hseq') {
Branch: 1 branch
BranchTrueFalseTotal
if ($data and $line eq "Hsp_hseq") 128 19824 19952
Condition100%3/3
$data and $line eq "Hsp_hseq"
!ll&&!rl&&r
19514310128
MC/DC100%2/2
$data and $line eq "Hsp_hseq"
$data $line eq "Hsp_hseq"
Truth table100%3/3
A and B
A= $dataB= $line eq "Hsp_hseq"
ABresult
0X0
100
111
885 # replace hmm '.' gap symbol by '-'
886 128 $data =~ s/\./-/g;
887 }
888 $self->element(
889 {
890 19952 'Name' => $line,
891 'Data' => $data
892 }
893 );
894 # Since HMMER doesn't print some data explicitly,
895 # calculate it from the homology line (midline)
896 19952 ▶ if ($line eq 'Hsp_midline') {
Branch: 1 branch
BranchTrueFalseTotal
if ($line eq "Hsp_midline") 4988 14964 19952
897 4988 ▶ if ($data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data) { } 128 4860 4988
898 128 my $length = length $data;
899 128 my $identical = ($data =~ tr/a-zA-Z//);
900 128 my $positive = ($data =~ tr/+//) + $identical;
901 128 $self->element(
902 {
903 'Name' => 'Hsp_align-len',
904 'Data' => $length
905 }
906 );
907 128 $self->element(
908 { 'Name' => 'Hsp_identity',
909 'Data' => $identical
910 }
911 );
912 128 $self->element(
913 { 'Name' => 'Hsp_positive',
914 'Data' => $positive
915 }
916 );
917 }
918 else {
919 4860 $self->element(
920 { 'Name' => 'Hsp_identity',
921 'Data' => 0
922 }
923 );
924 4860 $self->element(
925 { 'Name' => 'Hsp_positive',
926 'Data' => 0
927 }
928 );
929 }
930 }
931 }
932 4988 $self->{'_last_hspdata'} = {};
933 }
934 91030 ▶ if ($type) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type) { } 9993 81037 91030
elsif ($Bio::SearchIO::hmmer2::MAPPING{$nm}) { } 81037 0 81037
935 9993 ▶ if ( $self->_eventHandler->will_handle($type) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_eventHandler->will_handle($type)) 9993 0 9993
936 9993 my $func = sprintf( "end_%s", lc $type );
937 $rc = $self->_eventHandler->$func( $self->{'_reporttype'},
938 9993 $self->{'_values'} );
939 }
940 9993 my $lastelem = shift @{ $self->{'_elements'} };
941  
942 # Flush corresponding values from the {_values} buffer
943 9993 my $name = uc $type;
944 9993 foreach my $key (keys %{ $self->{_values} }) {
945 194899 ▶ delete $self->{_values}->{$key} if ($key =~ m/^$name-/);
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /^$name-/ 104995 89904 194899
946 }
947 }
948 elsif ( $MAPPING{$nm} ) {
949 81037 ▶ if ( ref( $MAPPING{$nm} ) =~ /hash/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Bio::SearchIO::hmmer2::MAPPING{$nm}) =~ /hash/i) { } 0 81037 81037
950 0 my $key = ( keys %{ $MAPPING{$nm} } )[0];
951 $self->{'_values'}->{$key}->{ $MAPPING{$nm}->{$key} } =
952 0 $self->{'_last_data'};
953 }
954 else {
955 81037 $self->{'_values'}->{ $MAPPING{$nm} } = $self->{'_last_data'};
956 }
957 }
958 else {
959 0 $self->debug("unknown nm $nm, ignoring\n");
960 }
961 91030 $self->{'_last_data'} = ''; # remove read data if we are at
962 # end of an element
963 91030 ▶ $self->{'_result'} = $rc if ( defined $type && $type eq 'result' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type eq "result" 17 91013 91030
Condition100%3/3
defined $type and $type eq "result"
!ll&&!rl&&r
81037997617
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
964 91030 return $rc;
965 }
966  
967 =head2 element
968  
969 Title : element
970 Usage : $eventhandler->element({'Name' => $name, 'Data' => $str});
971 Function: Convience method that calls start_element, characters, end_element
972 Returns : none
973 Args : Hash ref with the keys 'Name' and 'Data'
974  
975  
976 =cut
977  
978 81037 ▶sub element {
Subroutine element: called CC=1 SCAR=0.0
Pod documented
979 81037 my ( $self, $data ) = @_;
980 81037 $self->start_element($data);
981 81037 $self->characters($data);
982 81037 $self->end_element($data);
983 }
984  
985 =head2 characters
986  
987 Title : characters
988 Usage : $eventgenerator->characters($str)
989 Function: Send a character events
990 Returns : none
991 Args : string
992  
993  
994 =cut
995  
996 81037 ▶sub characters {
Subroutine characters: called CC=6 SCAR=17.9
Pod documented
997 81037 my ( $self, $data ) = @_;
998  
999 81037 ▶ if ( $self->in_element('hsp')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(?:qseq|hseq|csline|midline)/o and defined $data->{"Data"}) 1292 79745 81037
Condition100%6/6
$self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(?:qseq|hseq|csline|midline)/o and defined $data->{"Data"}
!ll&&!rl&&r
60231195141292
$self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(?:qseq|hseq|csline|midline)/o
!ll&&!rl&&r
201994003220806
MC/DC100%3/3
$self->in_element("hsp") and $data->{"Name"} =~ /Hsp\_(?:qseq|hseq|csline|midline)/o and defined $data->{"Data"}
$self->in_element("hsp") $data->{"Name"} =~ /Hsp\_(?:qseq|hseq|csline|midline)/o defined $data->{"Data"}
Truth table100%4/4
A and B and C
A= $self->in_element("hsp")B= $data->{"Name"} =~ /Hsp\_(?:qseq|hseq|csline|midline)/oC= defined $data->{"Data"}
ABCresult
0XX0
10X0
1100
1111
1000 && $data->{'Name'} =~ /Hsp\_(?:qseq|hseq|csline|midline)/o
1001 && defined $data->{'Data'} )
1002 {
1003 1292 $self->{'_last_hspdata'}->{ $data->{'Name'} } .= $data->{'Data'};
1004 }
1005 81037 ▶ return unless ( defined $data->{'Data'} && $data->{'Data'} !~ /^\s+$/o );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{"Data"} and not $data->{"Data"} =~ /^\s+$/o 19518 61519 81037
Condition100%3/3
defined $data->{"Data"} and not $data->{"Data"} =~ /^\s+$/o
!ll&&!rl&&r
19515361519
MC/DC100%2/2
defined $data->{"Data"} and not $data->{"Data"} =~ /^\s+$/o
defined $data->{"Data"} not $data->{"Data"} =~ /^\s+$/o
Truth table100%3/3
A and not(B)
A= defined $data->{"Data"}B= not $data->{"Data"} =~ /^\s+$/o
ABresult
0X0
100
111
1006  
1007 61519 $self->{'_last_data'} = $data->{'Data'};
1008 }
1009  
1010 =head2 within_element
1011  
1012 Title : within_element
1013 Usage : if( $eventgenerator->within_element($element) ) {}
1014 Function: Test if we are within a particular element
1015 This is different than 'in' because within can be tested
1016 for a whole block.
1017 Returns : boolean
1018 Args : string element name
1019  
1020  
1021 =cut
1022  
1023 256 ▶sub within_element {
Subroutine within_element: called CC=6 SCAR=19.3
Pod documented
1024 256 my ( $self, $name ) = @_;
1025 return 0
1026 if ( !defined $name
1027 || !defined $self->{'_elements'}
1028 256 ▶ || scalar @{ $self->{'_elements'} } == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name && defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0 0 256 256
Condition33%2/6
not defined $name && defined $self->{"_elements"} or scalar @{$self->{"_elements"};} == 0
l!l&&r!l&&!r
00256
defined $name && defined $self->{'_elements'}
!ll&&!rl&&r
00256
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 table25%1/4
not(A && B) or C
A= defined $nameB= defined $self->{'_elements'}C= scalar @{$self->{"_elements"};} == 0
ABCresult
0XX1
10X1
1111
1100
1029 256 foreach my $element ( @{ $self->{'_elements'} } ) {
1030 371 ▶ return 1 if ( $element eq $name );
Branch: 1 branch
BranchTrueFalseTotal
if $element eq $name 243 128 371
1031 }
1032 13 return 0;
1033 }
1034  
1035 =head2 in_element
1036  
1037 Title : in_element
1038 Usage : if( $eventgenerator->in_element($element) ) {}
1039 Function: Test if we are in a particular element
1040 This is different than 'within' because 'in' only
1041 tests its immediete parent.
1042 Returns : boolean
1043 Args : string element name
1044  
1045  
1046 =cut
1047  
1048 81050 ▶sub in_element {
Subroutine in_element: called CC=2 SCAR=7.1
Pod documented
1049 81050 my ( $self, $name ) = @_;
1050 81050 ▶ return 0 if !defined $self->{'_elements'}->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_elements"}[0] 0 81050 81050
1051 81050 return ( $self->{'_elements'}->[0] eq $name );
1052 }
1053  
1054 =head2 start_document
1055  
1056 Title : start_document
1057 Usage : $eventgenerator->start_document
1058 Function: Handle a start document event
1059 Returns : none
1060 Args : none
1061  
1062  
1063 =cut
1064  
1065 20 ▶sub start_document {
Subroutine start_document: called CC=1 SCAR=0.0
Pod documented
1066 20 my ($self) = @_;
1067 20 $self->{'_lasttype'} = '';
1068 20 $self->{'_values'} = {};
1069 20 $self->{'_result'} = undef;
1070 20 $self->{'_elements'} = [];
1071 }
1072  
1073 =head2 end_document
1074  
1075 Title : end_document
1076 Usage : $eventgenerator->end_document
1077 Function: Handles an end document event
1078 Returns : Bio::Search::Result::ResultI object
1079 Args : none
1080  
1081  
1082 =cut
1083  
1084 20 ▶sub end_document {
Subroutine end_document: called CC=1 SCAR=0.0
Pod documented
1085 20 my ($self) = @_;
1086 20 return $self->{'_result'};
1087 }
1088  
1089 =head2 result_count
1090  
1091 Title : result_count
1092 Usage : my $count = $searchio->result_count
1093 Function: Returns the number of results we have processed
1094 Returns : integer
1095 Args : none
1096  
1097  
1098 =cut
1099  
1100 0 ▶sub result_count {
Subroutine result_count: not called CC=1 SCAR=6.9
Pod documented
1101 0 my $self = shift;
1102 0 return $self->{'_result_count'};
1103 }
1104  
1105 3 1;
« lib/Bio/SearchIO/hmmer3.pm ↑ Summary lib/Bio/Tools/Hmmpfam.pm »