Bio/OntologyIO/Handlers/InterPro_BioSQL_Handler.pm

filter: Statementstmt 14.9% 31 / 208 Branchbran 0.0% 0 / 94 Conditioncond 0.0% 0 / 34 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 36.0% 9 / 25 Podpod 44.4% 4 / 9 totaltotal 11.3% 44 / 389 CC 63 SCAR 51.5
CC
63
Cov
9%
start_element
552.0
end_element
110.0
_create_publication
72.0
CRAP 173.1
« Bio/SearchIO/Writer/HTMLResultWriter.pm ↑ Summary Bio/Ontology/InterProTerm.pm »
1 #
2 # BioPerl module for InterPro_BioSQL_Handler
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Juguang Xiao, juguang@tll.org.sg
7 #
8 # Copyright Juguang Xiao
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::OntologyIO::Handlers::InterPro_BioSQL_Handler - parse an InterPro XML file and persist the resulting terms to a Biosql database
17  
18 =head1 SYNOPSIS
19  
20 # see load_interpro.pl in bioperl-db/scripts/biosql/
21  
22 =head1 DESCRIPTION
23  
24 This module is for parsing an InterPro XML file and persist the
25 resulting terms to a Biosql database as soon as the term is complete
26 as signaled by the appropriate xml tag. This parser takes advantage of
27 SAX, a stream-based XML parser technology, to keep the used memory as
28 small as possible. The alternative parser for InterPro, module
29 InterProHandler, builds up the entire ontology in memory, which given
30 the size of the latest InterPro releases requires a huge amount of
31 memory.
32  
33 This module takes the following non-standard arguments upon
34 instantiation.
35  
36 -db the adaptor factory as returned by a call to
37 Bio::DB::BioDB->new()
38 -version the InterPro version (not available as property!)
39 -term_factory the object factory to use for creating terms
40  
41 Note that there are two alternatives for how to persist the terms and
42 relationships to the database. The default is using the adaptor
43 factory passed as -db or set as a property to create persistent
44 objects and store them in the database. The alternative is to specify
45 a term persistence and a relationship persistence handler; if one or
46 both have been set, the respective handler will be called with each
47 term and relationship that is to be stored. See properties
48 persist_term_handler and persist_relationship_handler.
49  
50 =head1 AUTHOR
51  
52 Juguang Xiao, juguang@tll.org.sg
53  
54 =head1 Contributors
55  
56 Hilmar Lapp, hlapp at gmx.net
57  
58 =head2 APPENDIX
59  
60 The rest of the documentation details each of the object methods.
61 Internal methods are usually preceded with a _
62  
63 =cut
64  
65 package Bio::OntologyIO::Handlers::InterPro_BioSQL_Handler;
66 1 $Bio::OntologyIO::Handlers::InterPro_BioSQL_Handler::VERSION = '1.7.8';
67 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 1 ▶use Bio::Ontology::Ontology;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 1 ▶use Bio::Ontology::Term;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 1 ▶use Bio::Ontology::TermFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 1 ▶use Bio::Ontology::RelationshipType;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 1 ▶use Bio::Ontology::Relationship;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 ▶use Bio::Annotation::DBLink;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 1 ▶use Bio::Annotation::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 1 ▶use base qw(Bio::OntologyIO::Handlers::BaseSAXHandler);
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78 1 my $is_a_rel;
79 1 my $count=0;
80  
81 0 ▶sub _initialize {
Subroutine _initialize: not called CC=4 SCAR=30.0
82 0 my($self,@args)=@_;
83 0 $self->SUPER::_initialize(@args);
84 0 my ($db, $version, $fact) = $self->_rearrange(
85 [qw(DB VERSION TERM_FACTORY)], @args);
86 0 ▶ $self->db($db) if $db; # this is now a property and may be set later
Branch: 1 branch
BranchTrueFalseTotal
if $db 0 0 0
87 0 ▶ if (!$fact) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fact) 0 0 0
88 0 $fact = Bio::Ontology::TermFactory->new(-type=>"Bio::Ontology::Term");
89 }
90 0 $self->term_factory($fact);
91 0 my $ontology = Bio::Ontology::Ontology->new(-name => 'InterPro');
92 0 ▶ if (defined($version)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $version) 0 0 0
93 0 $version = "InterPro version $version";
94 0 $ontology->definition($version);
95 }
96 0 $self->_ontology($ontology);
97 0 $is_a_rel = Bio::Ontology::RelationshipType->get_instance('IS_A');
98 0 $is_a_rel->ontology($ontology);
99 }
100  
101 =head2 term_factory
102  
103 Title : term_factory
104 Usage : $obj->term_factory($newval)
105 Function: Get/set the ontology term factory to use.
106  
107 As a user of this module it is not necessary to call this
108 method as there will be default. In order to change the
109 default, the easiest way is to instantiate
110 L<Bio::Ontology::TermFactory> with the proper -type
111 argument. Most if not all parsers will actually use this
112 very implementation, so even easier than the aforementioned
113 way is to simply call
114 $ontio->term_factory->type("Bio::Ontology::MyTerm").
115  
116 Example :
117 Returns : value of term_factory (a Bio::Factory::ObjectFactoryI object)
118 Args : on set, new value (a Bio::Factory::ObjectFactoryI object, optional)
119  
120  
121 =cut
122  
123 0 ▶sub term_factory{
Subroutine term_factory: not called CC=2 SCAR=17.9
Pod documented
124 0 my $self = shift;
125  
126 0 ▶ return $self->{'term_factory'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
127 0 return $self->{'term_factory'};
128 }
129  
130 =head2 db
131  
132 Title : db
133 Usage : $obj->db($newval)
134 Function: Sets or retrieves the database adaptor factory.
135  
136 The adaptor factory is a Bio::DB::DBAdaptorI compliant
137 object and will be used to obtain the persistence adaptors
138 necessary to serialize terms and relationships to the
139 database.
140  
141 Usually, you will obtain such an object from a call to
142 Bio::DB::BioDB. You *must* set this property before
143 starting the parse.
144  
145 Note that this property is immutable once set, except that
146 you may set it to undef. Therefore, be careful not to set
147 to undef before setting the desired real value.
148  
149 Example :
150 Returns : value of db (a Bio::DB::DBAdaptorI compliant object)
151 Args : on set, new value (a Bio::DB::DBAdaptorI compliant object
152 or undef, optional)
153  
154  
155 =cut
156  
157 0 ▶sub db {
Subroutine db: not called CC=5 SCAR=34.0
Pod documented
158 0 my $self=shift;
159 0 ▶ if(@_){
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
160 0 my $db = shift;
161 0 ▶ if ($db && exists($self->{_db}) && ($self->{_db} != $db)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($db and exists $self->{"_db"} and $self->{"_db"} != $db) 0 0 0
Condition0%0/6
$db and exists $self->{"_db"} and $self->{"_db"} != $db
!ll&&!rl&&r
000
$db and exists $self->{"_db"}
!ll&&!rl&&r
000
MC/DC0%0/3
$db and exists $self->{"_db"} and $self->{"_db"} != $db
$db exists $self->{"_db"} $self->{"_db"} != $db
Truth table0%0/4
A and B and C
A= $dbB= exists $self->{"_db"}C= $self->{"_db"} != $db
ABCresult
0XX0
10X0
1100
1111
162 0 $self->throw('db may not be modified once set');
163 }
164 0 $self->{_db}=$db;
165 }
166 0 return $self->{_db};
167 }
168  
169 =head2 persist_term_handler
170  
171 Title : persist_term_handler
172 Usage : $obj->persist_term_handler($handler,@args)
173 Function: Sets or retrieves the persistence handler for terms along
174 with the constant set of arguments to be passed to the
175 handler.
176  
177 If set, the first argument will be treated as a closure and
178 be called for each term to persist to the database. The
179 term will be passed as a named parameter (-term), followed
180 by the other arguments passed to this setter. Note that
181 this allows one to pass an arbitrary configuration to the
182 handler.
183  
184 If not set, terms will be persisted along with their
185 relationships using the respective persistence adaptor
186 returned by the adaptor factory (see property db).
187  
188 Example :
189 Returns : an array reference with the values passed on set, or an empty
190 array if never set
191 Args : On set, an array of values. The first value is the handler
192 as a closure; all other values will be passed to the handler
193 as constant argument.
194  
195  
196 =cut
197  
198 0 ▶sub persist_term_handler{
Subroutine persist_term_handler: not called CC=3 SCAR=24.8
Pod documented
199 0 my $self = shift;
200  
201 0 ▶ return $self->{'persist_term_handler'} = [@_] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
202 0 ▶ return $self->{'persist_term_handler'} || [];
Condition0%0/2
$self->{'persist_term_handler'} || []
l!l
00
MC/DC0%0/1
$self->{'persist_term_handler'} || []
$self->{'persist_term_handler'}
Truth table0%0/2
A
A= $self->{'persist_term_handler'}
Aresult
11
00
203 }
204  
205 =head2 persist_relationship_handler
206  
207 Title : persist_relationship_handler
208 Usage : $obj->persist_relationship_handler($handler,@args)
209 Function: Sets or retrieves the persistence handler for relationships
210 along with the constant set of arguments to be passed to
211 the handler.
212  
213 If set, the first argument will be treated as a closure and
214 be called for each relationship to persist to the database. The
215 relationship will be passed as a named parameter (-rel), followed
216 by the other arguments passed to this setter. Note that
217 this allows one to pass an arbitrary configuration to the
218 handler.
219  
220 If not set, relationships will be persisted along with their
221 relationships using the respective persistence adaptor
222 returned by the adaptor factory (see property db).
223  
224 Example :
225 Returns : an array reference with the values passed on set, or an empty
226 array if never set
227 Args : On set, an array of values. The first value is the handler
228 as a closure; all other values will be passed to the handler
229 as constant argument.
230  
231  
232 =cut
233  
234 0 ▶sub persist_relationship_handler{
Subroutine persist_relationship_handler: not called CC=3 SCAR=24.8
Pod documented
235 0 my $self = shift;
236  
237 0 ▶ return $self->{'persist_relationship_handler'} = [@_] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
238 0 ▶ return $self->{'persist_relationship_handler'} || [];
Condition0%0/2
$self->{'persist_relationship_handler'} || []
l!l
00
MC/DC0%0/1
$self->{'persist_relationship_handler'} || []
$self->{'persist_relationship_handler'}
Truth table0%0/2
A
A= $self->{'persist_relationship_handler'}
Aresult
11
00
239 }
240  
241 =head2 _persist_term
242  
243 Title : _persist_term
244 Usage :
245 Function: Persists a term to the database, using either a previously
246 set persistence handler, or the adaptor factory directly.
247 Example :
248 Returns :
249 Args : the ontology term to persist
250  
251  
252 =cut
253  
254 0 ▶sub _persist_term {
Subroutine _persist_term: not called CC=3 SCAR=24.8
255 0 my $self = shift;
256 0 my $term = shift;
257  
258 0 my ($handler,@args) = @{$self->persist_term_handler};
259 0 ▶ if ($handler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handler) { } 0 0 0
260 0 &$handler('-term' => $term, @args);
261 } else {
262 # no handler; we'll do this ourselves straight and simple
263 0 my $db = $self->db();
264 0 my $pterm = $db->create_persistent($term);
265 0 eval {
266 0 $pterm->create();
267 0 $pterm->commit();
268 };
269 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
270 0 $pterm->rollback();
271 0 $self->warn("failed to store term '".$term->name."': ".$@);
272 }
273 }
274 }
275  
276 =head2 _persist_relationship
277  
278 Title : _persist_relationship
279 Usage :
280 Function: Persists a relationship to the database, using either a
281 previously set persistence handler, or the adaptor factory
282 directly.
283  
284 Example :
285 Returns :
286 Args : the term relationship to persist
287  
288  
289 =cut
290  
291 0 ▶sub _persist_relationship {
Subroutine _persist_relationship: not called CC=3 SCAR=24.8
292 0 my $self = shift;
293 0 my $rel = shift;
294  
295 0 my ($handler,@args) = @{$self->persist_relationship_handler};
296 0 ▶ if ($handler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handler) { } 0 0 0
297 0 &$handler('-rel' => $rel, @args);
298 } else {
299 # no handler; we'll do this ourselves straight and simple
300 0 my $db = $self->db();
301 0 my $prel = $db->create_persistent($rel);
302 0 eval {
303 0 $prel->create();
304 0 $prel->commit();
305 };
306 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
307 0 $prel->rollback();
308 0 $self->warn("failed to store relationship of subject '"
309 .$rel->subject_term->name."' to object '"
310 .$rel->object_term->name.": ".$@);
311 }
312 }
313 }
314  
315 =head2 _persist_ontology
316  
317 Title : _persist_ontology
318 Usage :
319 Function: Perists the ontology itself to the database, by either
320 inserting or updating it.
321  
322 Note that this will only create or update the ontology as
323 an entity, not any of its terms, relationships, or
324 relationship types.
325  
326 Example :
327 Returns : the ontology as a persistent object with primary key
328 Args : the ontology to persist as a Bio::Ontology::OntologyI
329 compliant object
330  
331  
332 =cut
333  
334 0 ▶sub _persist_ontology{
Subroutine _persist_ontology: not called CC=6 SCAR=37.4
335 0 my $self = shift;
336 0 my $ont = shift;
337 0 my $db = $self->db();
338  
339 # do a lookup first; chances are we have this already in the database
340 0 my $adp = $db->get_object_adaptor($ont);
341 # to avoid clobbering this ontology's properties with possibly older ones
342 # from the database we'll need an object factory
343 0 my $ontfact =
344 Bio::Factory::ObjectFactory->new(-type=>"Bio::Ontology::Ontology");
345 # do the lookup:
346 0 my $found = $adp->find_by_unique_key($ont, '-obj_factory' => $ontfact);
347 # make a persistent object of the ontology
348 0 $ont = $db->create_persistent($ont);
349 # transfer primary key if found in the lookup
350 0 ▶ $ont->primary_key($found->primary_key) if $found;
Branch: 1 branch
BranchTrueFalseTotal
if $found 0 0 0
351 # insert or update
352 0 my $result;
353 0 eval {
354 0 $result = $ont->store();
355 };
356 0 ▶ if ($@ || !$result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $result) 0 0 0
Condition0%0/3
$@ or not $result
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not $result
$@ not $result
Truth table0%0/3
A or not(B)
A= $@B= not $result
ABresult
1X1
011
000
357 0 $adp->rollback();
358 0 ▶ $self->throw("failed to update ontology '"
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
359 .$ont->name."' in database".($@ ? ": $@" : ""));
360 }
361  
362 # done - we don't commit here
363 0 ▶ return ref($result) ? $result : $ont;
Branch: 1 branch
BranchTrueFalseTotal
ref $result ? : 0 0 0
364 }
365  
366 0 ▶sub start_document {
Subroutine start_document: not called CC=2 SCAR=17.9
Pod undocumented
367 0 my $self = shift;
368 0 my $ont = $self->_ontology;
369 0 my @iprtypes = (
370 $self->create_term(-identifier=>'IPR:Family',
371 -name=>'Family',
372 -ontology => $ont),
373 $self->create_term(-identifier=>'IPR:Domain',
374 -name=>'Domain',
375 -ontology => $ont),
376 $self->create_term(-identifier=>'IPR:Repeat',
377 -name=>'Repeat',
378 -ontology => $ont),
379 $self->create_term(-identifier=>'IPR:PTM',
380 -name=>'post-translational modification',
381 -ontology => $ont),
382 $self->create_term(-identifier=>'IPR:Active_site',
383 -name=>'Active_site',
384 -ontology => $ont),
385 $self->create_term(-identifier=>'IPR:Binding_site',
386 -name=>'Binding_site',
387 -ontology => $ont),
388 );
389 0 foreach my $iprtype (@iprtypes) {
390 0 $self->_persist_term($iprtype);
391 0 $ont->add_term($iprtype);
392 }
393 }
394  
395 0 ▶sub start_element {
Subroutine start_element: not called CC=23 SCAR=63.1
Pod undocumented
396 0 my $self=shift;
397 0 my $tag=$_[0]->{Name};
398 0 my %args=%{$_[0]->{Attributes}};
399 0 my $ont = $self->_ontology;
400  
401 0 ▶ if($tag eq 'interpro'){
Branch: 9 branches
BranchTrueFalseTotal
if ($tag eq 'interpro') { } 0 0 0
elsif ($tag eq 'example') { } 0 0 0
elsif ($tag eq 'db_xref') { } 0 0 0
elsif ($tag eq 'publication') { } 0 0 0
elsif ($tag eq 'author_list') { } 0 0 0
elsif ($tag eq 'journal') { } 0 0 0
elsif ($tag eq 'location') { } 0 0 0
elsif ($tag eq 'year') { } 0 0 0
elsif ($tag eq 'dbinfo' and $self->_top_tag eq 'release') { } 0 0 0
402 0 my $id = $args{id};
403 0 my $term = $self->create_term(-identifier=>$id);
404 0 $term->ontology($ont);
405 0 $term->add_synonym($args{short_name});
406 #$term->definition();
407  
408 my ($object_term) =
409 0 ($ont->engine->get_term_by_identifier("IPR:".$args{type}));
410  
411 0 my $rel = Bio::Ontology::Relationship->new(
412 -subject_term => $term,
413 -predicate_term => $is_a_rel,
414 -object_term => $object_term,
415 -ontology => $ont
416 );
417 0 $self->_relationship($rel);
418 }elsif($tag eq 'example'){
419 0 my $example = Bio::Annotation::DBLink->new;
420 0 $self->_current_hash->{example} = $example;
421 }elsif($tag eq 'db_xref'){
422 0 my $top = $self->_top_tag;
423 0 ▶ if($top eq 'example'){
Branch: 7 branches
BranchTrueFalseTotal
if ($top eq 'example') { } 0 0 0
elsif ($top eq 'child') { } 0 0 0
elsif ($top eq 'member_list') { } 0 0 0
elsif ($top eq 'external_doc_list') { } 0 0 0
elsif ($top eq 'publication') { } 0 0 0
elsif ($top eq 'structure_db_links') { } 0 0 0
elsif ($top eq 'abstract') { } 0 0 0
424 0 my $example = $self->_current_hash->{example};
425 0 $example->database($args{db});
426 0 $example->primary_id($args{dbkey});
427 #print "EXAmPLE:\t", $example->database, '|', $example->primary_id, "\n";
428 }elsif($top eq 'child'){
429 ;
430 }elsif($top eq 'member_list'){
431 my $dblink=Bio::Annotation::DBLink->new(
432 -dbname => $args{id},
433 -primary_id => $args{dbkey},
434 -comment => $args{name}
435 0 );
436 }elsif($top eq 'external_doc_list'){
437 ;
438 }elsif($top eq 'publication'){
439 0 ▶ if($args{db} eq 'MEDLINE'){
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'db'} eq 'MEDLINE') { } 0 0 0
elsif ($args{'db'} eq 'PUBMED') { } 0 0 0
440 0 $self->_current_hash->{medline} =$args{dbkey};
441 } elsif($args{db} eq 'PUBMED'){
442 0 $self->_current_hash->{pubmed} =$args{dbkey};
443 }else{
444 0 $self->warn("'".$args{dbkey}."' is not a MEDLINE publication, "
445 ."don't know how to handle");
446 }
447 }elsif($top eq 'structure_db_links'){
448 ;
449 }elsif($top eq 'abstract'){
450 ;
451 }
452 #else{
453 # $self->warn("unrecognized element '$top' in element '$tag', ignoring");
454 #}
455 }elsif($tag eq 'publication'){
456 0 my $publication = Bio::Annotation::Reference->new();
457 0 $self->_current_hash->{publication} = $publication;
458 }elsif($tag eq 'author_list'){
459 ;
460 }elsif($tag eq 'journal'){
461 ;
462 }elsif($tag eq 'location'){
463 ;
464 }elsif($tag eq 'year'){
465 ;
466 ▶ } elsif (($tag eq 'dbinfo') && ($self->_top_tag eq 'release')) {
Condition0%0/3
$tag eq "dbinfo" and $self->_top_tag eq "release"
!ll&&!rl&&r
000
MC/DC0%0/2
$tag eq "dbinfo" and $self->_top_tag eq "release"
$tag eq "dbinfo" $self->_top_tag eq "release"
Truth table0%0/3
A and B
A= $tag eq "dbinfo"B= $self->_top_tag eq "release"
ABresult
0X0
100
111
467 0 ▶ my $entrydate = $args{file_date} || '';
Condition0%0/2
$args{'file_date'} || ''
l!l
00
MC/DC0%0/1
$args{'file_date'} || ''
$args{'file_date'}
Truth table0%0/2
A
A= $args{'file_date'}
Aresult
11
00
468 0 $entrydate =~ s/ \d{2}:\d{2}:\d{2}//;
469 0 ▶ my $def = $ont->definition() || '';
Condition0%0/2
$ont->definition || ''
l!l
00
MC/DC0%0/1
$ont->definition || ''
$ont->definition
Truth table0%0/2
A
A= $ont->definition
Aresult
11
00
470 0 ▶ $def .= "\n" if length($def) > 0;
Branch: 1 branch
BranchTrueFalseTotal
if length $def > 0 0 0 0
471 $def .= $args{dbname}." version ".$args{version}.", "
472 0 .$args{entry_count}." entries, ".$entrydate;
473 0 $ont->definition($def);
474 }
475 #else{
476 # $self->warn("unrecognized element '$tag', ignoring");
477 #}
478  
479 0 $self->_visited_count_inc($tag);
480 0 $self->_push_tag($tag);
481 }
482  
483  
484 0 ▶sub end_element {
Subroutine end_element: not called CC=10 SCAR=47.0
Pod undocumented
485 0 my $self=shift;
486 0 my $tag=shift->{Name};
487 0 my $chars_in=$self->_chars_hash->{$tag};
488 0 ▶ if($tag eq 'interpro'){
Branch: 8 branches
BranchTrueFalseTotal
if ($tag eq 'interpro') { } 0 0 0
elsif ($tag eq 'name') { } 0 0 0
elsif ($tag eq 'abstract') { } 0 0 0
elsif ($tag eq 'example') { } 0 0 0
elsif ($tag eq 'publication') { } 0 0 0
elsif ($tag eq 'author_list') { } 0 0 0
elsif ($tag eq 'title') { } 0 0 0
elsif ($tag eq 'release') { } 0 0 0
489 0 my $rel = $self->_relationship;
490 # store subject term first in order to give the handler a chance to
491 # apply whatever custom behaviour
492 # (note that the object term is the InterPro type and has been stored
493 # at the start of the whole document)
494 0 $self->_persist_term($rel->subject_term);
495 # the store the relationship to the InterPro type
496 0 $self->_persist_relationship($rel);
497 }elsif($tag eq 'name'){
498 0 my $rel = $self->_relationship;
499 0 $rel->subject_term->name($self->_chars_hash->{name});
500 0 $self->_chars_hash->{name}='';
501 }elsif($tag eq 'abstract'){
502 0 my $rel = $self->_relationship;
503 0 my $abstract = $self->_chars_hash->{abstract};
504 0 $abstract =~ s/\n/ /g;
505 0 $rel->subject_term->definition($abstract);
506 0 $self->_chars_hash->{abstract} = '';
507 }elsif($tag eq 'example'){
508 0 my $example = $self->_current_hash->{example};
509 0 my $comment = $self->_chars_hash->{example};
510 0 $comment =~ s/^(\s+)//; $comment =~ s/(\s+)$//;
511 0 $example->comment($comment);
512 0 $self->_relationship->subject_term->add_dbxref(-dbxrefs => [$example]);
513 0 $self->_chars_hash->{example}='';
514 }elsif($tag eq 'publication'){
515 0 my $publication = $self->_create_publication;
516 0 $self->_relationship->subject_term->add_reference($publication);
517 }elsif($tag eq 'author_list'){
518 0 $self->_current_hash->{author} =$chars_in;
519 }elsif($tag eq 'title'){
520 0 $self->_current_hash->{title}=$chars_in;
521 } elsif ($tag eq 'release') {
522 0 my $ont = $self->_persist_ontology($self->_ontology);
523 0 ▶ $self->_ontology($ont) if $ont;
Branch: 1 branch
BranchTrueFalseTotal
if $ont 0 0 0
524 }
525 0 $self->_pop_tag;
526 0 $self->_visited_count_dec($tag);
527 }
528  
529  
530 0 ▶sub characters {
Subroutine characters: not called CC=1 SCAR=6.9
Pod undocumented
531 0 my $self=shift;
532 0 my $text = shift->{Data};
533  
534 0 my $top_tag =$self->_top_tag;
535 0 $self->_chars_hash->{$top_tag} .= $text;
536  
537 # $self->_chars_hash->{abstract} .= $text if $self->_visited_count('abstract');
538 }
539  
540 0 ▶sub create_term {
Subroutine create_term: not called CC=1 SCAR=6.9
Pod undocumented
541 0 return shift->term_factory->create_object(@_);
542 }
543  
544 0 ▶sub _ontology {
Subroutine _ontology: not called CC=2 SCAR=17.9
545 0 my $self = shift;
546 0 ▶ return $self->{_ontology}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
547 0 return $self->{_ontology};
548 }
549  
550 0 ▶sub _relationship {
Subroutine _relationship: not called CC=2 SCAR=17.9
551 0 my $self =shift;
552 0 ▶ $self->{_relationship}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
553 0 return $self->{_relationship};
554 }
555 0 ▶sub _create_publication {
Subroutine _create_publication: not called CC=8 SCAR=42.8
556 0 my $self=shift;
557 0 my $publ = $self->_current_hash->{publication};
558 0 ▶ my $journal = $self->_current_hash->{journal} || '<no journal>';
Condition0%0/2
$self->_current_hash->{'journal'} || '<no journal>'
l!l
00
MC/DC0%0/1
$self->_current_hash->{'journal'} || '<no journal>'
$self->_current_hash->{'journal'}
Truth table0%0/2
A
A= $self->_current_hash->{'journal'}
Aresult
11
00
559 0 ▶ my $year = $self->_current_hash->{year} || '<no year>';
Condition0%0/2
$self->_current_hash->{'year'} || '<no year>'
l!l
00
MC/DC0%0/1
$self->_current_hash->{'year'} || '<no year>'
$self->_current_hash->{'year'}
Truth table0%0/2
A
A= $self->_current_hash->{'year'}
Aresult
11
00
560 0 ▶ my $page_location = $self->_current_hash->{page_location} || '<no pages>';
Condition0%0/2
$self->_current_hash->{'page_location'} || '<no pages>'
l!l
00
MC/DC0%0/1
$self->_current_hash->{'page_location'} || '<no pages>'
$self->_current_hash->{'page_location'}
Truth table0%0/2
A
A= $self->_current_hash->{'page_location'}
Aresult
11
00
561 0 ▶ my $volumn = $self->_current_hash->{volumn} || '<no volume>';
Condition0%0/2
$self->_current_hash->{'volumn'} || '<no volume>'
l!l
00
MC/DC0%0/1
$self->_current_hash->{'volumn'} || '<no volume>'
$self->_current_hash->{'volumn'}
Truth table0%0/2
A
A= $self->_current_hash->{'volumn'}
Aresult
11
00
562 my $medline =
563 0 ▶ $self->_current_hash->{medline} || $self->_current_hash->{pubmed};
Condition0%0/3
$self->_current_hash->{'medline'} || $self->_current_hash->{'pubmed'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_current_hash->{'medline'} || $self->_current_hash->{'pubmed'}
$self->_current_hash->{'medline'} $self->_current_hash->{'pubmed'}
Truth table0%0/3
A || B
A= $self->_current_hash->{'medline'}B= $self->_current_hash->{'pubmed'}
ABresult
1X1
011
000
564  
565 0 $publ->authors($self->_current_hash->{author});
566 0 $publ->location("$journal, $year, V $volumn, $page_location");
567 0 $publ->title($self->_current_hash->{title});
568 0 $publ->medline($medline);
569 0 ▶ if ($self->_current_hash->{pubmed}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_current_hash->{"pubmed"} and $self->_current_hash->{"pubmed"} != $medline) 0 0 0
Condition0%0/3
$self->_current_hash->{"pubmed"} and $self->_current_hash->{"pubmed"} != $medline
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_current_hash->{"pubmed"} and $self->_current_hash->{"pubmed"} != $medline
$self->_current_hash->{"pubmed"} $self->_current_hash->{"pubmed"} != $medline
Truth table0%0/3
A and B
A= $self->_current_hash->{"pubmed"}B= $self->_current_hash->{"pubmed"} != $medline
ABresult
0X0
100
111
570 && ($self->_current_hash->{pubmed} != $medline)) {
571 0 $publ->pubmed($self->_current_hash->{pubmed});
572 }
573  
574 # Clear the above in current hash
575 0 $self->_current_hash->{publication} = undef;
576 0 $self->_current_hash->{author} = undef;
577 0 $self->_current_hash->{journal} = undef;
578 0 $self->_current_hash->{year} = undef;
579 0 $self->_current_hash->{page_location}=undef;
580 0 $self->_current_hash->{volumn} = undef;
581 0 $self->_current_hash->{title} = undef;
582 0 $self->_current_hash->{medline} = undef;
583 0 $self->_current_hash->{pubmed} = undef;
584 }
585 1 1;
« Bio/SearchIO/Writer/HTMLResultWriter.pm ↑ Summary Bio/Ontology/InterProTerm.pm »