0
|
1 =pod
|
|
2
|
|
3 =head1 NAME
|
|
4
|
|
5 Bio::EnsEMBL::Funcgen::RunnableDB::Motif
|
|
6
|
|
7 =head1 DESCRIPTION
|
|
8
|
|
9 'Funcgen::Motif'
|
|
10
|
|
11 TODO: Try to collate that to Funcgen
|
|
12
|
|
13 =cut
|
|
14
|
|
15
|
|
16 package Bio::EnsEMBL::Funcgen::RunnableDB::Motif;
|
|
17
|
|
18 use warnings;
|
|
19 use strict;
|
|
20
|
|
21 use base ('Bio::EnsEMBL::Hive::Process');
|
|
22
|
|
23 use Bio::EnsEMBL::DBSQL::DBAdaptor;
|
|
24 use Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor;
|
|
25 use Bio::EnsEMBL::Utils::Exception qw(throw warning stack_trace_dump);
|
|
26 use Data::Dumper;
|
|
27
|
|
28 sub fetch_input { # nothing to fetch... just the parameters...
|
|
29 my $self = shift @_;
|
|
30
|
|
31 $self->SUPER::fetch_input();
|
|
32
|
|
33 if(!$self->param('bin_dir')){ throw "No binary folder given"; }
|
|
34 $self->_bin_folder($self->param('bin_dir'));
|
|
35
|
|
36 if(!$self->param('species')){ throw "No species given"; }
|
|
37 $self->_species($self->param('species'));
|
|
38
|
|
39 if(!$self->param('bin_size')){ throw "No bin size given"; }
|
|
40 $self->_bin_size($self->param('bin_size'));
|
|
41
|
|
42 if(!$self->param('window_size')){ throw "No window size given"; }
|
|
43 $self->_window_size($self->param('window_size'));
|
|
44
|
|
45 #Get the core db... possibly make these non-mandatory
|
|
46 if(!$self->param('dnadb_host')){ throw "No core host given"; }
|
|
47 if(!$self->param('dnadb_port')){ throw "No core port given"; }
|
|
48 if(!$self->param('dnadb_user')){ throw "No core user given"; }
|
|
49 #if(!$self->param('dnadb_name')){ throw "No core dbname given"; }
|
|
50 my $dba;
|
|
51 eval{
|
|
52 $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(
|
|
53 -host => $self->param('dnadb_host'),
|
|
54 -port => $self->param('dnadb_port'),
|
|
55 -user => $self->param('dnadb_user'),
|
|
56 -dbname => $self->param('dnadb_name'),
|
|
57 -species => $self->_species,
|
|
58 );
|
|
59 };
|
|
60 if($@) { throw "Error creating the Core DB Adaptor: $@"; }
|
|
61 if(!$dba){ throw "Could not connect to Core DB"; }
|
|
62
|
|
63 #Get the efg db... always read only user
|
|
64 if(!$self->param('dbhost')){ throw "No host given"; }
|
|
65 if(!$self->param('dbport')){ throw "No port given"; }
|
|
66 if(!$self->param('dbuser')){ throw "No user given"; }
|
|
67 if(!$self->param('dbname')){ throw "No dbname given"; }
|
|
68 eval{
|
|
69 $self->_efgdba(Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
|
|
70 -host => $self->param('dbhost'),
|
|
71 -port => $self->param('dbport'),
|
|
72 -user => $self->param('dbuser'),
|
|
73 -dbname => $self->param('dbname'),
|
|
74 -species => $self->_species,
|
|
75 -dnadb => $dba,
|
|
76 ));
|
|
77 };
|
|
78 if($@) { throw "Error creating the EFG DB Adaptor: $@"; }
|
|
79 if(!$self->_efgdba()){ throw "Could not connect to EFG DB"; }
|
|
80
|
|
81 my $dnadbc = $self->_efgdba()->dnadb->dbc;
|
|
82 warn $dnadbc->host." ".$dnadbc->port." ".$dnadbc->username." ".$dnadbc->dbname;
|
|
83
|
|
84
|
|
85 if(!$self->param('feature_set')){ throw "No feature set given"; }
|
|
86 my $fseta = $self->_efgdba()->get_FeatureSetAdaptor();
|
|
87 my $fset = $fseta->fetch_by_name($self->param('feature_set'));
|
|
88 if(!$fset){
|
|
89 throw $self->param('feature_set')." is not a valid Feature Set";
|
|
90 }
|
|
91 $self->_feature_set($fset);
|
|
92
|
|
93 if(!$self->param('output_dir')){ throw "No output dir given"; }
|
|
94 $self->_output_dir($self->param('output_dir')."/".$self->_feature_set->name);
|
|
95
|
|
96 return 1;
|
|
97 }
|
|
98
|
|
99 sub run {
|
|
100 my $self = shift @_;
|
|
101
|
|
102 return 1;
|
|
103 }
|
|
104
|
|
105
|
|
106 sub write_output { # Nothing is written at this stage (for the moment)
|
|
107
|
|
108 my $self = shift @_;
|
|
109
|
|
110 return 1;
|
|
111
|
|
112 }
|
|
113
|
|
114 #Private Generic getter and setter
|
|
115 sub _getter_setter {
|
|
116 my ($self, $param_name, $param_value) = @_;
|
|
117 if(!$param_name){ return undef; }
|
|
118 if(!$param_value){
|
|
119 $param_value = $self->param($param_name);
|
|
120 } else {
|
|
121 $self->param($param_name, $param_value);
|
|
122 }
|
|
123 return $param_value;
|
|
124 }
|
|
125
|
|
126 # Private getter / setters : Maybe do some validation in some cases...
|
|
127
|
|
128 #Private getter / setter to the bin folder
|
|
129 sub _bin_folder {
|
|
130 return $_[0]->_getter_setter('bin_folder',$_[1]);
|
|
131 }
|
|
132
|
|
133 #Private getter / setter to the EFG DB Adaptor
|
|
134 sub _efgdba {
|
|
135 return $_[0]->_getter_setter('efgdb',$_[1]);
|
|
136 }
|
|
137
|
|
138 #Private getter / setter to the bin size
|
|
139 sub _bin_size {
|
|
140 return $_[0]->_getter_setter('bin_size',$_[1]);
|
|
141 }
|
|
142
|
|
143 #Private getter / setter to the window size
|
|
144 sub _window_size {
|
|
145 return $_[0]->_getter_setter('window_size',$_[1]);
|
|
146 }
|
|
147
|
|
148 #Private getter / setter to the output dir
|
|
149 sub _output_dir {
|
|
150 return $_[0]->_getter_setter('output_dir',$_[1]);
|
|
151 }
|
|
152
|
|
153 #Private getter / setter to the feature set
|
|
154 sub _feature_set {
|
|
155 return $_[0]->_getter_setter('feature_set',$_[1]);
|
|
156 }
|
|
157
|
|
158 #Private getter / setter to the species
|
|
159 sub _species {
|
|
160 return $_[0]->_getter_setter('species',$_[1]);
|
|
161 }
|
|
162
|
|
163 1;
|