File Coverage

Bio/OntologyIO/goflat.pm
Criterion Covered Total %
statement 18 18 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 25 26 96.1


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::OntologyIO::goflat
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Christian M. Zmasek or
7             #
8             # (c) Christian M. Zmasek, czmasek-at-burnham.org, 2002.
9             # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
10             #
11             # You may distribute this module under the same terms as perl itself.
12             # Refer to the Perl Artistic License (see the license accompanying this
13             # software package, or see http://www.perl.com/language/misc/Artistic.html)
14             # for the terms under which you may use, modify, and redistribute this module.
15             #
16             # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
17             # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18             # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19             #
20             # You may distribute this module under the same terms as perl itself
21              
22             # POD documentation - main docs before the code
23              
24             =head1 NAME
25              
26             Bio::OntologyIO::goflat - a parser for the Gene Ontology flat-file format
27              
28             =head1 SYNOPSIS
29              
30             use Bio::OntologyIO;
31              
32             # do not use directly -- use via Bio::OntologyIO
33             my $parser = Bio::OntologyIO->new
34             ( -format => "go",
35             -defs_file => "/home/czmasek/GO/GO.defs",
36             -files => ["/home/czmasek/GO/component.ontology",
37             "/home/czmasek/GO/function.ontology",
38             "/home/czmasek/GO/process.ontology"] );
39              
40             my $go_ontology = $parser->next_ontology();
41              
42             my $IS_A = Bio::Ontology::RelationshipType->get_instance( "IS_A" );
43             my $PART_OF = Bio::Ontology::RelationshipType->get_instance( "PART_OF" );
44              
45             =head1 DESCRIPTION
46              
47             Needs Graph.pm from CPAN.
48              
49             This is essentially a very thin derivation of the dagflat parser.
50              
51             =head1 FEEDBACK
52              
53             =head2 Mailing Lists
54              
55             User feedback is an integral part of the evolution of this and other
56             Bioperl modules. Send your comments and suggestions preferably to the
57             Bioperl mailing lists Your participation is much appreciated.
58              
59             bioperl-l@bioperl.org - General discussion
60             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
61              
62             =head2 Support
63              
64             Please direct usage questions or support issues to the mailing list:
65              
66             I
67              
68             rather than to the module maintainer directly. Many experienced and
69             reponsive experts will be able look at the problem and quickly
70             address it. Please include a thorough description of the problem
71             with code and data examples if at all possible.
72              
73             =head2 Reporting Bugs
74              
75             Report bugs to the Bioperl bug tracking system to help us keep track
76             the bugs and their resolution. Bug reports can be submitted via the
77             web:
78              
79             https://github.com/bioperl/bioperl-live/issues
80              
81             =head1 AUTHOR
82              
83             Christian M. Zmasek
84              
85             Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
86              
87             WWW: http://monochrome-effect.net/
88              
89             Address:
90              
91             Genomics Institute of the Novartis Research Foundation
92             10675 John Jay Hopkins Drive
93             San Diego, CA 92121
94              
95             =head2 CONTRIBUTOR
96              
97             Hilmar Lapp, hlapp at gmx.net
98              
99             =head1 APPENDIX
100              
101             The rest of the documentation details each of the object
102             methods. Internal methods are usually preceded with a _
103              
104             =cut
105              
106              
107             # Let the code begin...
108              
109              
110             package Bio::OntologyIO::goflat;
111              
112 1     1   4 use strict;
  1         1  
  1         24  
113              
114 1     1   339 use Bio::Ontology::TermFactory;
  1         2  
  1         21  
115              
116 1     1   3 use constant TRUE => 1;
  1         1  
  1         42  
117 1     1   3 use constant FALSE => 0;
  1         1  
  1         33  
118              
119              
120 1     1   3 use base qw(Bio::OntologyIO::dagflat);
  1         2  
  1         395  
121              
122              
123             =head2 new
124              
125             Title : new
126             Usage : $parser = Bio::OntologyIO->new(
127             -format => "go",
128             -defs_file => "/path/to/GO.defs",
129             -files => ["/path/to/component.ontology",
130             "/path/to/function.ontology",
131             "/path/to/process.ontology"] );
132             Function: Creates a new goflat parser.
133             Returns : A new goflat parser object, implementing Bio::OntologyIO.
134             Args : -defs_file => the name of the file holding the term
135             definitions
136             -files => a single ontology flat file holding the
137             term relationships, or an array ref holding
138             the file names (for GO, there will usually be
139             3 files: component.ontology, function.ontology,
140             process.ontology)
141             -file => if there is only a single flat file, it may
142             also be specified via the -file parameter
143             -ontology_name => the name of the ontology; if not specified the
144             parser will auto-discover it by using the term
145             that starts with a $, and converting underscores
146             to spaces
147             -engine => the Bio::Ontology::OntologyEngineI object
148             to be reused (will be created otherwise); note
149             that every Bio::Ontology::OntologyI will
150             qualify as well since that one inherits from the
151             former.
152              
153             See L.
154              
155             =cut
156              
157             # in reality, we let OntologyIO::new do the instantiation, and override
158             # _initialize for all initialization work
159             sub _initialize {
160 3     3   5 my ($self, @args) = @_;
161            
162 3         9 $self->SUPER::_initialize( @args );
163              
164             # default term object factory
165 3 50       12 $self->term_factory(Bio::Ontology::TermFactory->new(
166             -type => "Bio::Ontology::GOterm"))
167             unless $self->term_factory();
168              
169             } # _initialize
170              
171            
172             1;