forked from Ensembl/ensembl-production
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatabaseDumper.pm
98 lines (72 loc) · 2.44 KB
/
DatabaseDumper.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
=head1 LICENSE
Copyright [1999-2018] EMBL-European Bioinformatics Institute
and Wellcome Trust Sanger Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=pod
=head1 NAME
Bio::EnsEMBL::EGPipeline::Common::DatabaseDumper
=head1 DESCRIPTION
This is a simple wrapper around the Hive module; all it's really doing
is creating an appropriate dbconn for that module.
=head1 Author
James Allen
=cut
package Bio::EnsEMBL::EGPipeline::Common::RunnableDB::DatabaseDumper;
use strict;
use warnings;
use File::Basename qw(dirname);
use File::Path qw(make_path);
use Bio::EnsEMBL::Hive::DBSQL::DBConnection;
use base (
'Bio::EnsEMBL::Hive::RunnableDB::DatabaseDumper',
'Bio::EnsEMBL::EGPipeline::Common::RunnableDB::Base'
);
sub param_defaults {
my ($self) = @_;
return {
%{$self->SUPER::param_defaults},
'db_type' => 'core',
'overwrite' => 0,
};
}
sub fetch_input {
my $self = shift @_;
my $output_file = $self->param('output_file');
if (defined $output_file) {
if (-e $output_file) {
if ($self->param('overwrite')) {
$self->warning("Output file '$output_file' already exists, and will be overwritten.");
} else {
$self->warning("Output file '$output_file' already exists, and won't be overwritten.");
$self->param('skip_dump', 1);
}
} else {
my $output_dir = dirname($output_file);
if (!-e $output_dir) {
$self->warning("Output directory '$output_dir' does not exist. I shall create it.");
make_path($output_dir) or $self->throw("Failed to create output directory '$output_dir'");
}
}
}
my $db_type = $self->param('db_type');
if ($db_type eq 'hive') {
$self->param('src_db_conn', $self->dbc);
} else {
$self->param('exclude_ehive', 1);
my $hive_style_dbc = Bio::EnsEMBL::Hive::DBSQL::DBConnection->new(
-dbconn => $self->get_DBAdaptor($db_type)->dbc,
);
$self->param('src_db_conn', $hive_style_dbc);
}
$self->SUPER::fetch_input();
}
1;