Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
13f462ad
Commit
13f462ad
authored
Mar 20, 2014
by
Leo Gordon
Browse files
moved loading/saving of the collections into DBAdaptor module
parent
6e8b91eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
51 deletions
+57
-51
modules/Bio/EnsEMBL/Hive.pm
modules/Bio/EnsEMBL/Hive.pm
+5
-46
modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm
modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm
+49
-1
scripts/generate_graph.pl
scripts/generate_graph.pl
+1
-2
scripts/init_pipeline.pl
scripts/init_pipeline.pl
+2
-2
No files found.
modules/Bio/EnsEMBL/Hive.pm
View file @
13f462ad
...
...
@@ -67,55 +67,14 @@ use Bio::EnsEMBL::Hive::Utils::Collection;
our
%hash_of_collections
;
sub
collection
{
my
$key
=
pop
@_
;
my
$class
=
shift
@_
;
my
$key
=
shift
@_
;
return
$hash_of_collections
{
$key
}
||=
Bio::EnsEMBL::Hive::Utils::
Collection
->
new
();
}
sub
load_collections_from_dba
{
my
$hive_dba
=
pop
@_
;
foreach
my
$AdaptorType
('
Meta
',
'
MetaContainer
')
{
my
$adaptor
=
$hive_dba
->
get_adaptor
(
$AdaptorType
);
$hash_of_collections
{
$AdaptorType
}
=
$adaptor
->
get_param_hash
();
}
foreach
my
$AdaptorType
('
ResourceClass
',
'
ResourceDescription
',
'
Analysis
',
'
AnalysisStats
',
'
AnalysisCtrlRule
',
'
DataflowRule
')
{
my
$adaptor
=
$hive_dba
->
get_adaptor
(
$AdaptorType
);
$hash_of_collections
{
$AdaptorType
}
=
Bio::EnsEMBL::Hive::Utils::
Collection
->
new
(
$adaptor
->
fetch_all
);
}
}
sub
save_collections_to_dba
{
my
$hive_dba
=
pop
@_
;
foreach
my
$AdaptorType
('
Meta
',
'
MetaContainer
')
{
my
$adaptor
=
$hive_dba
->
get_adaptor
(
$AdaptorType
);
while
(
my
(
$meta_key
,
$meta_value
)
=
each
%
{
$hash_of_collections
{
$AdaptorType
}
}
)
{
$adaptor
->
remove_all_by_meta_key
(
$meta_key
);
# make sure the previous values are gone
$adaptor
->
store_pair
(
$meta_key
,
$meta_value
);
}
if
(
@
_
)
{
$hash_of_collections
{
$key
}
=
shift
@_
;
}
foreach
my
$AdaptorType
('
ResourceClass
',
'
ResourceDescription
',
'
Analysis
',
'
AnalysisStats
',
'
AnalysisCtrlRule
',
'
DataflowRule
')
{
my
$adaptor
=
$hive_dba
->
get_adaptor
(
$AdaptorType
);
foreach
my
$storable_object
(
Bio::EnsEMBL::
Hive
->
collection
(
$AdaptorType
)
->
list
)
{
$adaptor
->
store_or_update_one
(
$storable_object
);
# warn "Stored/updated ".$storable_object->toString()."\n";
}
}
my
$job_adaptor
=
$hive_dba
->
get_AnalysisJobAdaptor
;
foreach
my
$analysis
(
Bio::EnsEMBL::
Hive
->
collection
('
Analysis
')
->
list
)
{
if
(
my
$our_jobs
=
$analysis
->
jobs_collection
)
{
$job_adaptor
->
store
(
$our_jobs
);
foreach
my
$job
(
@$our_jobs
)
{
# warn "Stored ".$job->toString()."\n";
}
}
}
return
$hash_of_collections
{
$key
}
||=
Bio::EnsEMBL::Hive::Utils::
Collection
->
new
();
}
1
;
...
...
modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm
View file @
13f462ad
...
...
@@ -36,9 +36,11 @@ package Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use
strict
;
use
Bio::EnsEMBL::Hive
::
Utils
('
throw
')
;
use
Bio::EnsEMBL::
Hive
;
use
Bio::EnsEMBL::Hive::DBSQL::
DBConnection
;
use
Bio::EnsEMBL::Hive::DBSQL::
SqlSchemaAdaptor
;
use
Bio::EnsEMBL::Hive::
Utils
('
throw
');
use
Bio::EnsEMBL::Hive::Utils::
Collection
;
sub
new
{
...
...
@@ -253,5 +255,51 @@ sub AUTOLOAD {
return
$self
->
get_adaptor
(
$type
,
@
_
);
}
sub
load_collections
{
my
$self
=
shift
@_
;
foreach
my
$AdaptorType
('
Meta
',
'
MetaContainer
')
{
my
$adaptor
=
$self
->
get_adaptor
(
$AdaptorType
);
Bio::EnsEMBL::
Hive
->
collection
(
$AdaptorType
,
$adaptor
->
get_param_hash
()
);
}
foreach
my
$AdaptorType
('
ResourceClass
',
'
ResourceDescription
',
'
Analysis
',
'
AnalysisStats
',
'
AnalysisCtrlRule
',
'
DataflowRule
')
{
my
$adaptor
=
$self
->
get_adaptor
(
$AdaptorType
);
Bio::EnsEMBL::
Hive
->
collection
(
$AdaptorType
,
Bio::EnsEMBL::Hive::Utils::
Collection
->
new
(
$adaptor
->
fetch_all
)
);
}
}
sub
save_collections
{
my
$self
=
shift
@_
;
foreach
my
$AdaptorType
('
Meta
',
'
MetaContainer
')
{
my
$adaptor
=
$self
->
get_adaptor
(
$AdaptorType
);
while
(
my
(
$meta_key
,
$meta_value
)
=
each
%
{
Bio::EnsEMBL::
Hive
->
collection
(
$AdaptorType
)
}
)
{
$adaptor
->
remove_all_by_meta_key
(
$meta_key
);
# make sure the previous values are gone
$adaptor
->
store_pair
(
$meta_key
,
$meta_value
);
}
}
foreach
my
$AdaptorType
('
ResourceClass
',
'
ResourceDescription
',
'
Analysis
',
'
AnalysisStats
',
'
AnalysisCtrlRule
',
'
DataflowRule
')
{
my
$adaptor
=
$self
->
get_adaptor
(
$AdaptorType
);
foreach
my
$storable_object
(
Bio::EnsEMBL::
Hive
->
collection
(
$AdaptorType
)
->
list
)
{
$adaptor
->
store_or_update_one
(
$storable_object
);
# warn "Stored/updated ".$storable_object->toString()."\n";
}
}
my
$job_adaptor
=
$self
->
get_AnalysisJobAdaptor
;
foreach
my
$analysis
(
Bio::EnsEMBL::
Hive
->
collection
('
Analysis
')
->
list
)
{
if
(
my
$our_jobs
=
$analysis
->
jobs_collection
)
{
$job_adaptor
->
store
(
$our_jobs
);
foreach
my
$job
(
@$our_jobs
)
{
# warn "Stored ".$job->toString()."\n";
}
}
}
}
1
;
scripts/generate_graph.pl
View file @
13f462ad
...
...
@@ -15,7 +15,6 @@ BEGIN {
use
Getopt::
Long
qw(:config pass_through no_auto_abbrev)
;
use
Pod::
Usage
;
use
Bio::EnsEMBL::
Hive
;
use
Bio::EnsEMBL::Hive::DBSQL::
DBAdaptor
;
use
Bio::EnsEMBL::Hive::
Utils
('
script_usage
',
'
load_file_or_module
');
use
Bio::EnsEMBL::Hive::Utils::
Graph
;
...
...
@@ -72,7 +71,7 @@ sub main {
-
no_sql_schema_version_check
=>
$self
->
{'
nosqlvc
'},
);
Bio::EnsEMBL::
Hive
->
load_collections_from_dba
(
$self
->
{'
dba
'}
);
$self
->
{'
dba
'}
->
load_collections
(
);
}
if
(
$self
->
{'
pipeconfig
'})
{
...
...
scripts/init_pipeline.pl
View file @
13f462ad
...
...
@@ -42,11 +42,11 @@ sub main {
my
$hive_dba
=
Bio::EnsEMBL::Hive::DBSQL::
DBAdaptor
->
new
(
-
url
=>
$pipeconfig_object
->
pipeline_url
(),
-
no_sql_schema_version_check
=>
1
);
Bio::EnsEMBL::
Hive
->
load_collections_from_dba
(
$hive_dba
);
$hive_dba
->
load_collections
(
);
$pipeconfig_object
->
add_objects_from_config
();
Bio::EnsEMBL::
Hive
->
save_collections_to_dba
(
$hive_dba
);
$hive_dba
->
save_collections
(
);
$pipeconfig_object
->
show_useful_commands
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment