tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / Bio / Ontology / DocumentRegistry.pm
blob0daa012f76076fde700f6c502d988ad2e17e83b2
1 # $Id$
3 # BioPerl module for Bio::Ontology::DocumentRegistry
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Allen Day <allenday@ucla.edu>
9 # Copyright Allen Day
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::Ontology::DocumentRegistry - Keep track of where to find ontologies.
18 Allows lookups by name.
20 =head1 SYNOPSIS
22 my $registry = Bio::Ontology::DocumentRegistry->get_instance();
23 my($ont,$def,$fmt) = $registry->documents('Sequence Ontology');
25 my $io = Bio::OntologyIO->new(-url => $ont,
26 -defs_url => $def,
27 -format => $fmt);
28 my $so = $io->next_ontology();
29 #...
31 =head1 DESCRIPTION
33 Do not use this directly, use Bio::Ontology::OntologyStore instead.
34 Bio::Ontology::OntologyStore uses Bio::Ontology::DocumentRegistry to
35 load and cache ontologies as object graphs, you can just ask it for
36 what you want by name. See L<Bio::Ontology::OntologyStore> for
37 details.
39 =head1 FEEDBACK
41 =head2 Mailing Lists
43 User feedback is an integral part of the evolution of this and other
44 Bioperl modules. Send your comments and suggestions preferably to
45 the Bioperl mailing list. Your participation is much appreciated.
47 bioperl-l@bioperl.org - General discussion
48 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
50 =head2 Support
52 Please direct usage questions or support issues to the mailing list:
54 I<bioperl-l@bioperl.org>
56 rather than to the module maintainer directly. Many experienced and
57 reponsive experts will be able look at the problem and quickly
58 address it. Please include a thorough description of the problem
59 with code and data examples if at all possible.
61 =head2 Reporting Bugs
63 Report bugs to the Bioperl bug tracking system to help us keep track
64 of the bugs and their resolution. Bug reports can be submitted via
65 the web:
67 http://bugzilla.open-bio.org/
69 =head1 AUTHOR - Allen Day
71 Email allenday@ucla.edu
73 =head1 APPENDIX
75 The rest of the documentation details each of the object methods.
76 Internal methods are usually preceded with a _
78 =cut
81 # Let the code begin...
83 package Bio::Ontology::DocumentRegistry;
84 use strict;
85 use base qw(Bio::Root::Root);
86 use Data::Dumper;
88 my $instance;
90 BEGIN {
91 $instance = {
92 'Sequence Ontology' => {
93 ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.ontology?rev=HEAD",
94 definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD",
95 format => 'soflat',
97 'Sequence Ontology OBO' => {
98 ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.obo?rev=HEAD",
99 definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD",
100 format => 'obo',
103 #### TODO Server http://umn.dl.sourceforge.net/ does not respond, are there
104 #### alternative sources?
105 'Sequence Ontology Feature Annotation' => {
106 ontology => 'http://umn.dl.sourceforge.net/sourceforge/song/sofa.ontology',
107 definitions =>'http://umn.dl.sourceforge.net/sourceforge/song/sofa.definition',
108 format => 'soflat',
110 'Gene Ontology' => {
111 ontology => [
112 'http://www.geneontology.org/ontology/function.ontology',
113 'http://www.geneontology.org/ontology/process.ontology',
114 'http://www.geneontology.org/ontology/component.ontology'
116 definitions => 'http://www.geneontology.org/ontology/GO.defs',
117 format => 'soflat',
121 #aliases
122 $instance->{Gene_Ontology} = $instance->{'Gene Ontology'};
124 bless $instance, __PACKAGE__;
128 sub new {
129 return shift->get_instance(@_);
132 =head2 get_instance
134 Title : get_instance
135 Usage : my $singleton = Bio::Ontology::DocumentRegistry->get_instance();
136 Function: constructor
137 Returns : The Bio::Ontology::DocumentRegistry singleton.
138 Args : None
139 Usage
141 =cut
143 sub get_instance {
144 return $instance;
147 =head2 documents
149 Title : documents
150 Usage : my($ontology_url, $definitions_url, $format) = $obj->documents('Sequence Ontology');
151 Function: Maps an ontology name to a list of (local or) remote URIs where the
152 files can be located.
153 Returns : A 3-item list:
154 (1) URI for the ontology file
155 (2) URI for the ontology definitions file
156 (3) format of the files (dagedit, obo, etc)
157 Args : Name of an ontology, e.g. 'Sequence Ontology', or 'Cellular Component
158 (Gene Ontology)'
160 =cut
163 sub documents {
164 my($self,$name) = @_;
166 if(defined($self->{$name})){
167 return ($self->{$name}{ontology} , $self->{$name}{definitions}, $self->{$name}{format});
168 } else {
169 return ();