Skip to content
Snippets Groups Projects
Commit e0b9856f authored by Leo Gordon's avatar Leo Gordon
Browse files

In case no -logic_name/-analysis_id was supplied, show the list of analyses...

In case no -logic_name/-analysis_id was supplied, show the list of analyses that have no incoming dataflow (and so are candidates for seeding)
parent c5ad3d59
No related branches found
No related tags found
No related merge requests found
...@@ -9,65 +9,84 @@ use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor; ...@@ -9,65 +9,84 @@ use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor; use Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor;
use Bio::EnsEMBL::Hive::Utils ('destringify', 'stringify', 'script_usage'); use Bio::EnsEMBL::Hive::Utils ('destringify', 'stringify', 'script_usage');
my ($reg_conf, $reg_alias, $url, $analysis_id, $logic_name, $input_id); sub show_seedable_analyses {
my ($hive_dba) = @_;
GetOptions( my $analyses = $hive_dba->get_AnalysisAdaptor->fetch_all();
# connect to the database: my $incoming = $hive_dba->get_DataflowRuleAdaptor->fetch_HASHED_FROM_to_analysis_url_TO_dataflow_rule_id();
'reg_conf|regfile=s' => \$reg_conf, my $job_adaptor = $hive_dba->get_AnalysisJobAdaptor;
'reg_alias|regname=s' => \$reg_alias,
'url=s' => \$url, print "\nYou haven't specified neither -logic_name nor -analysis_id of the analysis being seeded.\n";
print "\nSeedable analyses without incoming dataflow:\n";
# identify the analysis: foreach my $analysis (@$analyses) {
'analysis_id=i' => \$analysis_id, my $logic_name = $analysis->logic_name;
'logic_name=s' => \$logic_name, unless($incoming->{$logic_name}) {
print "\t".$logic_name." (".$analysis->dbID.")\n";
# specify the input_id (as a string): }
'input_id=s' => \$input_id, }
);
my $hive_dba;
if($reg_conf and $reg_alias) {
Bio::EnsEMBL::Registry->load_all($reg_conf);
$hive_dba = Bio::EnsEMBL::Registry->get_DBAdaptor($reg_alias, 'hive');
} elsif($url) {
$hive_dba = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(-url => $url);
} else {
warn "\nERROR: Connection parameters (url or reg_conf+reg_alias) need to be specified\n";
script_usage(1);
} }
my $analysis_adaptor = $hive_dba->get_AnalysisAdaptor;
my $analysis; sub main {
if($logic_name) { my ($reg_conf, $reg_alias, $url, $analysis_id, $logic_name, $input_id);
$analysis = $analysis_adaptor->fetch_by_logic_name( $logic_name )
or die "Could not fetch analysis '$logic_name'"; GetOptions(
} else { # connect to the database:
unless($analysis_id) { 'reg_conf|regfile=s' => \$reg_conf,
$analysis_id = 1; 'reg_alias|regname=s' => \$reg_alias,
warn "Neither -logic_name nor -analysis_id was set, assuming analysis_id='$analysis_id'\n"; 'url=s' => \$url,
# identify the analysis:
'analysis_id=i' => \$analysis_id,
'logic_name=s' => \$logic_name,
# specify the input_id (as a string):
'input_id=s' => \$input_id,
);
my $hive_dba;
if($reg_conf and $reg_alias) {
Bio::EnsEMBL::Registry->load_all($reg_conf);
$hive_dba = Bio::EnsEMBL::Registry->get_DBAdaptor($reg_alias, 'hive');
} elsif($url) {
$hive_dba = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(-url => $url);
} else {
warn "\nERROR: Connection parameters (url or reg_conf+reg_alias) need to be specified\n";
script_usage(1);
} }
$analysis = $analysis_adaptor->fetch_by_dbID( $analysis_id )
or die "Could not fetch analysis with dbID='$analysis_id'";
}
unless($input_id) { my $analysis_adaptor = $hive_dba->get_AnalysisAdaptor;
$input_id = '{}'; my $analysis;
warn "Since -input_id has not been set, assuming input_id='$input_id'\n"; if($logic_name) {
} $analysis = $analysis_adaptor->fetch_by_logic_name( $logic_name )
or die "Could not fetch analysis '$logic_name'";
} elsif($analysis_id) {
$analysis = $analysis_adaptor->fetch_by_dbID( $analysis_id )
or die "Could not fetch analysis with dbID='$analysis_id'";
} else {
show_seedable_analyses($hive_dba);
exit(0);
}
unless($input_id) {
$input_id = '{}';
warn "Since -input_id has not been set, assuming input_id='$input_id'\n";
}
# Make sure all job creations undergo re-stringification # Make sure all job creations undergo re-stringification
# to avoid alternative "spellings" of the same input_id hash: # to avoid alternative "spellings" of the same input_id hash:
$input_id = stringify( destringify( $input_id ) ); $input_id = stringify( destringify( $input_id ) );
Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor->CreateNewJob( Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor->CreateNewJob(
-analysis => $analysis, -analysis => $analysis,
-input_id => $input_id, -input_id => $input_id,
-prev_job_id => undef, # this job has been created by the initialization script, not by another job -prev_job_id => undef, # this job has been created by the initialization script, not by another job
) or die "Could not create job '$input_id' (it could have been there already)\n"; ) or die "Could not create job '$input_id' (it could have been there already)\n";
warn "Job '$input_id' in analysis '".$analysis->logic_name."'(".$analysis->dbID.") has been created\n"; warn "Job '$input_id' in analysis '".$analysis->logic_name."'(".$analysis->dbID.") has been created\n";
}
main();
__DATA__ __DATA__
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment