| 1 | # | ||||||||||
| 2 | # BioPerl module for Bio::Ontology::DocumentRegistry | ||||||||||
| 3 | # | ||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||
| 5 | # | ||||||||||
| 6 | # Cared for by Allen Day <allenday@ucla.edu> | ||||||||||
| 7 | # | ||||||||||
| 8 | # Copyright Allen Day | ||||||||||
| 9 | # | ||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||
| 11 | |||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||
| 13 | |||||||||||
| 14 | =head1 NAME | ||||||||||
| 15 | |||||||||||
| 16 | Bio::Ontology::DocumentRegistry - Keep track of where to find ontologies. | ||||||||||
| 17 | Allows lookups by name. | ||||||||||
| 18 | |||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||
| 20 | |||||||||||
| 21 | my $registry = Bio::Ontology::DocumentRegistry->get_instance(); | ||||||||||
| 22 | my($ont,$def,$fmt) = $registry->documents('Sequence Ontology'); | ||||||||||
| 23 | |||||||||||
| 24 | my $io = Bio::OntologyIO->new(-url => $ont, | ||||||||||
| 25 | -defs_url => $def, | ||||||||||
| 26 | -format => $fmt); | ||||||||||
| 27 | my $so = $io->next_ontology(); | ||||||||||
| 28 | #... | ||||||||||
| 29 | |||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||
| 31 | |||||||||||
| 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. | ||||||||||
| 37 | |||||||||||
| 38 | =head1 FEEDBACK | ||||||||||
| 39 | |||||||||||
| 40 | =head2 Mailing Lists | ||||||||||
| 41 | |||||||||||
| 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. | ||||||||||
| 45 | |||||||||||
| 46 | bioperl-l@bioperl.org - General discussion | ||||||||||
| 47 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||
| 48 | |||||||||||
| 49 | =head2 Support | ||||||||||
| 50 | |||||||||||
| 51 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 52 | |||||||||||
| 53 | I<bioperl-l@bioperl.org> | ||||||||||
| 54 | |||||||||||
| 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. | ||||||||||
| 59 | |||||||||||
| 60 | =head2 Reporting Bugs | ||||||||||
| 61 | |||||||||||
| 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: | ||||||||||
| 65 | |||||||||||
| 66 | https://github.com/bioperl/bioperl-live/issues | ||||||||||
| 67 | |||||||||||
| 68 | =head1 AUTHOR - Allen Day | ||||||||||
| 69 | |||||||||||
| 70 | Email allenday@ucla.edu | ||||||||||
| 71 | |||||||||||
| 72 | =head1 APPENDIX | ||||||||||
| 73 | |||||||||||
| 74 | The rest of the documentation details each of the object methods. | ||||||||||
| 75 | Internal methods are usually preceded with a _ | ||||||||||
| 76 | |||||||||||
| 77 | =cut | ||||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | # Let the code begin... | ||||||||||
| 81 | |||||||||||
| 82 | package Bio::Ontology::DocumentRegistry; | ||||||||||
| 83 | 28 | $Bio::Ontology::DocumentRegistry::VERSION = '1.7.8'; | |||||||||
| 84 | 28 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 85 | 28 | ▶ | use base qw(Bio::Root::Root); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 86 | 28 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 87 | |||||||||||
| 88 | 28 | my $instance; | |||||||||
| 89 | |||||||||||
| 90 | 28 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 91 | 28 | $instance = { | |||||||||
| 92 | # No longer maintained, only OBO and OWL supported | ||||||||||
| 93 | 'Sequence Ontology' => { | ||||||||||
| 94 | ontology => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.ontology?rev=HEAD", | ||||||||||
| 95 | # definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD", | ||||||||||
| 96 | format => 'soflat', | ||||||||||
| 97 | }, | ||||||||||
| 98 | 'Sequence Ontology OBO' => { | ||||||||||
| 99 | ontology => "https://raw.githubusercontent.com/The-Sequence-Ontology/SO-Ontologies/master/so.obo", | ||||||||||
| 100 | # definitions => "http://song.cvs.sourceforge.net/*checkout*/song/ontology/so.definition?rev=HEAD", | ||||||||||
| 101 | format => 'obo', | ||||||||||
| 102 | }, | ||||||||||
| 103 | #### TODO Server http://umn.dl.sourceforge.net/ does not respond, are there | ||||||||||
| 104 | #### alternative sources? | ||||||||||
| 105 | 'Sequence Ontology Feature Annotation' => { | ||||||||||
| 106 | ontology => 'https://raw.githubusercontent.com/The-Sequence-Ontology/SO-Ontologies/master/subsets/SOFA.obo', | ||||||||||
| 107 | #definitions =>'http://umn.dl.sourceforge.net/sourceforge/song/sofa.definition', | ||||||||||
| 108 | format => 'obo', | ||||||||||
| 109 | }, | ||||||||||
| 110 | # TODO: No longer available as separate files | ||||||||||
| 111 | 'Gene Ontology' => { | ||||||||||
| 112 | ontology => 'http://purl.obolibrary.org/obo/go/go-basic.obo', | ||||||||||
| 113 | #definitions => 'http://www.geneontology.org/ontology/GO.defs', | ||||||||||
| 114 | format => 'soflat', | ||||||||||
| 115 | }, | ||||||||||
| 116 | }; | ||||||||||
| 117 | |||||||||||
| 118 | #aliases | ||||||||||
| 119 | 28 | $instance->{Gene_Ontology} = $instance->{'Gene Ontology'}; | |||||||||
| 120 | |||||||||||
| 121 | 28 | bless $instance, __PACKAGE__; | |||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | |||||||||||
| 125 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 126 | 0 | return shift->get_instance(@_); | |||||||||
| 127 | } | ||||||||||
| 128 | |||||||||||
| 129 | =head2 get_instance | ||||||||||
| 130 | |||||||||||
| 131 | Title : get_instance | ||||||||||
| 132 | Usage : my $singleton = Bio::Ontology::DocumentRegistry->get_instance(); | ||||||||||
| 133 | Function: constructor | ||||||||||
| 134 | Returns : The Bio::Ontology::DocumentRegistry singleton. | ||||||||||
| 135 | Args : None | ||||||||||
| 136 | Usage | ||||||||||
| 137 | |||||||||||
| 138 | =cut | ||||||||||
| 139 | |||||||||||
| 140 | 1 | ▶ | sub get_instance { | ||||||||
|
Subroutine
get_instance: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 141 | 1 | return $instance; | |||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | =head2 documents | ||||||||||
| 145 | |||||||||||
| 146 | Title : documents | ||||||||||
| 147 | Usage : my($ontology_url, $definitions_url, $format) = $obj->documents('Sequence Ontology'); | ||||||||||
| 148 | Function: Maps an ontology name to a list of (local or) remote URIs where the | ||||||||||
| 149 | files can be located. | ||||||||||
| 150 | Returns : A 3-item list: | ||||||||||
| 151 | (1) URI for the ontology file | ||||||||||
| 152 | (2) URI for the ontology definitions file | ||||||||||
| 153 | (3) format of the files (dagedit, obo, etc) | ||||||||||
| 154 | Args : Name of an ontology, e.g. 'Sequence Ontology', or 'Cellular Component | ||||||||||
| 155 | (Gene Ontology)' | ||||||||||
| 156 | |||||||||||
| 157 | =cut | ||||||||||
| 158 | |||||||||||
| 159 | |||||||||||
| 160 | 1 | ▶ | sub documents { | ||||||||
|
Subroutine
documents: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 161 | 1 | my($self,$name) = @_; | |||||||||
| 162 | |||||||||||
| 163 | 1 | ▶ | if(defined($self->{$name})){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 164 | 1 | return ($self->{$name}{ontology} , $self->{$name}{definitions}, $self->{$name}{format}); | |||||||||
| 165 | } else { | ||||||||||
| 166 | 0 | return (); | |||||||||
| 167 | } | ||||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | 28 | 1; | |||||||||