Bio/OntologyIO/Handlers/InterProHandler.pm

filter: Statementstmt 11.6% 29 / 250 Branchbran 0.0% 0 / 104 Conditioncond 0.0% 0 / 31 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 28.5% 8 / 28 Podpod 100% 8 / 8 totaltotal 10.2% 45 / 439 CC 73 SCAR 60.9
CC
73
Cov
8%
end_element
1190.0
start_element
202.5
ontology_engine
56.0
CRAP 441.6
« Bio/SearchIO/blast.pm ↑ Summary Bio/Root/IO.pm »
1 #
2 # BioPerl module for InterProHandler
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Peter Dimitrov <dimitrov@gnf.org>
7 #
8 # Copyright Peter Dimitrov
9 # (c) Peter Dimitrov, dimitrov@gnf.org, 2003.
10 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2003.
11 #
12 # You may distribute this module under the same terms as perl itself.
13 # Refer to the Perl Artistic License (see the license accompanying this
14 # software package, or see http://www.perl.com/language/misc/Artistic.html)
15 # for the terms under which you may use, modify, and redistribute this module.
16 #
17 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
18 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 #
21 # POD documentation - main docs before the code
22  
23 =head1 NAME
24  
25 Bio::OntologyIO::Handlers::InterProHandler - XML handler class for InterProParser
26  
27 =head1 SYNOPSIS
28  
29 # do not use directly - used and instantiated by InterProParser
30  
31 =head1 DESCRIPTION
32  
33 Handles xml events generated by InterProParser when parsing InterPro
34 XML files.
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 - Peter Dimitrov
67  
68 Email dimitrov@gnf.org
69  
70 =head1 CONTRIBUTORS
71  
72 Juguang Xiao, juguang@tll.org.sg
73  
74 =head1 APPENDIX
75  
76 The rest of the documentation details each of the object methods.
77 Internal methods are usually preceded with a _
78  
79 =cut
80  
81 # Let the code begin...
82  
83 package Bio::OntologyIO::Handlers::InterProHandler;
84 1 $Bio::OntologyIO::Handlers::InterProHandler::VERSION = '1.7.8';
85 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 1 ▶use Bio::Ontology::Ontology;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 1 ▶use Bio::Ontology::RelationshipType;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 1 ▶use Bio::Ontology::SimpleOntologyEngine;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 1 ▶use Bio::Annotation::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 1 ▶use base qw(Bio::Root::Root);
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95 1 my ( $record_count, $processed_count, $is_a_rel, $contains_rel, $found_in_rel );
96  
97 =head2 new
98  
99 Title : new
100 Usage : $h = Bio::OntologyIO::Handlers::InterProHandler->new;
101 Function: Initializes global variables
102 Example :
103 Returns : an InterProHandler object
104 Args :
105  
106  
107 =cut
108  
109 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
110 0 my ( $class, @args ) = @_;
111 0 my $self = $class->SUPER::new(@args);
112  
113 0 my ( $eng, $ont, $name, $fact ) = $self->_rearrange(
114 [qw[
115 ENGINE
116 ONTOLOGY
117 ONTOLOGY_NAME
118 TERM_FACTORY
119 ]],
120 @args
121 );
122  
123 0 ▶ if ( defined($ont) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ont) { } 0 0 0
124 0 $self->ontology($ont);
125 } else {
126 0 ▶ $name = "InterPro" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
127 0 $self->ontology( Bio::Ontology::Ontology->new( -name => $name ) );
128 }
129 0 ▶ $self->ontology_engine($eng) if $eng;
Branch: 1 branch
BranchTrueFalseTotal
if $eng 0 0 0
130  
131 0 ▶ $self->term_factory($fact) if $fact;
Branch: 1 branch
BranchTrueFalseTotal
if $fact 0 0 0
132  
133 0 $is_a_rel = Bio::Ontology::RelationshipType->get_instance("IS_A");
134 0 $contains_rel = Bio::Ontology::RelationshipType->get_instance("CONTAINS");
135 0 $found_in_rel = Bio::Ontology::RelationshipType->get_instance("FOUND_IN");
136 0 $is_a_rel->ontology( $self->ontology() );
137 0 $contains_rel->ontology( $self->ontology() );
138 0 $found_in_rel->ontology( $self->ontology() );
139 0 $self->_cite_skip(0);
140 0 $self->secondary_accessions_map( {} );
141  
142 0 return $self;
143 }
144  
145 =head2 ontology_engine
146  
147 Title : ontology_engine
148 Usage : $obj->ontology_engine($newval)
149 Function: Get/set ontology engine. Can be initialized only once.
150 Example :
151 Returns : value of ontology_engine (a scalar)
152 Args : new value (a scalar, optional)
153  
154  
155 =cut
156  
157 0 ▶sub ontology_engine {
Subroutine ontology_engine: not called CC=7 SCAR=40.3
Pod documented
158 0 my ( $self, $value ) = @_;
159  
160 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
161 0 ▶ if ( defined $self->{'ontology_engine'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'ontology_engine'}) { } 0 0 0
162 0 $self->throw("ontology_engine already defined");
163 } else {
164 0 ▶ $self->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless $value->isa("Bio::Ontology::OntologyEngineI") 0 0 0
165 ref($value) . " does not implement " . "Bio::Ontology::OntologyEngineI. Bummer." )
166 unless $value->isa("Bio::Ontology::OntologyEngineI");
167 0 $self->{'ontology_engine'} = $value;
168  
169 # don't forget to set this as the engine of the ontology, otherwise
170 # those two might not point to the same object
171 0 my $ont = $self->ontology();
172 0 ▶ if ( $ont && $ont->can("engine") && ( !$ont->engine() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ont and $ont->can("engine") and not $ont->engine) 0 0 0
Condition0%0/6
$ont and $ont->can("engine") and not $ont->engine
!ll&&!rl&&r
000
$ont and $ont->can("engine")
!ll&&!rl&&r
000
MC/DC0%0/3
$ont and $ont->can("engine") and not $ont->engine
$ont $ont->can("engine") not $ont->engine
Truth table0%0/4
A and B and not(C)
A= $ontB= $ont->can("engine")C= not $ont->engine
ABCresult
0XX0
10X0
1100
1111
173 0 $ont->engine($value);
174 }
175  
176 $self->debug(
177 0 ref($self)
178 . "::ontology_engine: registering ontology engine ("
179 . ref($value) . "):\n"
180 . $value->to_string
181 . "\n" );
182 }
183 }
184  
185 0 return $self->{'ontology_engine'};
186 }
187  
188 =head2 ontology
189  
190 Title : ontology
191 Usage :
192 Function: Get the ontology to add the InterPro terms to.
193  
194 The value is determined automatically once ontology_engine
195 has been set and if it hasn't been set before.
196  
197 Example :
198 Returns : A L<Bio::Ontology::OntologyI> implementing object.
199 Args : On set, a L<Bio::Ontology::OntologyI> implementing object.
200  
201 =cut
202  
203 0 ▶sub ontology {
Subroutine ontology: not called CC=3 SCAR=24.8
Pod documented
204 0 my ( $self, $ont ) = @_;
205  
206 0 ▶ if ( defined($ont) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ont) 0 0 0
207 0 ▶ $self->throw( ref($ont) . " does not implement Bio::Ontology::OntologyI" . ". Bummer." )
Branch: 1 branch
BranchTrueFalseTotal
unless $ont->isa("Bio::Ontology::OntologyI") 0 0 0
208 unless $ont->isa("Bio::Ontology::OntologyI");
209 0 $self->{'_ontology'} = $ont;
210 }
211 0 return $self->{'_ontology'};
212 }
213  
214 =head2 term_factory
215  
216 Title : term_factory
217 Usage : $obj->term_factory($newval)
218 Function: Get/set the ontology term object factory
219 Example :
220 Returns : value of term_factory (a Bio::Factory::ObjectFactory instance)
221 Args : on set, new value (a Bio::Factory::ObjectFactory instance
222 or undef, optional)
223  
224  
225 =cut
226  
227 0 ▶sub term_factory {
Subroutine term_factory: not called CC=2 SCAR=17.9
Pod documented
228 0 my $self = shift;
229  
230 0 ▶ return $self->{'term_factory'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
231 0 return $self->{'term_factory'};
232 }
233  
234 =head2 _cite_skip
235  
236 Title : _cite_skip
237 Usage : $obj->_cite_skip($newval)
238 Function:
239 Example :
240 Returns : value of _cite_skip (a scalar)
241 Args : new value (a scalar, optional)
242  
243  
244 =cut
245  
246 0 ▶sub _cite_skip {
Subroutine _cite_skip: not called CC=2 SCAR=17.9
247 0 my ( $self, $value ) = @_;
248  
249 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
250 0 $self->{'_cite_skip'} = $value;
251 }
252  
253 0 return $self->{'_cite_skip'};
254 }
255  
256 =head2 _hash
257  
258 Title : _hash
259 Usage : $obj->_hash($newval)
260 Function:
261 Example :
262 Returns : value of _hash (a scalar)
263 Args : new value (a scalar, optional)
264  
265  
266 =cut
267  
268 0 ▶sub _hash {
Subroutine _hash: not called CC=2 SCAR=17.9
269 0 my ( $self, $value ) = @_;
270  
271 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
272 0 $self->{'_hash'} = $value;
273 }
274  
275 0 return $self->{'_hash'};
276 }
277  
278 =head2 _stack
279  
280 Title : _stack
281 Usage : $obj->_stack($newval)
282 Function:
283 Example :
284 Returns : value of _stack (a scalar)
285 Args : new value (a scalar, optional)
286  
287  
288 =cut
289  
290 0 ▶sub _stack {
Subroutine _stack: not called CC=2 SCAR=17.9
291 0 my ( $self, $value ) = @_;
292  
293 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
294 0 $self->{'_stack'} = $value;
295 }
296 0 return $self->{'_stack'};
297 }
298  
299 =head2 _top
300  
301 Title : _top
302 Usage :
303 Function:
304 Example :
305 Returns :
306 Args :
307  
308  
309 =cut
310  
311 0 ▶sub _top {
Subroutine _top: not called CC=2 SCAR=17.9
312 0 my ( $self, $_stack ) = @_;
313 0 my @stack = @{$_stack};
314  
315 0 ▶ return ( @stack >= 1 ) ? $stack[ @stack - 1 ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@stack >= 1 ? : 0 0 0
316 }
317  
318 =head2 _term
319  
320 Title : _term
321 Usage : $obj->_term($newval)
322 Function: Get/set method for the term currently processed.
323 Example :
324 Returns : value of term (a scalar)
325 Args : new value (a scalar, optional)
326  
327  
328 =cut
329  
330 0 ▶sub _term {
Subroutine _term: not called CC=2 SCAR=17.9
331 0 my ( $self, $value ) = @_;
332  
333 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
334 0 $self->{'_term'} = $value;
335 }
336  
337 0 return $self->{'_term'};
338 }
339  
340 =head2 _clear_term
341  
342 Title : _clear_term
343 Usage :
344 Function: Removes the current term from the handler
345 Example :
346 Returns :
347 Args :
348  
349  
350 =cut
351  
352 0 ▶sub _clear_term {
Subroutine _clear_term: not called CC=1 SCAR=6.9
353 0 my ($self) = @_;
354  
355 0 delete $self->{'_term'};
356 }
357  
358 =head2 _names
359  
360 Title : _names
361 Usage : $obj->_names($newval)
362 Function:
363 Example :
364 Returns : value of _names (a scalar)
365 Args : new value (a scalar, optional)
366  
367  
368 =cut
369  
370 0 ▶sub _names {
Subroutine _names: not called CC=2 SCAR=17.9
371 0 my ( $self, $value ) = @_;
372  
373 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
374 0 $self->{'_names'} = $value;
375 }
376  
377 0 return $self->{'_names'};
378 }
379  
380 =head2 _create_relationship
381  
382 Title : _create_relationship
383 Usage :
384 Function: Helper function. Adds relationships to one of the relationship stores.
385 Example :
386 Returns :
387 Args :
388  
389 =cut
390  
391 {
392
393 1 my %relationship_cache;
394  
395 0 ▶sub _clear_cache { %relationship_cache = () }
Subroutine _clear_cache: not called CC=1 SCAR=6.9
396  
397 0 ▶sub _create_relationship {
Subroutine _create_relationship: not called CC=5 SCAR=34.0
398 0 my ( $self, $ref_id, $rel_type_term ) = @_;
399
400 0 my $ont = $self->ontology();
401 0 my $fact = $self->term_factory();
402 0 my $term_temp = ( $ont->engine->get_term_by_identifier($ref_id) )[0];
403
404 0 ▶ if ( !defined $term_temp ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $term_temp) 0 0 0
405 0 $term_temp =
406 $ont->engine->add_term(
407 $fact->create_object( -InterPro_id => $ref_id, -name => $ref_id, -ontology => $ont ) );
408 0 $ont->engine->mark_uninstantiated($term_temp);
409 }
410 0 my $marshalled = join(':', (sort $self->_term->identifier, $ref_id));
411  
412 # check cache to see if the two have been seen before, using marshalled IDs
413 0 ▶ if ($relationship_cache{$marshalled}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($relationship_cache{$marshalled}++) 0 0 0
414 # TODO: should check that the relationship type for these terms is the
415 # inverse of the stored relationship type
416 0 return;
417 }
418
419 0 my $rel_type_name = $self->_top( $self->_names );
420  
421 0 my $rel = Bio::Ontology::Relationship->new( -predicate_term => $rel_type_term );
422  
423 0 ▶ if ( $rel_type_name eq 'parent_list' || $rel_type_name eq 'found_in' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rel_type_name eq 'parent_list' or $rel_type_name eq 'found_in') { } 0 0 0
Condition0%0/3
$rel_type_name eq "parent_list" or $rel_type_name eq "found_in"
l!l&&r!l&&!r
000
MC/DC0%0/2
$rel_type_name eq "parent_list" or $rel_type_name eq "found_in"
$rel_type_name eq "parent_list" $rel_type_name eq "found_in"
Truth table0%0/3
A or B
A= $rel_type_name eq "parent_list"B= $rel_type_name eq "found_in"
ABresult
1X1
011
000
424 0 $rel->object_term($term_temp);
425 0 $rel->subject_term( $self->_term );
426 } else {
427 0 $rel->object_term( $self->_term );
428 0 $rel->subject_term($term_temp);
429 }
430 0 $rel->ontology($ont);
431 0 $ont->add_relationship($rel);
432 }
433  
434 }
435  
436 =head2 start_element
437  
438 Title : start_element
439 Usage :
440 Function: This is a method that is derived from XML::SAX::Base and
441 has to be overridden for processing start of xml element
442 events. Used internally only.
443  
444 Example :
445 Returns :
446 Args :
447  
448  
449 =cut
450  
451 1 ▶sub start_element {
Subroutine start_element: not called CC=14 SCAR=53.1
Pod documented
452 0 my ( $self, $element ) = @_;
453 0 my $ont = $self->ontology();
454 0 my $fact = $self->term_factory();
455  
456 0 ▶ if ( $element->{Name} eq 'interprodb' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($element->{'Name'} eq 'interprodb') { } 0 0 0
elsif ($element->{'Name'} eq 'interpro') { } 0 0 0
elsif (defined $self->_stack) { } 0 0 0
457 0 $ont->add_term(
458 $fact->create_object(
459 -identifier => "Active_site",
460 -name => "Active Site"
461 )
462 );
463 0 $ont->add_term(
464 $fact->create_object(
465 -identifier => "Conserved_site",
466 -name => "Conserved Site"
467 )
468 );
469 0 $ont->add_term(
470 $fact->create_object(
471 -identifier => "Binding_site",
472 -name => "Binding Site"
473 )
474 );
475 0 $ont->add_term(
476 $fact->create_object(
477 -identifier => "Family",
478 -name => "Family"
479 )
480 );
481 0 $ont->add_term(
482 $fact->create_object(
483 -identifier => "Domain",
484 -name => "Domain"
485 )
486 );
487 0 $ont->add_term(
488 $fact->create_object(
489 -identifier => "Repeat",
490 -name => "Repeat"
491 )
492 );
493 0 $ont->add_term(
494 $fact->create_object(
495 -identifier => "PTM",
496 -name => "post-translational modification"
497 )
498 );
499 0 $ont->add_term(
500 $fact->create_object(
501 -identifier => "Region",
502 -name => "Region"
503 )
504 );
505 } elsif ( $element->{Name} eq 'interpro' ) {
506 0 my %record_args = %{ $element->{Attributes} };
507 0 my $id = $record_args{"id"};
508  
509 # this sets the current term
510 0 ▶ my $term = ( $ont->engine->get_term_by_identifier($id) )[0] ||
Condition0%0/3
($ont->engine->get_term_by_identifier($id))[0] || $fact->create_object('-InterPro_id', $id, '-name', $id)
l!l&&r!l&&!r
000
MC/DC0%0/2
($ont->engine->get_term_by_identifier($id))[0] || $fact->create_object('-InterPro_id', $id, '-name', $id)
($ont->engine->get_term_by_identifier($id))[0] $fact->create_object('-InterPro_id', $id, '-name', $id)
Truth table0%0/3
A || B
A= ($ont->engine->get_term_by_identifier($id))[0]B= $fact->create_object('-InterPro_id', $id, '-name', $id)
ABresult
1X1
011
000
511 $fact->create_object( -InterPro_id => $id, -name => $id );
512 0 $self->_term($term);
513  
514 0 $term->ontology($ont);
515 0 $term->short_name( $record_args{"short_name"} );
516 0 $term->protein_count( $record_args{"protein_count"} );
517 0 $self->_increment_record_count();
518 0 $self->_stack( [ { interpro => undef } ] );
519 0 $self->_names( ["interpro"] );
520  
521 ## Adding a relationship between the newly created InterPro term
522 ## and the term describing its type
523  
524 0 my $rel = Bio::Ontology::Relationship->new( -predicate_term => $is_a_rel );
525 0 ▶ my ($object_term) = $ont->find_terms( -identifier => $record_args{"type"} )
Branch: 1 branch
BranchTrueFalseTotal
my($object_term) = $ont->find_terms("-identifier", $record_args{"type"}) or $self->throw(qq[when processing interpro ID '${id}', no term found for interpro type '$record_args{"type"}']) 0 0 0
526 or $self->throw(
527 "when processing interpro ID '$id', no term found for interpro type '$record_args{type}'"
528 );
529 0 $rel->object_term($object_term);
530 0 $rel->subject_term( $self->_term );
531 0 $rel->ontology($ont);
532 0 $ont->add_relationship($rel);
533 0 $ont->add_term($term);
534 } elsif ( defined $self->_stack ) {
535 0 my %hash = ();
536  
537 0 ▶ if ( keys %{ $element->{Attributes} } > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$element{"Attributes"};} > 0) 0 0 0
538 0 foreach my $key ( keys %{ $element->{Attributes} } ) {
539 0 $hash{$key} = $element->{Attributes}->{$key};
540 }
541 }
542 0 push @{ $self->_stack }, \%hash;
543 0 ▶ if ( $element->{Name} eq 'rel_ref' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($element->{'Name'} eq 'rel_ref') { } 0 0 0
elsif ($element->{'Name'} eq 'abstract') { } 0 0 0
544 0 my $ref_id = $element->{Attributes}->{"ipr_ref"};
545 0 my $parent = $self->_top( $self->_names );
546  
547 0 ▶ if ( $parent eq 'parent_list' || $parent eq 'child_list' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent eq "parent_list" or $parent eq "child_list") 0 0 0
Condition0%0/3
$parent eq "parent_list" or $parent eq "child_list"
l!l&&r!l&&!r
000
MC/DC0%0/2
$parent eq "parent_list" or $parent eq "child_list"
$parent eq "parent_list" $parent eq "child_list"
Truth table0%0/3
A or B
A= $parent eq "parent_list"B= $parent eq "child_list"
ABresult
1X1
011
000
548 0 $self->_create_relationship( $ref_id, $is_a_rel );
549 }
550 0 ▶ if ( $parent eq 'contains' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent eq "contains") 0 0 0
551 0 $self->_create_relationship( $ref_id, $contains_rel );
552 }
553 0 ▶ if ( $parent eq 'found_in' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent eq "found_in") 0 0 0
554 0 $self->_create_relationship( $ref_id, $found_in_rel );
555 }
556 } elsif ( $element->{Name} eq 'abstract' ) {
557 0 $self->_cite_skip(1);
558 }
559 0 push @{ $self->_names }, $element->{Name};
560 }
561  
562 }
563  
564 =head2 _char_storage
565  
566 Title : _char_storage
567 Usage : $obj->_char_storage($newval)
568 Function:
569 Example :
570 Returns : value of _char_storage (a scalar)
571 Args : new value (a scalar, optional)
572  
573  
574 =cut
575  
576 0 ▶sub _char_storage {
Subroutine _char_storage: not called CC=2 SCAR=17.9
577 0 my ( $self, $value ) = @_;
578  
579 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
580 0 $self->{'_char_storage'} = $value;
581 }
582  
583 0 return $self->{'_char_storage'};
584 }
585  
586 =head2 characters
587  
588 Title : characters
589 Usage :
590 Function: This is a method that is derived from XML::SAX::Base and has to be overridden for processing xml characters events. Used internally only.
591 Example :
592 Returns :
593 Args :
594  
595  
596 =cut
597  
598 0 ▶sub characters {
Subroutine characters: not called CC=1 SCAR=6.9
Pod documented
599 0 my ( $self, $characters ) = @_;
600 0 my $text = $characters->{Data};
601  
602 0 chomp $text;
603 0 $text =~ s/^(\s+)//;
604 0 $self->{_char_storage} .= $text;
605  
606 }
607  
608 =head2 end_element
609  
610 Title : end_element
611 Usage :
612 Function: This is a method that is derived from XML::SAX::Base and has to be overridden for processing end of xml element events. Used internally only.
613 Example :
614 Returns :
615 Args :
616  
617  
618 =cut
619  
620 0 ▶sub end_element {
Subroutine end_element: not called CC=34 SCAR=70.8
Pod documented
621 0 my ( $self, $element ) = @_;
622  
623 0 ▶ if ( $element->{Name} eq 'interprodb' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($element->{'Name'} eq 'interprodb') { } 0 0 0
elsif ($element->{'Name'} eq 'interpro') { } 0 0 0
elsif ($element->{'Name'} ne 'cite') { } 0 0 0
624 0 $self->debug(
625 "Interpro DB Parser Finished: $record_count read, $processed_count processed\n");
626 0 $self->_clear_cache();
627 } elsif ( $element->{Name} eq 'interpro' ) {
628 0 $self->_clear_term;
629 0 $self->_increment_processed_count();
630 } elsif ( $element->{Name} ne 'cite' ) {
631 0 $self->{_char_storage} =~ s/<\/?p>//g;
632 0 ▶ if ( ( defined $self->_stack ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_stack) 0 0 0
633 0 my $current_hash = pop @{ $self->_stack };
634 0 my $parent_hash = $self->_top( $self->_stack );
635 0 my $current_hash_key = pop @{ $self->_names };
636  
637 0 ▶ if ( keys %{$current_hash} > 0 && $self->_char_storage ne "" ) {
Branch: 3 branches
BranchTrueFalseTotal
if (keys %{$current_hash;} > 0 and $self->_char_storage ne '') { } 0 0 0
elsif ($self->_char_storage ne '') { } 0 0 0
elsif (keys %{$current_hash;} > 0) { } 0 0 0
Condition0%0/3
keys %{$current_hash;} > 0 and $self->_char_storage ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
keys %{$current_hash;} > 0 and $self->_char_storage ne ""
keys %{$current_hash;} > 0 $self->_char_storage ne ""
Truth table0%0/3
A and B
A= keys %{$current_hash;} > 0B= $self->_char_storage ne ""
ABresult
0X0
100
111
638 0 $current_hash->{comment} = $self->_char_storage;
639 0 push @{ $parent_hash->{$current_hash_key} }, $current_hash;
640 } elsif ( $self->_char_storage ne "" ) {
641 0 push @{ $parent_hash->{$current_hash_key} },
642 { 'accumulated_text_12345' => $self->_char_storage };
643 0 } elsif ( keys %{$current_hash} > 0 ) {
644 0 push @{ $parent_hash->{$current_hash_key} }, $current_hash;
645 }
646 0 ▶ if ( $element->{Name} eq 'pub_list' ) {
Branch: 9 branches
BranchTrueFalseTotal
if ($element->{'Name'} eq 'pub_list') { } 0 0 0
elsif ($element->{'Name'} eq 'name') { } 0 0 0
elsif ($element->{'Name'} eq 'abstract') { } 0 0 0
elsif ($element->{'Name'} eq 'member_list') { } 0 0 0
elsif ($element->{'Name'} eq 'sec_list') { } 0 0 0
elsif ($element->{'Name'} eq 'example_list') { } 0 0 0
elsif ($element->{'Name'} eq 'external_doc_list') { } 0 0 0
elsif ($element->{'Name'} eq 'class_list') { } 0 0 0
elsif ($element->{'Name'} eq 'deleted_entries') { } 0 0 0
647 0 my @refs = ();
648  
649 0 foreach my $pub_record ( @{ $current_hash->{publication} } ) {
650 0 my $ref = Bio::Annotation::Reference->new;
651 0 my $loc = $pub_record->{location}->[0];
652 # TODO: Getting unset stuff here; should this be an error?
653 $ref->location(
654 sprintf("%s, %s-%s, %s, %s",
655 $pub_record->{journal}->[0]->{accumulated_text_12345} || '',
656 $loc->{firstpage} || '',
657 $loc->{lastpage} || '',
658 $loc->{volume} || '',
659 0 ▶ $pub_record->{year}->[0]->{accumulated_text_12345} || '')
Condition0%0/10
$pub_record->{'journal'}[0]{'accumulated_text_12345'} || ''
l!l
00
$loc->{'firstpage'} || ''
l!l
00
$loc->{'lastpage'} || ''
l!l
00
$loc->{'volume'} || ''
l!l
00
$pub_record->{'year'}[0]{'accumulated_text_12345'} || ''
l!l
00
MC/DC0%0/1
$pub_record->{'journal'}[0]{'accumulated_text_12345'} || ''
$pub_record->{'journal'}[0]{'accumulated_text_12345'}
MC/DC0%0/1
$loc->{'firstpage'} || ''
$loc->{'firstpage'}
MC/DC0%0/1
$loc->{'lastpage'} || ''
$loc->{'lastpage'}
MC/DC0%0/1
$loc->{'volume'} || ''
$loc->{'volume'}
MC/DC0%0/1
$pub_record->{'year'}[0]{'accumulated_text_12345'} || ''
$pub_record->{'year'}[0]{'accumulated_text_12345'}
Truth table0%0/2
A
A= $pub_record->{'journal'}[0]{'accumulated_text_12345'}
Aresult
11
00
Truth table0%0/2
A
A= $loc->{'firstpage'}
Aresult
11
00
Truth table0%0/2
A
A= $loc->{'lastpage'}
Aresult
11
00
Truth table0%0/2
A
A= $loc->{'volume'}
Aresult
11
00
Truth table0%0/2
A
A= $pub_record->{'year'}[0]{'accumulated_text_12345'}
Aresult
11
00
660 );
661 0 $ref->title( $pub_record->{title}->[0]->{accumulated_text_12345} );
662 0 my $ttt = $pub_record->{author_list}->[0];
663  
664 0 $ref->authors( $ttt->{accumulated_text_12345} );
665 $ref->medline( scalar( $ttt->{dbkey} ) )
666 0 ▶ if exists( $ttt->{db} ) && $ttt->{db} eq "MEDLINE";
Branch: 1 branch
BranchTrueFalseTotal
if exists $ttt->{"db"} and $ttt->{"db"} eq "MEDLINE" 0 0 0
Condition0%0/3
exists $ttt->{"db"} and $ttt->{"db"} eq "MEDLINE"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ttt->{"db"} and $ttt->{"db"} eq "MEDLINE"
exists $ttt->{"db"} $ttt->{"db"} eq "MEDLINE"
Truth table0%0/3
A and B
A= exists $ttt->{"db"}B= $ttt->{"db"} eq "MEDLINE"
ABresult
0X0
100
111
667 0 push @refs, $ref;
668 }
669 0 $self->_term->add_reference(@refs);
670 } elsif ( $element->{Name} eq 'name' ) {
671 0 $self->_term->name( $self->_char_storage );
672 } elsif ( $element->{Name} eq 'abstract' ) {
673 0 $self->_term->definition( $self->_char_storage );
674 0 $self->_cite_skip(0);
675 } elsif ( $element->{Name} eq 'member_list' ) {
676 0 my @refs = ();
677  
678 0 foreach my $db_xref ( @{ $current_hash->{db_xref} } ) {
679 push @refs,
680 Bio::Annotation::DBLink->new(
681 -database => $db_xref->{db},
682 -primary_id => $db_xref->{dbkey}
683 0 );
684 }
685 0 $self->_term->add_dbxref(-dbxrefs => \@refs,
686 -context => 'member_list');
687 } elsif ( $element->{Name} eq 'sec_list' ) {
688 0 my @refs = ();
689  
690 0 foreach my $sec_ac ( @{ $current_hash->{sec_ac} } ) {
691 0 push @refs, $sec_ac->{sec_ac};
692 }
693 0 $self->_term->add_secondary_id(@refs);
694 0 $self->secondary_accessions_map->{ $self->_term->identifier } = \@refs;
695 } elsif ( $element->{Name} eq 'example_list' ) {
696 0 my @refs = ();
697  
698 0 foreach my $example ( @{ $current_hash->{examples} } ) {
699 push @refs,
700 Bio::Annotation::DBLink->new(
701 -database => $example->{db_xref}->[0]->{db},
702 -primary_id => $example->{db_xref}->[0]->{dbkey},
703 -comment => $example->{comment}
704 0 );
705 }
706 0 $self->_term->add_dbxref(-dbxrefs => \@refs,
707 -context => 'example_list');
708 } elsif ( $element->{Name} eq 'external_doc_list' ) {
709 0 my @refs = ();
710  
711 0 foreach my $db_xref ( @{ $current_hash->{db_xref} } ) {
712 push @refs,
713 Bio::Annotation::DBLink->new(
714 -database => $db_xref->{db},
715 -primary_id => $db_xref->{dbkey}
716 0 );
717 }
718 0 $self->_term->add_dbxref(-dbxrefs => \@refs,
719 -context => 'external_doc_list');
720 } elsif ( $element->{Name} eq 'class_list' ) {
721 0 my @refs = ();
722  
723 0 foreach my $classification ( @{ $current_hash->{classification} } ) {
724 push @refs,
725 Bio::Annotation::DBLink->new(
726 -database => $classification->{class_type},
727 -primary_id => $classification->{id}
728 0 );
729 }
730 0 $self->_term->add_dbxref(-dbxrefs => \@refs,
731 -context => 'class_list');
732 } elsif ( $element->{Name} eq 'deleted_entries' ) {
733 0 my @refs = ();
734  
735 0 foreach my $del_ref ( @{ $current_hash->{del_ref} } ) {
736 my $term =
737 0 ( $self->ontology_engine->get_term_by_identifier( $del_ref->{id} ) )[0];
738  
739 0 ▶ $term->is_obsolete(1) if defined $term;
Branch: 1 branch
BranchTrueFalseTotal
if defined $term 0 0 0
740 }
741 }
742 }
743 0 ▶ $self->_char_storage('') if !$self->_cite_skip;
Branch: 1 branch
BranchTrueFalseTotal
if not $self->_cite_skip 0 0 0
744 }
745 }
746  
747 =head2 secondary_accessions_map
748  
749 Title : secondary_accessions_map
750 Usage : $obj->secondary_accessions_map($newval)
751 Function:
752 Example : $map = $interpro_handler->secondary_accessions_map();
753 Returns : Reference to a hash that maps InterPro identifier to an
754 array reference of secondary accessions following the InterPro
755 xml schema.
756 Args : Empty hash reference
757  
758  
759 =cut
760  
761 0 ▶sub secondary_accessions_map {
Subroutine secondary_accessions_map: not called CC=2 SCAR=17.9
Pod documented
762 0 my ( $self, $value ) = @_;
763  
764 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
765 0 $self->{'secondary_accessions_map'} = $value;
766 }
767  
768 0 return $self->{'secondary_accessions_map'};
769 }
770  
771 =head2 _increment_record_count
772  
773 Title : _increment_record_count
774 Usage :
775 Function:
776 Example :
777 Returns :
778 Args :
779  
780  
781 =cut
782  
783 0 ▶sub _increment_record_count {
Subroutine _increment_record_count: not called CC=1 SCAR=6.9
784 0 $record_count++;
785 }
786  
787 =head2 _increment_processed_count
788  
789 Title : _increment_processed_count
790 Usage :
791 Function:
792 Example :
793 Returns :
794 Args :
795  
796  
797 =cut
798  
799 0 ▶sub _increment_processed_count {
Subroutine _increment_processed_count: not called CC=2 SCAR=17.9
800 0 my $self = shift;
801 0 $processed_count++;
802 0 ▶ $self->debug("$processed_count\n") if $processed_count % 100 == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $processed_count % 100 == 0 0 0 0
803 }
804  
805 1 1;
« Bio/SearchIO/blast.pm ↑ Summary Bio/Root/IO.pm »