comparison variant_effect_predictor/Bio/EnsEMBL/DBSQL/MetaContainer.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 =head1 LICENSE
2
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and
4 Genome Research Limited. All rights reserved.
5
6 This software is distributed under a modified Apache license.
7 For license details, please see
8
9 http://www.ensembl.org/info/about/code_licence.html
10
11 =head1 CONTACT
12
13 Please email comments or questions to the public Ensembl
14 developers list at <dev@ensembl.org>.
15
16 Questions may also be sent to the Ensembl help desk at
17 <helpdesk@ensembl.org>.
18
19 =cut
20
21 =head1 NAME
22
23 Bio::EnsEMBL::DBSQL::MetaContainer - Encapsulates all access to core
24 database meta information
25
26 =head1 SYNOPSIS
27
28 my $meta_container =
29 $registry->get_adaptor( 'Human', 'Core', 'MetaContainer' );
30
31 my @mapping_info =
32 @{ $meta_container->list_value_by_key('assembly.mapping') };
33
34 my $scientific_name = $meta_container->get_scientific_name();
35
36 =head1 DESCRIPTION
37
38 An object that encapsulates specific access to core db meta data
39
40 =head1 METHODS
41
42 =cut
43
44 package Bio::EnsEMBL::DBSQL::MetaContainer;
45
46 use strict;
47 use warnings;
48
49 use Bio::EnsEMBL::Utils::Exception qw/deprecate/;
50 use Bio::Species;
51
52
53 use base qw/Bio::EnsEMBL::DBSQL::BaseMetaContainer/;
54
55 # add well known meta info get-functions below
56
57 =head2 get_production_name
58
59 Args : none
60 Example : $species = $meta_container->get_production_name();
61 Description : Obtains the name of the species in a form usable as, for
62 example, a table name, file name etc.
63 Returntype : string
64 Exceptions : none
65 Status : Stable
66
67 =cut
68
69 sub get_production_name {
70 my ($self) = @_;
71 return $self->single_value_by_key('species.production_name');
72 }
73
74 =head2 get_short_name
75
76 Args : none
77 Example : $species = $meta_container->get_short_name();
78 Description : Obtains the name of the species in a form usable as, for
79 example, a short label in a GUI.
80 Returntype : string
81 Exceptions : none
82 Status : Stable
83
84 =cut
85
86 sub get_short_name {
87 my ($self) = @_;
88 return $self->single_value_by_key('species.short_name');
89 }
90
91 =head2 get_common_name
92
93 Args : none
94 Example : $species = $meta_container->get_common_name();
95 Description : Obtains the common name of the species.
96 Returntype : string
97 Exceptions : none
98 Status : Stable
99
100 =cut
101
102 sub get_common_name {
103 my ($self) = @_;
104 return $self->single_value_by_key('species.common_name');
105 }
106
107 =head2 get_scientific_name
108
109 Args : none
110 Example : $species = $meta_container->get_scientific_name();
111 Description : Obtains the full scientific name of the species.
112 Returntype : string
113 Exceptions : none
114 Status : Stable
115
116 =cut
117 sub get_scientific_name {
118 my ($self) = @_;
119 return $self->single_value_by_key('species.scientific_name');
120 }
121
122 =head2 get_division
123
124 Args : none
125 Example : $div = $meta_container->get_division();
126 Description : Obtains the Ensembl Genomes division to which the species belongs.
127 Returntype : string
128 Exceptions : none
129 Status : Stable
130
131 =cut
132 sub get_division {
133 my ($self) = @_;
134 return $self->single_value_by_key('species.division');
135 }
136
137 =head2 get_Species
138
139 Arg [1] : none
140 Example : $species = $meta_container->get_Species();
141 Description: Obtains the species from this databases meta table. Call is
142 deprecated; please use other subroutines in this package
143 Returntype : Bio::Species
144 Exceptions : none
145 Caller : ?
146 Status : Deprecated
147
148 =cut
149
150 sub get_Species {
151 my ($self) = @_;
152
153 deprecate('Call is deprecated. Use $self->get_common_name() / $self->get_classification() / $self->get_scientific_name() instead');
154
155 my $common_name = $self->get_common_name();
156 my $classification =
157 $self->list_value_by_key('species.classification');
158 if ( !@$classification ) {
159 return undef;
160 }
161
162 #Re-create the old classification data structure by adding the scientific
163 #name back onto the classification but with species before genus e.g.
164 # sapiens -> Homo -> Hominade
165 my $scientific_name = $self->get_scientific_name();
166 my ($genus, @sp) = split(/ /, $scientific_name);
167 unshift(@{$classification}, join(q{ }, @sp), $genus);
168
169 my $species = Bio::Species->new();
170 $species->common_name($common_name);
171
172 $species->classification($classification, 1); #always force it
173
174 return $species;
175 }
176
177
178 =head2 get_taxonomy_id
179
180 Arg [1] : none
181 Example : $tax_id = $meta_container->get_taxonomy_id();
182 Description: Retrieves the taxonomy id from the database meta table
183 Returntype : string
184 Exceptions : none
185 Caller : ?
186 Status : Stable
187
188 =cut
189
190 sub get_taxonomy_id {
191 my ($self) = @_;
192 return $self->single_value_by_key('species.taxonomy_id', 1);
193 }
194
195
196
197 =head2 get_default_assembly
198
199 Description: DEPRECATED. Use the version of the coordinate system you are
200 interested in instead.
201
202 Example: #use this instead
203 my ($highest_cs) = @{$db->get_CoordSystemAdaptor->fetch_all()};
204 my $assembly = $highest_cs->version();
205
206 =cut
207
208 sub get_default_assembly {
209 my $self = shift;
210
211 deprecate("Use version of coordinate system you are interested in instead.\n".
212 "Example:\n".
213 ' ($cs) = @{$coord_system_adaptor->fetch_all()};'."\n" .
214 ' $assembly = $cs->version();');
215
216 my ($cs) = @{$self->db->get_CoordSystemAdaptor->fetch_all()};
217
218 return $cs->version();
219 }
220
221
222 #
223 # TBD This method should be removed/deprecated
224 #
225 sub get_max_assembly_contig {
226 my $self = shift;
227 deprecate('This method should either be fixed or removed');
228 return $self->single_value_by_key('assembly.maxcontig');
229 }
230
231 =head2 get_genebuild
232
233 Arg [1] : none
234 Example : $tax_id = $meta_container->get_genebuild();
235 Description: Retrieves the genebuild from the database meta table
236 Returntype : string
237 Exceptions : none
238 Caller : ?
239 Status : Stable
240
241 =cut
242
243 sub get_genebuild {
244 my ($self) = @_;
245 return $self->single_value_by_key('genebuild.start_date', 1);
246 }
247
248 =head2 get_genebuild
249
250 Example : $classification = $meta_container->get_classification();
251 Description: Retrieves the classification held in the backing database minus
252 any species specific levels. This means that the first element
253 in the array will be subfamily/family level ascending to
254 superkingdom
255 Returntype : ArrayRef[String]
256 Exceptions : none
257 Caller : ?
258 Status : Stable
259
260 =cut
261
262 sub get_classification {
263 my ($self) = @_;
264 my $classification = $self->list_value_by_key('species.classification');
265 my $copy = [@{$classification}];
266 splice(@{$copy}, 0, 1); # remove the Homo sapiens
267 return $copy;
268 }
269
270
271 1;
272