bug 2549; fixed small bug in Bio::Taxon which doesn't catch -common_name
[bioperl-live.git] / Bio / Ontology / DocumentRegistry.pm
blobb9af6ed8f3fd48cb7e6d6c08b5b76862b968d587
1 # $Id$
3 # BioPerl module for Bio::Ontology::DocumentRegistry
5 # Cared for by Allen Day <allenday@ucla.edu>
7 # Copyright Allen Day
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::Ontology::DocumentRegistry - Keep track of where to find ontologies.
16 Allows lookups by name.
18 =head1 SYNOPSIS
20 my $registry = Bio::Ontology::DocumentRegistry->get_instance();
21 my($ont,$def,$fmt) = $registry->documents('Sequence Ontology');
23 my $io = Bio::OntologyIO->new(-url => $ont,
24 -defs_url => $def,
25 -format => $fmt);
26 my $so = $io->next_ontology();
27 #...
29 =head1 DESCRIPTION
31 Do not use this directly, use Bio::Ontology::OntologyStore instead.
32 Bio::Ontology::OntologyStore uses Bio::Ontology::DocumentRegistry to
33 load and cache ontologies as object graphs, you can just ask it for
34 what you want by name. See L<Bio::Ontology::OntologyStore> for
35 details.
37 =head1 FEEDBACK
39 =head2 Mailing Lists
41 User feedback is an integral part of the evolution of this and other
42 Bioperl modules. Send your comments and suggestions preferably to
43 the Bioperl mailing list. Your participation is much appreciated.
45 bioperl-l@bioperl.org - General discussion
46 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
48 =head2 Reporting Bugs
50 Report bugs to the Bioperl bug tracking system to help us keep track
51 of the bugs and their resolution. Bug reports can be submitted via
52 the web:
54 http://bugzilla.open-bio.org/
56 =head1 AUTHOR - Allen Day
58 Email allenday@ucla.edu
60 =head1 APPENDIX
62 The rest of the documentation details each of the object methods.
63 Internal methods are usually preceded with a _
65 =cut
68 # Let the code begin...
70 package Bio::Ontology::DocumentRegistry;
71 use strict;
72 use base qw(Bio::Root::Root);
73 use Data::Dumper;
75 my $instance;
77 BEGIN {
78 $instance = {
79 'Sequence Ontology' => {
80 ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.ontology?rev=HEAD",
81 definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD",
82 format => 'soflat',
84 'Sequence Ontology OBO' => {
85 ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.obo?rev=HEAD",
86 definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD",
87 format => 'obo',
89 'Sequence Ontology Feature Annotation' => {
90 ontology => 'http://umn.dl.sourceforge.net/sourceforge/song/sofa.ontology',
91 definitions =>'http://umn.dl.sourceforge.net/sourceforge/song/sofa.definition',
92 format => 'soflat',
94 'Gene Ontology' => {
95 ontology => [
96 'http://www.geneontology.org/ontology/function.ontology',
97 'http://www.geneontology.org/ontology/process.ontology',
98 'http://www.geneontology.org/ontology/component.ontology'
100 definitions => 'http://www.geneontology.org/ontology/GO.defs',
101 format => 'soflat',
105 #aliases
106 $instance->{Gene_Ontology} = $instance->{'Gene Ontology'};
108 bless $instance, __PACKAGE__;
112 sub new {
113 return shift->get_instance(@_);
116 =head2 get_instance
118 Title : get_instance
119 Usage : my $singleton = Bio::Ontology::DocumentRegistry->get_instance();
120 Function: constructor
121 Returns : The Bio::Ontology::DocumentRegistry singleton.
122 Args : None
123 Usage
125 =cut
127 sub get_instance {
128 return $instance;
131 =head2 documents
133 Title : documents
134 Usage : my($ontology_url, $definitions_url, $format) = $obj->documents('Sequence Ontology');
135 Function: Maps an ontology name to a list of (local or) remote URIs where the
136 files can be located.
137 Returns : A 3-item list:
138 (1) URI for the ontology file
139 (2) URI for the ontology definitions file
140 (3) format of the files (dagedit, obo, etc)
141 Args : Name of an ontology, e.g. 'Sequence Ontology', or 'Cellular Component
142 (Gene Ontology)'
144 =cut
147 sub documents {
148 my($self,$name) = @_;
150 if(defined($self->{$name})){
151 return ($self->{$name}{ontology} , $self->{$name}{definitions}, $self->{$name}{format});
152 } else {
153 return ();