comparison variant_effect_predictor/Bio/EnsEMBL/Funcgen/RunnableDB/Annotation.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 =pod
2
3 =head1 NAME
4
5 Bio::EnsEMBL::Funcgen::RunnableDB::Annotation
6
7 =head1 DESCRIPTION
8
9 'Annotation' is a base class for runnables running the Annotatin Pipeline
10 It performs common tasks such as connecting to the EFG DB etc...
11
12 =cut
13
14 package Bio::EnsEMBL::Funcgen::RunnableDB::Annotation;
15
16 use warnings;
17 use strict;
18
19 use Bio::EnsEMBL::Funcgen::Utils::Helper;
20 use Bio::EnsEMBL::DBSQL::DBConnection;
21 use Bio::EnsEMBL::DBSQL::DBAdaptor;
22 use Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor;
23 use Bio::EnsEMBL::Funcgen::InputSet;
24 use Bio::EnsEMBL::Funcgen::DataSet;
25 use Bio::EnsEMBL::Funcgen::FeatureSet;
26 use Bio::EnsEMBL::Funcgen::AnnotatedFeature;
27 use Bio::EnsEMBL::Utils::Exception qw(throw warning stack_trace_dump);
28 use Data::Dumper;
29 use DBI;
30
31 #use base ('Bio::EnsEMBL::Hive::ProcessWithParams');
32 use base ('Bio::EnsEMBL::Hive::Process');
33
34 #This defines a set of parameters based on given parameters from the pipeline:
35 sub fetch_input { # nothing to fetch... just the DB parameters...
36 my $self = shift @_;
37
38 my $dnadb_params = $self->param('dnadb') || throw "No parameters for Core DB";
39 eval{ $self->_dnadba(Bio::EnsEMBL::DBSQL::DBAdaptor->new(%{ $dnadb_params })); };
40 if($@) { throw "Error creating the Core DB Adaptor: $@"; }
41 if(!$self->_dnadba()){ throw "Could not connect to Core DB"; }
42 $self->_dnadb_params($dnadb_params);
43
44 #Get efg connection, otherwise fail..
45 my $efgdb_params = $self->param('efgdb') || throw "No parameters for EFG DB";
46
47 eval{
48 $self->_efgdba(Bio::EnsEMBL::Funcgen::DBSQL::DBAdaptor->new(
49 %{ $efgdb_params },
50 #Why is this not working???
51 #-dnadb => $self->_dnadba,
52 -dnadb_user => $self->_dnadba->dbc->username,
53 -dnadb_port => $self->_dnadba->dbc->port,
54 -dnadb_host => $self->_dnadba->dbc->host,
55 -dnadb_dbname => $self->_dnadba->dbc->dbname,
56 ));
57 };
58
59 if($@) { throw "Error creating the EFG DB Adaptor: $@"; }
60 if(!$self->_efgdba()){ throw "Could not connect to EFG DB"; }
61 $self->_efgdb_params($efgdb_params);
62
63 #Get work db connection, otherwise fail..
64 my $workdb_params = $self->param('workdb') || throw "No parameters for Work server";
65 $self->_workdb_params($workdb_params);
66
67 my $species = $self->param('species') || throw "No species defined";
68 $self->_species($species);
69
70 #Not is use, currently...
71 #my $release = $self->param('release') || throw "Release number not specified";
72 #$self->_release($release);
73
74 my $work_dir = $self->param('work_dir') || throw "'work_dir' is a required parameter";
75 $self->_work_dir($work_dir);
76
77 #Work with conventions here too?? work_dir/output/dbname ??
78 my $output_dir = $self->param('output_dir') || throw "'output_dir' is a required parameter";
79 $self->_output_dir($output_dir);
80
81 return 1;
82 }
83
84
85 sub run {
86 my $self = shift @_;
87
88 return 1;
89 }
90
91
92 sub write_output {
93 my $self = shift @_;
94
95 return 1;
96
97 }
98
99
100 #Private Generic getter and setter
101 sub _getter_setter {
102 my ($self, $param_name, $param_value) = @_;
103 if(!$param_name){ return undef; }
104 if(!$param_value){
105 $param_value = $self->param($param_name);
106 } else {
107 $self->param($param_name, $param_value);
108 }
109 return $param_value;
110 }
111
112 # Private getter / setters : Maybe do some validation in some cases...
113
114 #Private getter / setter to the Work DB Connection params
115 sub _workdb_params {
116 return $_[0]->_getter_setter('workdb_params',$_[1]);
117 }
118
119 #Private getter / setter to the EFG DB Adaptor
120 sub _efgdba {
121 return $_[0]->_getter_setter('efgdb',$_[1]);
122 }
123
124 #Private getter / setter to the EFG DB Connection params
125 sub _efgdb_params {
126 return $_[0]->_getter_setter('efgdb_params',$_[1]);
127 }
128
129 #Private getter / setter to the Core DB Adaptor
130 sub _dnadba {
131 return $_[0]->_getter_setter('dnadb',$_[1]);
132 }
133
134 #Private getter / setter to the Core DB Connection params
135 sub _dnadb_params {
136 return $_[0]->_getter_setter('dnadb_params',$_[1]);
137 }
138
139 #Private getter / setter to the Species name
140 sub _species {
141 return $_[0]->_getter_setter('species',$_[1]);
142 }
143
144 #Private getter / setter to the work folder
145 sub _work_dir {
146 return $_[0]->_getter_setter('work_dir',$_[1]);
147 }
148
149 #Private getter / setter to the output folder
150 sub _output_dir {
151 return $_[0]->_getter_setter('output_dir',$_[1]);
152 }
153
154 #Private getter / setter to the release number
155 sub _release {
156 return $_[0]->_getter_setter('release',$_[1]);
157 }
158
159
160 1;