| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::OntologyIO::obo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Cared for by Sohel Merchant, s-merchant at northwestern.edu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Copyright Sohel Merchant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | Bio::OntologyIO::obo - parser for OBO flat-file format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | use Bio::OntologyIO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # do not use directly -- use via Bio::OntologyIO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | my $parser = Bio::OntologyIO->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ( -format => "obo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | -file => "gene_ontology.obo"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | while(my $ont = $parser->next_ontology()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | print "read ontology ",$ont->name()," with ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | scalar($ont->get_root_terms), " root terms, and ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | scalar($ont->get_all_terms), " total terms, and ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | scalar($ont->get_leaf_terms), " leaf terms\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Parser for OBO flat-file format. 'obo' example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | format-version: 1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ontology: so/dev/externalDerived | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | property_value: owl:versionInfo "$Revision: 80 $" xsd:string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | default-namespace: SO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | [Term] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | id: SO_0000343 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | name: match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | def: "A region of sequence, aligned to another sequence." [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | [Term] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | id: SO_0000039 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | name: match_part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | def: "A part of a match." [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | is_a: SO_0000343 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | Specification: L<http://www.geneontology.org/GO.format.obo-1_2.shtml>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Bioperl modules. Send your comments and suggestions preferably to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | Bioperl mailing lists Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | web: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | Sohel Merchant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | Email: s-merchant@northwestern.edu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Address: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | Northwestern University | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | Center for Genetic Medicine (CGM), dictyBase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Suite 1206, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 676 St. Clair st | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | Chicago IL 60611 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | =head2 CONTRIBUTOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | Hilmar Lapp, hlapp at gmx.net | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | Chris Mungall, cjm at fruitfly.org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | Brian Osborne, briano@bioteam.net | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | package Bio::OntologyIO::obo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $Bio::OntologyIO::obo::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | use Bio::Root::IO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | use Bio::Ontology::OBOEngine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | use Bio::Ontology::Ontology; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | use Bio::Ontology::OntologyStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | use Bio::Ontology::TermFactory; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | use Bio::Annotation::Collection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | use Text::Balanced qw(extract_quotelike extract_bracketed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | use constant TRUE => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | use constant FALSE => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | ▶ | use base qw(Bio::OntologyIO); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | Title : new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | Usage : $parser = Bio::OntologyIO->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | -format => "obo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | -file => "gene_ontology.obo"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Function: Creates a new dagflat parser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | Returns : A new dagflat parser object, implementing Bio::OntologyIO. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | Args : -file => a single ontology flat file holding the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | terms, descriptions and relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | -ontology_name => the name of the ontology; if not specified the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | parser will assign the name of the ontology as the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | default-namespace header value from the OBO file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | -engine => the Bio::Ontology::OntologyEngineI object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | to be reused (will be created otherwise); note | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | that every Bio::Ontology::OntologyI will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | qualify as well since that one inherits from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | former. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | See L<Bio::OntologyIO>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # Let OntologyIO::new() do the instantiation, and override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # _initialize for all initialization work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=5 SCAR=18.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 3 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | my ( $file, $name, $eng ) = $self->_rearrange( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | [ qw( FILE ONTOLOGY_NAME ENGINE) ], %arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | $self->SUPER::_initialize(%arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | delete $self->{'_ontologies'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # Ontology engine (and possibly name if it's an OntologyI) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | ▶ | $eng = Bio::Ontology::OBOEngine->new() unless $eng; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | if ( $eng->isa("Bio::Ontology::OntologyI") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->ontology_name( $eng->name() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | $eng = $eng->engine() if $eng->can('engine'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | $self->_ont_engine($eng); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | $self->ontology_name($name) if $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | =head2 ontology_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | Title : ontology_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | Usage : $obj->ontology_name($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | Function: Get/set the name of the ontology parsed by this module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | Returns : value of ontology_name (a scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | ▶ | sub ontology_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ontology_name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | ▶ | return $self->{'ontology_name'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | return $self->{'ontology_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | =head2 parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | Title : parse() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | Usage : $parser->parse(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Function: Parses the files set with "new" or with methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | defs_file and _flat_files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Normally you should not need to call this method as it will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | be called automatically upon the first call to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | next_ontology(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | Returns : Bio::Ontology::OntologyEngineI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=18 SCAR=29.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Setup the default term factory if not done by anyone yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | ▶ | $self->term_factory(Bio::Ontology::TermFactory->new( -type => "Bio::Ontology::OBOterm" ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | unless $self->term_factory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # Parse the file header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | my $annotations_collection = $self->_header(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # Create the default ontology object itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | my $ont = Bio::Ontology::Ontology->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | -name => $self->ontology_name(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | -engine => $self->_ont_engine() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # Assign the file headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | $ont->annotation($annotations_collection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Set up the ontology of the relationship types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | for ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | $self->_part_of_relationship(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $self->_is_a_relationship(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | $self->_related_to_relationship(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | $self->_regulates_relationship(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $self->_positively_regulates_relationship(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | $self->_negatively_regulates_relationship(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 18 | $_->ontology($ont); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | $self->_add_ontology($ont); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Adding new terms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 3 | ▶ | while ( my $term = $self->_next_term() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # Check if the terms has a valid ID and NAME otherwise ignore the term | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1021 | ▶ | if ( !$term->identifier() || !$term->name() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$term->identifier and $term->name
MC/DC0%0/2
$term->identifier and $term->name
$term->identifier
$term->name
Truth table33%1/3
A and B
A= $term->identifierB= $term->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | $self->throw( "OBO File Format Error on line " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | . $self->{'_current_line_no'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | . "\nThe term does not have a id/name tag. This term will be ignored." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1021 | my $new_ontology_flag = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1021 | my $ontologies_array_ref = $self->{'_ontologies'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1021 | for my $ontology ( @$ontologies_array_ref ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1037 | my ($oname, $t_ns) = ( $ontology->name, $term->namespace ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1037 | ▶ | next unless ( defined($oname) && defined($t_ns) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $oname and defined $t_ns
MC/DC50%1/2
defined $oname and defined $t_ns
defined $oname
defined $t_ns
Truth table66%2/3
A and B
A= defined $onameB= defined $t_ns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 187 | ▶ | if ( $oname eq $t_ns ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # No need to create new ontology | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 169 | $new_ontology_flag = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 169 | $ont = $ontology; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1021 | ▶ | if ( $new_ontology_flag && $term->namespace ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$new_ontology_flag and $term->namespace
MC/DC100%2/2
$new_ontology_flag and $term->namespace
$new_ontology_flag
$term->namespace
Truth table100%3/3
A and B
A= $new_ontology_flagB= $term->namespace
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | my $new_ont = Bio::Ontology::Ontology->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | -name => $term->namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | -engine => $self->_ont_engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | $new_ont->annotation($annotations_collection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | $self->_add_ontology($new_ont); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | $ont = $new_ont; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1021 | $self->_add_term( $term, $ont ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # Adding the IS_A relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1021 | for my $parent_term ( @{$self->{'_isa_parents'}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # Check if parent exists, if not then add the term to the graph. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 990 | ▶ | if ( ! $self->_has_term($parent_term) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 97 | $self->_add_term( $parent_term, $ont ); # ! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 990 | $self->_add_relationship( $parent_term, $term, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | $self->_is_a_relationship(), $ont ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # Adding the other relationships like part_of, related_to, develops_from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1021 | for my $relationship ( keys %{$self->{'_relationships'}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 139 | my $reltype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # Check if relationship exists, if not add it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 139 | ▶ | if ( $self->_ont_engine->get_relationship_type($relationship) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 130 | $reltype = $self->_ont_engine->get_relationship_type($relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 9 | $self->_ont_engine->add_relationship_type( $relationship, $ont ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 9 | $reltype = $self->_ont_engine->get_relationship_type($relationship); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Check if the id already exists in the graph | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 139 | for my $id ( @{$self->{'_relationships'}->{$relationship}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 241 | my $parent_term = $self->_create_term_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 241 | $parent_term->identifier($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 241 | $parent_term->ontology($ont); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 241 | ▶ | if ( ! $self->_has_term($parent_term) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 66 | $self->_add_term( $parent_term, $ont ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 241 | $self->_add_relationship( $parent_term, $term, $reltype, $ont ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | return $self->_ont_engine(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | =head2 next_ontology | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | Title : next_ontology | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | Function: Get the next available ontology from the parser. This is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | method prescribed by Bio::OntologyIO. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | Returns : An object implementing Bio::Ontology::OntologyI, and nothing if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | there is no more ontology in the input. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 6 | ▶ | sub next_ontology { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_ontology: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # Parse if not done already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 6 | ▶ | $self->parse() unless exists( $self->{'_ontologies'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # Return next available ontology | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | ▶ | if ( exists( $self->{'_ontologies'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | my $ont = shift( @{ $self->{'_ontologies'} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | ▶ | if ($ont) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 5 | my $store = Bio::Ontology::OntologyStore->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 5 | $store->register_ontology($ont); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 5 | return $ont; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | =head2 close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | Title : close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | Function: Closes this ontology stream and associated file handles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | Clients should call this method especially when they write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ontologies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | We need to override this here in order to close the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | handle for the term definitions file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # first call the inherited implementation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 3 | $self->SUPER::close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # INTERNAL METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | ▶ | sub _add_ontology { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_ontology: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | ▶ | $self->{'_ontologies'} = [] unless exists( $self->{'_ontologies'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 5 | for my $ont (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 5 | ▶ | $self->throw( ref($ont) . " does not implement Bio::Ontology::OntologyI" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $ont and $ont->isa("Bio::Ontology::OntologyI")
MC/DC0%0/2
ref $ont and $ont->isa("Bio::Ontology::OntologyI")
ref $ont
$ont->isa("Bio::Ontology::OntologyI")
Truth table33%1/3
A and B
A= ref $ontB= $ont->isa("Bio::Ontology::OntologyI")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | unless ref($ont) && $ont->isa("Bio::Ontology::OntologyI"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # The ontology name may have been auto-discovered while parsing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 5 | ▶ | $ont->name( $self->ontology_name ) unless $ont->name(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 5 | push( @{ $self->{'_ontologies'} }, $ont ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # This simply delegates. See Ontology::OBOEngine::add_term. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1184 | ▶ | sub _add_term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_term: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1184 | my ( $self, $term, $ont ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1184 | ▶ | $term->ontology($ont) if $ont && ( !$term->ontology ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ont and not $term->ontology
MC/DC50%1/2
$ont and not $term->ontology
$ont
not $term->ontology
Truth table66%2/3
A and not(B)
A= $ontB= not $term->ontology
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1184 | $self->_ont_engine()->add_term($term); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | ▶ | sub _part_of_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_part_of_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | return $self->_ont_engine()->part_of_relationship(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 993 | ▶ | sub _is_a_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_a_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 993 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 993 | return $self->_ont_engine()->is_a_relationship(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 3 | ▶ | sub _related_to_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_related_to_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | return $self->_ont_engine()->related_to_relationship(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 3 | ▶ | sub _regulates_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_regulates_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | return $self->_ont_engine()->regulates_relationship(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | ▶ | sub _positively_regulates_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_positively_regulates_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | return $self->_ont_engine()->positively_regulates_relationship(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | ▶ | sub _negatively_regulates_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_negatively_regulates_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | return $self->_ont_engine()->negatively_regulates_relationship(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1231 | ▶ | sub _add_relationship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_relationship: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1231 | my ( $self, $parent, $child, $type, $ont ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # Note the triple terminology (subject,predicate,object) corresponds to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # (child,type,parent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1231 | $self->_ont_engine()->add_relationship( $child, $type, $parent, $ont ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # This simply delegates. See OBOEngine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2252 | ▶ | sub _has_term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_term: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2252 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 2252 | return $self->_ont_engine()->has_term(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # Holds the OBO engine to be parsed into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 6136 | ▶ | sub _ont_engine { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ont_engine: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 6136 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 6136 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | $self->{"_ont_engine"} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 6136 | $self->{"_ont_engine"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # Removes the escape characters from the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 6614 | ▶ | sub _filter_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_line: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 6614 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 6614 | chomp($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 6614 | $line =~ tr [\200-\377] [\000-\177]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # see 'man perlop', section on tr/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # weird ascii characters should be excluded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 6614 | $line =~ tr/\0-\10//d; # remove weird characters; ascii 0-8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # preserve \11 (9 - tab) and \12 (10-linefeed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 6614 | $line =~ tr/\13\14//d; # remove weird characters; 11,12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # preserve \15 (13 - carriage return) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 6614 | $line =~ tr/\16-\37//d; # remove 14-31 (all rest before space) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 6614 | $line =~ tr/\177//d; # remove DEL character | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 6614 | $line =~ s/^\!.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 6614 | $line =~ s/[^\\]\!.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 6614 | $line =~ s/[^\\]\#.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 6614 | $line =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 6614 | $line =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 6614 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # Parses the header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 3 | ▶ | sub _header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header: called CC=10 SCAR=23.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 3 | my $annotation_collection = Bio::Annotation::Collection->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | my ( $tag, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | my $line_counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | $self->{'_current_line_no'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | my $format_version_header_flag = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 3 | my $default_namespace_header_flag = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 3 | ▶ | while ( my $line = $self->_readline() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 24 | ++$line_counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 24 | my $line = $self->_filter_line($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 24 | ▶ | if ( !$line ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | ▶ | if ( !$format_version_header_flag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $self->throw("Format Error - Cannot find tag format-version." . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | "This is required in header" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 3 | $self->{'_current_line_no'} = $line_counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | return $annotation_collection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | # Check if there is a header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 21 | ▶ | if ( $line =~ /\[\w*\]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->throw("Format Error - Cannot find tag format-version." . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | "This is required in header." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # If the line is not null, check it contains at least one colon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 21 | $self->_check_colon( $line, $line_counter ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # These are the allowed headers. Any other headers will be ignored | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 21 | ▶ | if ( $line =~ /^(\[|format-version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |data-version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |typeref: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |date: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |saved-by: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |auto-generated-by: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |default-namespace: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |remark: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |subsetdef: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |import: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |synonymtypedef: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |idspace: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |default-relationship-id-prefix: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |id-mapping: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | )/x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 21 | ▶ | if ( $line =~ /^([\w\-]+)\:\s*(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 21 | ( $tag, $value ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 21 | ▶ | if ( $tag =~ /format-version/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 3 | $format_version_header_flag = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | }elsif( $tag =~ /default-namespace/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 3 | $default_namespace_header_flag = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 21 | my $header = Bio::Annotation::SimpleValue->new( -value => $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 21 | $annotation_collection->add_Annotation( $tag, $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # Assign the Ontology name as the value of the default-namespace header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 21 | ▶ | if ( $tag =~ /default-namespace/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 3 | $self->ontology_name($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # Parses each stanza of the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1024 | ▶ | sub _next_term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_next_term: called CC=28 SCAR=34.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1024 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1024 | my $term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1024 | my $skip_stanza_flag = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1024 | my $line_counter = $self->{'_current_line_no'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1024 | ▶ | while ( my $line = $self->_readline() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 6590 | ++$line_counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 6590 | my $line = $self->_filter_line($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 6590 | ▶ | if ( !$line && $term ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $line and $term
MC/DC100%2/2
not $line and $term
not $line
$term
Truth table100%3/3
not(A) and B
A= not $lineB= $term
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1021 | $self->{'_current_line_no'} = $line_counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 1021 | return $term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 5569 | ▶ | if ( ( $line =~ /^\[(\w+)\]\s*(.*)/ ) ) { # New stanza | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1039 | ▶ | if ( uc($1) eq "TERM" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1021 | $term = $self->_create_term_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1021 | $skip_stanza_flag = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # Reset the relationships after each stanza | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 1021 | $self->{'_relationships'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1021 | $self->{'_isa_parents'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | elsif ( uc($1) eq "TYPEDEF" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 18 | $skip_stanza_flag = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # Check if this typedef is already defined by the relationship | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $skip_stanza_flag = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $self->warn("OBO File Format Warning on line $line_counter $line\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | . "Unrecognized stanza type found. Skipping this stanza." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 1039 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | # If the line is not null, check it contains at least one colon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 4530 | $self->_check_colon( $line, $line_counter ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # If there is any tag value other than the list below move to the next tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 4530 | ▶ | next if (( $line !~ /^(\[|id: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $line =~ /^(\[|id:
|is_anonymous:
|name:
|namespace:
|alt_id:
|def:
|comment:
|subset:
|synonym:
|xref:
|is_a:
|intersection_of:
|union_of:
|disjoint_from:
|relationship:
|is_obsolete:
|replaced_by:
|consider:
|created_by:
|creation_date:
)/x or $skip_stanza_flag
MC/DC100%2/2
not $line =~ /^(\[|id:
|is_anonymous:
|name:
|namespace:
|alt_id:
|def:
|comment:
|subset:
|synonym:
|xref:
|is_a:
|intersection_of:
|union_of:
|disjoint_from:
|relationship:
|is_obsolete:
|replaced_by:
|consider:
|created_by:
|creation_date:
)/x or $skip_stanza_flag
not $line =~ /^(\[|id:
|is_anonymous:
|name:
|namespace:
|alt_id:
|def:
|comment:
|subset:
|synonym:
|xref:
|is_a:
|intersection_of:
|union_of:
|disjoint_from:
|relationship:
|is_obsolete:
|replaced_by:
|consider:
|created_by:
|creation_date:
)/x
$skip_stanza_flag
Truth table100%3/3
not(A) or B
A= not $line =~ /^(\[|id:
|is_anonymous:
|name:
|namespace:
|alt_id:
|def:
|comment:
|subset:
|synonym:
|xref:
|is_a:
|intersection_of:
|union_of:
|disjoint_from:
|relationship:
|is_obsolete:
|replaced_by:
|consider:
|created_by:
|creation_date:
)/xB= $skip_stanza_flag
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |is_anonymous: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |name: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |namespace: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |alt_id: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |def: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |comment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |subset: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |synonym: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |xref: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |is_a: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |intersection_of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |union_of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |disjoint_from: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |relationship: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |is_obsolete: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |replaced_by: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |consider: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |created_by: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |creation_date: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | )/x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | ) || $skip_stanza_flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # Tag/value pair | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 4444 | ▶ | if ( $line =~ /^([\w\-]+)\:\s*(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 4444 | my ( $tag, $val ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # If no value for the tag throw a warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 4444 | ▶ | if ( !$val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $self->warn("OBO File Format Warning on line $line_counter $line\n" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | "Tag has no value." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 4444 | my $qh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 4444 | ( $val, $qh ) = $self->_extract_quals($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 4444 | my $val2 = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 4444 | $val2 =~ s/\\,/,/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 4444 | $tag = uc($tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 4444 | ▶ | if ( $tag eq "ID" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1021 | $term->identifier($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1021 | ▶ | if ( $self->_has_term($term) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 163 | $term = $self->_ont_engine()->get_terms($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | elsif ( $tag eq "NAME" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 1021 | $term->name($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | elsif ( $tag eq "XREF_ANALOG" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if ( !$term->has_dbxref($val) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $term->add_dbxref(-dbxrefs => $self->_to_annotation( [$val] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | elsif ( $tag eq "XREF_UNKNOWN" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $term->add_dbxref(-dbxrefs => $self->_to_annotation( [$val] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | elsif ( $tag eq "NAMESPACE" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 10 | $term->namespace($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | elsif ( $tag eq "DEF" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 575 | my ( $defstr, $parts ) = $self->_extract_qstr($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 575 | $term->definition($defstr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 575 | my $ann = $self->_to_annotation($parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 575 | $term->add_dbxref( -dbxrefs => $ann ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | elsif ( $tag eq "SYNONYM" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 293 | $term->add_synonym($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | elsif ( $tag eq "ALT_ID" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 1 | $term->add_secondary_id($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | elsif ( $tag =~ /XREF/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 6 | $term->add_secondary_id($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | elsif ( $tag eq "IS_OBSOLETE" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 19 | ▶ | if ( $val eq 'true' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 19 | $val = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | elsif ( $val eq 'false' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $val = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 19 | $term->is_obsolete($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | elsif ( $tag eq "COMMENT" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 44 | $term->comment($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | elsif ( $tag eq "RELATIONSHIP" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 241 | $self->_handle_relationship_tag($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | elsif ( $tag eq "IS_A" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 990 | $val =~ s/ //g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 990 | my $parent_term = $self->_create_term_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 990 | $parent_term->identifier($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 990 | push @{ $self->{'_isa_parents'} }, $parent_term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 3 | $term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | # Creates a Bio::Ontology::OBOterm object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 2252 | ▶ | sub _create_term_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_term_object: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 2252 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2252 | my $term = $self->term_factory->create_object(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 2252 | $term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 4444 | ▶ | sub _extract_quals { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_quals: called CC=6 SCAR=31.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 4444 | my ( $self, $str ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 4444 | my %q = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 4444 | ▶ | if ( $str =~ /(.*)\s+(\{.*\})\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my $return_str = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my $extr = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if ($extr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my @qparts = $self->_split_on_comma($extr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | foreach (@qparts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if (/(\w+)=\"(.*)\"/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $q{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | elsif (/(\w+)=\'(.*)\'/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | $q{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | warn("$_ in $str"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | return ( $return_str, \%q ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 4444 | return ( $str, {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 575 | ▶ | sub _extract_qstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_qstr: called CC=6 SCAR=18.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 575 | my ( $self, $str ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 575 | my ( $extr, $rem, $prefix ) = extract_quotelike($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 575 | my $txt = $extr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 575 | $txt =~ s/^\"//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 575 | $txt =~ s/\"$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 575 | ▶ | if ($prefix) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | warn("illegal prefix: $prefix in: $str"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 575 | my @extra = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # e.g. synonym: "foo" EXACT [...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 575 | ▶ | if ( $rem =~ /(\w+)\s+(\[.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | $rem = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | push( @extra, split( ' ', $1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 575 | my @parts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 575 | ▶ | while ( ( $extr, $rem, $prefix ) = extract_bracketed( $rem, '[]' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 1054 | ▶ | last unless $extr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 479 | $extr =~ s/^\[//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 479 | $extr =~ s/\]$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 479 | ▶ | push( @parts, $extr ) if $extr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | @parts = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 575 | map { $self->_split_on_comma($_) } @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 575 | $txt =~ s/\\//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 575 | ( $txt, \@parts, \@extra ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 479 | ▶ | sub _split_on_comma { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_on_comma: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 479 | my ( $self, $str ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 479 | my @parts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 479 | ▶ | while ( $str =~ /(.*[^\\],\s*)(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 5 | $str = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 5 | my $part = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 5 | unshift( @parts, $part ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 5 | $str =~ s/,\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 479 | unshift( @parts, $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 479 | return map { s/\\//g; $_ } @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | # This method checks for an existing colon in a line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 4551 | ▶ | sub _check_colon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_colon: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 4551 | my ( $self, $line, $line_no ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 4551 | ▶ | if ( $line && !( $line =~ /:/ ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line and not $line =~ /:/
MC/DC0%0/2
$line and not $line =~ /:/
$line
not $line =~ /:/
Truth table66%2/3
A and not(B)
A= $lineB= not $line =~ /:/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $self->throw("OBO File Format Error on line $line_no $line\n" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | "Cannot find key-terminating colon" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | # This method handles relationship tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 241 | ▶ | sub _handle_relationship_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_relationship_tag: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 241 | my ( $self, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 241 | my @parts = split( / /, $val ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 241 | my $relationship = uc($parts[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 241 | ▶ | my $id = $parts[1] =~ /\^(w+)\s+\!/ ? $1 : $parts[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 241 | push @{$self->{_relationships}->{$relationship}}, $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # Convert simple strings to Bio::Annotation::DBLinks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 575 | ▶ | sub _to_annotation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_annotation: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 575 | my ($self , $links) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 575 | ▶ | return unless $links; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 575 | my @dbxrefs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 575 | for my $string (@{$links}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 484 | my ($db, $id) = split(':',$string,2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 484 | push @dbxrefs, Bio::Annotation::DBLink->new(-database => $db, -primary_id => $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 575 | \@dbxrefs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||