diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisDataAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisDataAdaptor.pm index 126b83563ce185bd6c0a95dfbc80a5aafb4ebb13..5eee6707bda19ae95cf772379fad65627c04e729 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisDataAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisDataAdaptor.pm @@ -56,7 +56,6 @@ sub fetch_by_dbID { return $data; } - # # STORE METHODS # @@ -66,6 +65,21 @@ sub store { my ($self, $data) = @_; my $data_id; + return 0 unless($data); + + my $sth2 = $self->prepare("INSERT INTO analysis_data (data) VALUES (?)"); + $sth2->execute($data); + $data_id = $sth2->{'mysql_insertid'}; + $sth2->finish; + + return $data_id; +} + + +sub store_if_needed { + my ($self, $data) = @_; + my $data_id; + return 0 unless($data); my $sth = $self->prepare("SELECT analysis_data_id FROM analysis_data WHERE data = ?"); @@ -78,15 +92,9 @@ sub store { return $data_id; } - my $sth2 = $self->prepare("INSERT INTO analysis_data (data) VALUES (?)"); - $sth2->execute($data); - $data_id = $sth2->{'mysql_insertid'}; - $sth2->finish; - - return $data_id; + return $self->store($data); } - 1; diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm index fa9c13b0453d28bc0608c38aecb18d5c17fed5c5..d8933d19b134081a5c4c6619a38360cae23ce3c7 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm @@ -63,11 +63,11 @@ sub CreateNewJob { return undef unless(scalar @args); - my ($input_id, $analysis, $prev_analysis_job_id, $blocked) = - rearrange([qw(INPUT_ID ANALYSIS input_job_id BLOCK )], @args); + my ($input_id, $input_analysis_data_id, $analysis, $prev_analysis_job_id, $blocked) = + rearrange([qw(INPUT_ID INPUT_ANALYSIS_DATA_ID ANALYSIS input_job_id BLOCK )], @args); $prev_analysis_job_id=0 unless($prev_analysis_job_id); - throw("must define input_id") unless($input_id); + throw("must define input_id or input_analysis_data_id") unless($input_id or $input_analysis_data_id); throw("must define analysis") unless($analysis); throw("analysis must be [Bio::EnsEMBL::Analysis] not a [$analysis]") unless($analysis->isa('Bio::EnsEMBL::Analysis')); @@ -76,8 +76,10 @@ sub CreateNewJob { my $dbc = $analysis->adaptor->db->dbc; - my $dataDBA = new Bio::EnsEMBL::Hive::DBSQL::AnalysisDataAdaptor($dbc); - my $input_analysis_data_id = $dataDBA->store($input_id); + unless(defined($input_analysis_data_id)) { + my $dataDBA = $analysis->adaptor->db->get_AnalysisDataAdaptor; + $input_analysis_data_id = $dataDBA->store($input_id); + } my $sql = "INSERT ignore into analysis_job ". " SET input_analysis_data_id=\"$input_analysis_data_id\" ".