t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / Ontology / DocumentRegistry.pm
blobb0e8be1554b9e7bc5caabda997748f891a26adca
2 # BioPerl module for Bio::Ontology::DocumentRegistry
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Allen Day <allenday@ucla.edu>
8 # Copyright Allen Day
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Ontology::DocumentRegistry - Keep track of where to find ontologies.
17 Allows lookups by name.
19 =head1 SYNOPSIS
21 my $registry = Bio::Ontology::DocumentRegistry->get_instance();
22 my($ont,$def,$fmt) = $registry->documents('Sequence Ontology');
24 my $io = Bio::OntologyIO->new(-url => $ont,
25 -defs_url => $def,
26 -format => $fmt);
27 my $so = $io->next_ontology();
28 #...
30 =head1 DESCRIPTION
32 Do not use this directly, use Bio::Ontology::OntologyStore instead.
33 Bio::Ontology::OntologyStore uses Bio::Ontology::DocumentRegistry to
34 load and cache ontologies as object graphs, you can just ask it for
35 what you want by name. See L<Bio::Ontology::OntologyStore> for
36 details.
38 =head1 FEEDBACK
40 =head2 Mailing Lists
42 User feedback is an integral part of the evolution of this and other
43 Bioperl modules. Send your comments and suggestions preferably to
44 the Bioperl mailing list. Your participation is much appreciated.
46 bioperl-l@bioperl.org - General discussion
47 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 =head2 Support
51 Please direct usage questions or support issues to the mailing list:
53 I<bioperl-l@bioperl.org>
55 rather than to the module maintainer directly. Many experienced and
56 reponsive experts will be able look at the problem and quickly
57 address it. Please include a thorough description of the problem
58 with code and data examples if at all possible.
60 =head2 Reporting Bugs
62 Report bugs to the Bioperl bug tracking system to help us keep track
63 of the bugs and their resolution. Bug reports can be submitted via
64 the web:
66 https://github.com/bioperl/bioperl-live/issues
68 =head1 AUTHOR - Allen Day
70 Email allenday@ucla.edu
72 =head1 APPENDIX
74 The rest of the documentation details each of the object methods.
75 Internal methods are usually preceded with a _
77 =cut
80 # Let the code begin...
82 package Bio::Ontology::DocumentRegistry;
83 use strict;
84 use base qw(Bio::Root::Root);
85 use Data::Dumper;
87 my $instance;
89 BEGIN {
90 $instance = {
91 'Sequence Ontology' => {
92 ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.ontology?rev=HEAD",
93 definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD",
94 format => 'soflat',
96 'Sequence Ontology OBO' => {
97 ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.obo?rev=HEAD",
98 definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD",
99 format => 'obo',
102 #### TODO Server http://umn.dl.sourceforge.net/ does not respond, are there
103 #### alternative sources?
104 'Sequence Ontology Feature Annotation' => {
105 ontology => 'http://umn.dl.sourceforge.net/sourceforge/song/sofa.ontology',
106 definitions =>'http://umn.dl.sourceforge.net/sourceforge/song/sofa.definition',
107 format => 'soflat',
109 'Gene Ontology' => {
110 ontology => [
111 'http://www.geneontology.org/ontology/function.ontology',
112 'http://www.geneontology.org/ontology/process.ontology',
113 'http://www.geneontology.org/ontology/component.ontology'
115 definitions => 'http://www.geneontology.org/ontology/GO.defs',
116 format => 'soflat',
120 #aliases
121 $instance->{Gene_Ontology} = $instance->{'Gene Ontology'};
123 bless $instance, __PACKAGE__;
127 sub new {
128 return shift->get_instance(@_);
131 =head2 get_instance
133 Title : get_instance
134 Usage : my $singleton = Bio::Ontology::DocumentRegistry->get_instance();
135 Function: constructor
136 Returns : The Bio::Ontology::DocumentRegistry singleton.
137 Args : None
138 Usage
140 =cut
142 sub get_instance {
143 return $instance;
146 =head2 documents
148 Title : documents
149 Usage : my($ontology_url, $definitions_url, $format) = $obj->documents('Sequence Ontology');
150 Function: Maps an ontology name to a list of (local or) remote URIs where the
151 files can be located.
152 Returns : A 3-item list:
153 (1) URI for the ontology file
154 (2) URI for the ontology definitions file
155 (3) format of the files (dagedit, obo, etc)
156 Args : Name of an ontology, e.g. 'Sequence Ontology', or 'Cellular Component
157 (Gene Ontology)'
159 =cut
162 sub documents {
163 my($self,$name) = @_;
165 if(defined($self->{$name})){
166 return ($self->{$name}{ontology} , $self->{$name}{definitions}, $self->{$name}{format});
167 } else {
168 return ();