3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
37 my $serverroot =
'/path/to/ensembl';
41 # parse common options
44 # convert from schema 19 to 20+
45 $conversion->do_conversion()
49 This module is a helper module
for database conversion,
for
50 both vega-vega and ensembl-vega schemas. It provides a wrapper
52 methods therein. Also provides access to helper functions in
59 package Bio::EnsEMBL::Utils::SchemaConversion;
69 Example : $conversion->Bio::EnsEMBL::Utils::SchemaConversion->
new($serverroot);
71 object. Parses input file and checks input with user
73 Exceptions : thrown
if $Siteroot not passed over
74 Caller : $Siteroot/utils/vega_schema_conversion
85 $self->conv_support->parse_extra_options(
'do_vega_sc=s',
94 #check input and show help
95 $self->conv_usage()
if ($self->conv_support->param(
"help"));
96 $self->conv_usage(
"configuration file needed") unless ($self->conv_support->param(
"conffile"));
97 $self->conv_usage(
"password for database access needed") unless ($self->conv_support->param(
"pass"));
98 $self->conv_usage(
"can only do conversion to ensembl OR Vega, not both")
if ($self->conv_support->param(
'do_vega_sc') && $self->conv_support->param(
'do_ens_sc'));
99 $self->conv_usage(
"You need to do vega->veg or ensembl->vega conversion") unless ($self->conv_support->param(
'do_vega_sc') || $self->conv_support->param(
'do_ens_sc'));
101 # ask user to confirm parameters to proceed
102 $self->conv_support->allowed_params(
'conffile',
119 $self->conv_support->confirm_params;
126 Example : $conversion->conv_support;
128 Return type : Bio::EnsEMBL::Utils::ConversionSuppor
object
136 return $self->{config};
141 Example : $conversion->conv_obj;
151 return $self->{
'converter_object'};
157 Example : $self->species_alias
158 Description : examines name of source database to determine which conversion module to use
160 Exceptions : die
if wrong species name used
168 return 'CanisFamiliaris' if $name =~ /canis/;
169 return 'HomoSapiens' if $name =~ /homo/;
170 return 'MusMusculus' if $name =~ /mus/;
171 return 'DanioRerio' if $name =~ /danio/;
172 ##hack - should use own modules
173 return 'HomoSapiens' if $name =~ /sus/;
174 die
"invalid name of source database, please check configuration file";
177 =head2 choose_conversion_type
179 Example : $conversion->choose_conversion_type
180 Description : compares conversion type (ensembl or vega) and species type with
181 available modules and chooses that to use
for the conversion. Stores
182 a converter
object within the caller
185 Caller : $Siteroot/utils/vega_schema_conversion
189 sub choose_conversion_type {
194 $species = $self->species_alias($self->conv_support->param(
'source_db'));
195 if ($self->conv_support->param(
'do_vega_sc')) {
196 $species =
"vega::".$species;
197 eval
"require SeqStoreConverter::$species"; ## no critic
199 warn(
"Could not require conversion module SeqStoreConverter::$species\ for vega conversion\n" .
200 "Using SeqStoreConverter::BasicConverter instead:\n$@");
202 $species =
"BasicConverter";
205 warn
"Using conversion module SeqStoreConverter::$species for vega conversion\n";
209 eval
"require SeqStoreConverter::$species"; ## no critic
211 warn(
"Could not require conversion module SeqStoreConverter::$species for Ensembl conversion\n" .
212 "Using SeqStoreConverter::BasicConverter instead:\n$@");
214 $species =
"BasicConverter";
217 warn
"Using conversion module SeqStoreConverter::$species for Ensembl conversion\n";
219 $self->conv_support->param(
'vega_sql',0);
221 $converter =
"SeqStoreConverter::$species"->
new
222 ( $self->conv_support->param(
'user'),
223 $self->conv_support->param(
'pass'),
224 $self->conv_support->param(
'host').
':'.$self->conv_support->param(
'port'),
225 $self->conv_support->param(
'source_db'),
226 $self->conv_support->param(
'dbname'),
227 $self->conv_support->param(
'core_sql'),
228 $self->conv_support->param(
'vega_sql'),
229 $self->conv_support->param(
'force'),
230 $self->conv_support->param(
'verbose'),
234 $self->{
'converter_object'} = $converter;
239 Example : $conversion->do_conversion
240 Description : does the database conversion
243 Caller : $Siteroot/utils/vega_schema_conversion
250 $self->conv_obj->debug(
"\n\n*** converting " . $self->conv_obj->source .
" to " .
251 $self->conv_obj->target() .
" ***");
252 $self->conv_obj->transfer_meta();
253 $self->conv_obj->create_coord_systems();
254 $self->conv_obj->create_seq_regions();
255 $self->conv_obj->create_assembly();
256 $self->conv_obj->create_attribs();
257 $self->conv_obj->set_top_level();
258 $self->conv_obj->transfer_dna();
259 $self->conv_obj->back_patch_schema();
260 $self->conv_obj->transfer_genes();
261 $self->conv_obj->transfer_prediction_transcripts();
263 if ($self->conv_support->param(
'do_features')) {
264 $self->conv_obj->transfer_features();
266 #use this for both ensembl and vega for now,
267 #but might need changing when vega gets eg transcript modified dates
268 $self->conv_obj->transfer_vega_stable_ids();
269 $self->conv_obj->copy_other_tables();
270 $self->conv_obj->copy_repeat_consensus();
271 $self->conv_obj->create_meta_coord();
272 if ($self->conv_support->param(
'do_vega_sc')) {
273 $self->conv_obj->copy_other_vega_tables();
274 $self->conv_obj->update_clone_info();
275 $self->conv_obj->remove_supercontigs();
276 $self->conv_obj->copy_internal_clone_names();
277 $self->conv_obj->copy_assembly_exception;
281 =head2 make_schema_up_to_date
283 Example : $conversion->make_schema_up_to_date
284 Description : patches schema to latest version
291 sub make_schema_up_to_date {
293 $self->conv_obj->debug (
"\nPatching schema to latest version\n");
294 my $user = $self->conv_obj->user;
295 my $pass = $self->conv_obj->password;
296 my $port = $self->conv_obj->port;
297 my $host = $self->conv_obj->host;
298 my $target = $self->conv_obj->target;
299 my $patch_schema = $self->conv_support->param(
'patch_sql');
300 my $cmd =
"/usr/local/mysql/bin/mysql -u $user -p$pass -P $port -h $host $target < $patch_schema";
308 Example : $conversion->conv_usage(
"message")
309 Description : prints
usage information and exits
312 Caller : $Siteroot/utils/vega_schema_conversion
320 print STDERR
"\nMSG: $msg\n" if($msg);
324 ** Source and target databases must be on the same mysql instance
326 usage: ./conversion_densities.pl <options>
328 options: --conf <conf_file> configuration file (uses conf/Conversion.ini by
default):
331 do_vega_sc (do vega conversion: 0 or 1)
332 do_ens_sc (do ensembl conversion: 0 or 1)
333 user (a mysql db user with read/write priveleges)
336 source_db (schema 19 source database)
337 dbname (schema 20+ target database)
338 force (overwrite existing target database: 0 or 1)
339 verbose (print out
debug statements: 0 or 1)
340 logpath (location of log file)
341 do_features (transfer dna- and protein-align features, for debugging: 0 or 1)
342 core_sql (location of ensembl schema creation script: ensembl/sql/table.sql)
343 vega_sql (location of creation script for additional vega tables: ensembl/sql/vega_specific_tables.sql)
344 patch_sql (location of schema patching script: ensembl/sql/vega_latest_schema.sql)
346 --log name of log_file
347 --help display this message