1 package SGN
::Controller
::solGS
::AsyncJob
;
4 use namespace
::autoclean
;
6 use Storable qw
/ nstore retrieve /;
7 use Carp qw
/ carp confess croak /;
12 BEGIN { extends
'Catalyst::Controller' }
14 sub get_pheno_data_query_job_args_file
{
15 my ( $self, $c, $trials ) = @_;
17 $self->get_trials_phenotype_query_jobs_args( $c, $trials );
18 my $pheno_query_args = $c->stash->{trials_phenotype_query_jobs_args
};
20 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
21 my $pheno_query_args_file = $c->controller('solGS::Files')
22 ->create_tempfile( $temp_dir, 'phenotype_data_query_args_file' );
24 nstore
$pheno_query_args, $pheno_query_args_file
26 "pheno data query job : $! serializing selection pop data query details to $pheno_query_args_file";
28 $c->stash->{pheno_data_query_job_args_file
} = $pheno_query_args_file;
31 sub get_geno_data_query_job_args_file
{
32 my ( $self, $c, $trials, $protocol_id ) = @_;
34 $self->get_trials_genotype_query_jobs_args( $c, $trials, $protocol_id );
35 my $geno_query_args = $c->stash->{trials_genotype_query_jobs_args
};
37 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
38 my $geno_query_args_file = $c->controller('solGS::Files')
39 ->create_tempfile( $temp_dir, 'genotype_data_query_args_file' );
41 nstore
$geno_query_args, $geno_query_args_file
43 "geno data query job : $! serializing selection pop data query details to $geno_query_args_file";
45 $c->stash->{geno_data_query_job_args_file
} = $geno_query_args_file;
48 sub submit_cluster_phenotype_query
{
49 my ( $self, $c, $trials ) = @_;
51 $self->get_pheno_data_query_job_args_file( $c, $trials );
52 $c->stash->{dependent_jobs
} = $c->stash->{pheno_data_query_job_args_file
};
56 sub submit_cluster_genotype_query
{
57 my ( $self, $c, $trials, $protocol_id ) = @_;
59 $self->get_geno_data_query_job_args_file( $c, $trials, $protocol_id );
60 $c->stash->{dependent_jobs
} = $c->stash->{geno_data_query_job_args_file
};
64 sub submit_cluster_training_pop_data_query
{
65 my ( $self, $c, $trials, $protocol_id ) = @_;
67 $self->get_training_pop_data_query_job_args_file( $c, $trials,
69 $c->stash->{dependent_jobs
} =
70 $c->stash->{training_pop_data_query_job_args_file
};
74 sub training_pop_data_query_job_args
{
75 my ( $self, $c, $trials, $protocol_id ) = @_;
79 foreach my $trial (@
$trials) {
80 $c->controller('solGS::Files')->phenotype_file_name( $c, $trial );
82 if ( !-s
$c->stash->{phenotype_file_name
} ) {
83 $self->get_trials_phenotype_query_jobs_args( $c, [$trial] );
84 my $pheno_query = $c->stash->{trials_phenotype_query_jobs_args
};
85 push @queries, @
$pheno_query if $pheno_query;
88 $c->controller('solGS::Files')
89 ->genotype_file_name( $c, $trial, $protocol_id );
91 if ( !-s
$c->stash->{genotype_file_name
} ) {
92 $self->get_trials_genotype_query_jobs_args( $c, [$trial],
94 my $geno_query = $c->stash->{trials_genotype_query_jobs_args
};
95 push @queries, @
$geno_query if $geno_query;
99 $c->stash->{training_pop_data_query_job_args
} = \
@queries;
102 sub get_training_pop_data_query_job_args_file
{
103 my ( $self, $c, $trials, $protocol_id ) = @_;
105 $self->training_pop_data_query_job_args( $c, $trials, $protocol_id );
106 my $training_query_args = $c->stash->{training_pop_data_query_job_args
};
108 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
109 my $training_query_args_file = $c->controller('solGS::Files')
110 ->create_tempfile( $temp_dir, 'training_pop_data_query_args' );
112 nstore
$training_query_args, $training_query_args_file
114 "training pop data query job : $! serializing selection pop data query details to $training_query_args_file";
116 $c->stash->{training_pop_data_query_job_args_file
} =
117 $training_query_args_file;
120 sub get_trials_genotype_query_jobs_args
{
121 my ( $self, $c, $trials, $protocol_id ) = @_;
125 foreach my $trial_id (@
$trials) {
127 if ( $c->stash->{check_data_exists
} ) {
128 $c->controller('solGS::Files')
129 ->first_stock_genotype_file( $c, $trial_id, $protocol_id );
130 $geno_file = $c->stash->{first_stock_genotype_file
};
133 $c->controller('solGS::Files')
134 ->genotype_file_name( $c, $trial_id, $protocol_id );
135 $geno_file = $c->stash->{genotype_file_name
};
138 if ( !-s
$geno_file ) {
140 $self->genotype_trial_query_args( $c, $trial_id, $protocol_id );
142 $c->stash->{r_temp_file
} = "genotype-data-query-${trial_id}";
143 $self->create_cluster_accessible_tmp_files($c);
144 my $out_temp_file = $c->stash->{out_file_temp
};
145 my $err_temp_file = $c->stash->{err_file_temp
};
147 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
148 my $background_job = $c->stash->{background_job
};
150 my $args_file = $c->controller('solGS::Files')
151 ->create_tempfile( $temp_dir, "geno-data-args_file-${trial_id}" );
153 nstore
$args, $args_file
155 "data queryscript: $! serializing model details to $args_file ";
157 my $check_data_exists = $c->stash->{check_data_exists
} ?
1 : 0;
158 my $dbhost = $c->config->{dbhost
};
159 my $dbname = $c->config->{dbname
};
160 my $dbpass = $c->config->{dbpass
};
161 my $dbuser = $c->config->{dbuser
};
164 'mx-run solGS::queryJobs '
173 . ' --data_type genotype '
174 . ' --population_type trial '
177 . ' --check_data_exists '
178 . $check_data_exists;
181 'temp_dir' => $temp_dir,
182 'out_file' => $out_temp_file,
183 'err_file' => $err_temp_file,
184 'cluster_host' => 'localhost'
187 my $config = $self->create_cluster_config( $c, $config_args );
192 'background_job' => $background_job,
193 'temp_dir' => $temp_dir,
196 push @queries, $job_args;
200 $c->stash->{trials_genotype_query_jobs_args
} = \
@queries;
203 sub create_genotype_data_query_jobs
{
204 my ( $self, $c, $pop_id, $protocol_id ) = @_;
206 my $data_str = $c->stash->{data_structure
};
207 $protocol_id = $c->stash->{genotyping_protocol_id
} if !$protocol_id;
210 if ( $data_str =~ /list/ ) {
211 $c->controller('solGS::List')->create_list_geno_data_query_jobs($c);
212 $geno_query_jobs = $c->stash->{list_geno_data_query_jobs
};
214 elsif ( $data_str =~ /dataset/ ) {
215 $c->controller('solGS::Dataset')
216 ->create_dataset_geno_data_query_jobs($c);
217 $geno_query_jobs = $c->stash->{dataset_geno_data_query_jobs
};
220 if ( $c->req->referer =~ /solgs\/selection\
// ) {
221 $c->stash->{pops_ids_list
} =
222 [ $c->stash->{training_pop_id
}, $c->stash->{selection_pop_id
} ];
224 $c->controller('solGS::combinedTrials')
225 ->process_trials_list_details($c);
226 $c->controller('solGS::combinedTrials')
227 ->multi_pops_geno_files( $c, $c->stash->{pops_ids_list
},
229 $c->stash->{genotype_files_list
} =
230 $c->stash->{multi_pops_geno_files
};
236 if ( $c->stash->{data_set_type
} =~ /combined/ ) {
237 $c->controller('solGS::combinedTrials')
238 ->get_combined_pops_list( $c, $pop_id );
239 $combo_pops_list = $c->stash->{combined_pops_list
};
240 $c->stash->{pops_ids_list
} = $combo_pops_list;
244 $c->stash->{training_pop_id
} = $pop_id;
247 my $trials = $c->stash->{pops_ids_list
};
249 $trials = [ $c->stash->{training_pop_id
} ]
250 if $c->stash->{training_pop_id
};
254 $trials = [ $c->stash->{selection_pop_id
} ]
255 if $c->stash->{selection_pop_id
};
259 $trials = [$pop_id] if $pop_id;
262 $self->get_trials_genotype_query_jobs_args( $c, $trials, $protocol_id );
263 $geno_query_jobs = $c->stash->{trials_genotype_query_jobs_args
};
266 return $geno_query_jobs;
269 sub create_phenotype_data_query_jobs
{
270 my ( $self, $c, $pop_id ) = @_;
272 my $data_str = $c->stash->{data_structure
};
273 my $pheno_query_jobs;
275 if ( $data_str =~ /list/ ) {
276 $c->controller('solGS::List')->create_list_pheno_data_query_jobs($c);
277 $pheno_query_jobs = $c->stash->{list_pheno_data_query_jobs
};
279 elsif ( $data_str =~ /dataset/ ) {
280 $c->controller('solGS::Dataset')
281 ->create_dataset_pheno_data_query_jobs($c);
282 $pheno_query_jobs = $c->stash->{dataset_pheno_data_query_jobs
};
287 if ( $c->stash->{data_set_type
} =~ /combined/
288 || $c->stash->{combo_pops_id
} )
290 $c->controller('solGS::combinedTrials')
291 ->get_combined_pops_list( $c, $pop_id );
292 $c->stash->{pops_ids_list
} = $c->stash->{combined_pops_list
};
293 $trials = $c->stash->{combined_pops_list
};
296 $c->stash->{training_pop_id
} = $pop_id;
299 $trials = [ $c->stash->{training_pop_id
} ] if !$trials;
301 $self->get_trials_phenotype_query_jobs_args( $c, $trials );
302 $pheno_query_jobs = $c->stash->{trials_phenotype_query_jobs_args
};
305 return $pheno_query_jobs;
308 sub get_trials_phenotype_query_jobs_args
{
309 my ( $self, $c, $trials ) = @_;
313 $c->controller('solGS::combinedTrials')
314 ->multi_pops_pheno_files( $c, $trials );
315 $c->stash->{phenotype_files_list
} = $c->stash->{multi_pops_pheno_files
};
317 foreach my $trial_id (@
$trials) {
318 my $cached = $c->controller('solGS::CachedResult')
319 ->check_cached_phenotype_data( $c, $c->stash->{trial_id
} );
322 my $args = $self->phenotype_trial_query_args( $c, $trial_id );
324 $c->stash->{r_temp_file
} = "phenotype-data-query-${trial_id}";
325 $self->create_cluster_accessible_tmp_files($c);
326 my $out_temp_file = $c->stash->{out_file_temp
};
327 my $err_temp_file = $c->stash->{err_file_temp
};
329 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
330 my $background_job = $c->stash->{background_job
};
333 $c->controller('solGS::Files')
334 ->create_tempfile( $temp_dir,
335 "pheno-data-args_file-${trial_id}" );
337 nstore
$args, $args_file
339 "data query script: $! serializing phenotype data query details to $args_file ";
341 my $dbhost = $c->config->{dbhost
};
342 my $dbname = $c->config->{dbname
};
343 my $dbpass = $c->config->{dbpass
};
344 my $dbuser = $c->config->{dbuser
};
347 'mx-run solGS::queryJobs '
356 . ' --data_type phenotype '
357 . ' --population_type trial '
362 'temp_dir' => $temp_dir,
363 'out_file' => $out_temp_file,
364 'err_file' => $err_temp_file,
365 'cluster_host' => 'localhost'
368 my $config = $self->create_cluster_config( $c, $config_args );
373 'background_job' => $background_job,
374 'temp_dir' => $temp_dir,
377 push @queries, $job_args;
381 $c->stash->{trials_phenotype_query_jobs_args
} = \
@queries if @queries;
385 sub genotype_trial_query_args
{
386 my ( $self, $c, $pop_id, $protocol_id ) = @_;
389 my $check_data_exists = $c->stash->{check_data_exists
};
391 if ( $c->stash->{check_data_exists
} ) {
392 $c->controller('solGS::Files')
393 ->first_stock_genotype_file( $c, $pop_id, $protocol_id );
394 $geno_file = $c->stash->{first_stock_genotype_file
};
397 $c->controller('solGS::Files')
398 ->genotype_file_name( $c, $pop_id, $protocol_id );
399 $geno_file = $c->stash->{genotype_file_name
};
403 'trial_id' => $pop_id,
404 'genotype_file' => $geno_file,
405 'genotyping_protocol_id' => $protocol_id,
406 'cache_dir' => $c->stash->{solgs_cache_dir
},
413 sub phenotype_trial_query_args
{
414 my ( $self, $c, $pop_id ) = @_;
416 $pop_id = $c->stash->{training_pop_id
} || $c->stash->{trial_id
} if !$pop_id;
418 $c->controller('solGS::Files')->phenotype_file_name( $c, $pop_id );
419 my $pheno_file = $c->stash->{phenotype_file_name
};
421 $c->controller('solGS::Files')->phenotype_metadata_file($c);
422 my $metadata_file = $c->stash->{phenotype_metadata_file
};
424 no warnings
'uninitialized';
426 $c->controller('solGS::Files')->traits_list_file($c);
427 my $traits_file = $c->stash->{traits_list_file
};
430 'population_id' => $pop_id,
431 'phenotype_file' => $pheno_file,
432 'traits_list_file' => $traits_file,
433 'metadata_file' => $metadata_file,
439 sub create_cluster_accessible_tmp_files
{
440 my ( $self, $c, $template ) = @_;
442 my $temp_file_template = $template || $c->stash->{r_temp_file
};
445 $c->stash->{analysis_tempfiles_dir
} || $c->stash->{solgs_tempfiles_dir
};
447 my $in_file = $c->controller('solGS::Files')
448 ->create_tempfile( $temp_dir, "${temp_file_template}-in" );
449 my $out_file = $c->controller('solGS::Files')
450 ->create_tempfile( $temp_dir, "${temp_file_template}-out" );
451 my $err_file = $c->controller('solGS::Files')
452 ->create_tempfile( $temp_dir, "${temp_file_template}-err" );
455 in_file_temp
=> $in_file,
456 out_file_temp
=> $out_file,
457 err_file_temp
=> $err_file,
463 my ( $self, $c ) = @_;
465 my $prerequisite_jobs = $c->stash->{prerequisite_jobs
} || 'none';
466 my $background_job = $c->stash->{background_job
};
467 my $dependent_jobs = $c->stash->{dependent_jobs
};
470 $c->stash->{analysis_tempfiles_dir
} || $c->stash->{solgs_tempfiles_dir
};
472 $c->stash->{r_temp_file
} = 'run-async';
473 $self->create_cluster_accessible_tmp_files($c);
474 my $err_temp_file = $c->stash->{err_file_temp
};
475 my $out_temp_file = $c->stash->{out_file_temp
};
477 my $referer = $c->req->referer;
479 my $report_file = 'none';
481 if ($background_job) {
482 $c->stash->{async
} = 1;
483 $c->controller('solGS::AnalysisQueue')
484 ->get_analysis_report_job_args_file( $c, 2 );
485 $report_file = $c->stash->{analysis_report_job_args_file
};
489 'temp_dir' => $temp_dir,
490 'out_file' => $out_temp_file,
491 'err_file' => $err_temp_file,
492 'cluster_host' => 'localhost'
495 my $job_config = $self->create_cluster_config( $c, $config_args );
496 my $job_config_file = $c->controller('solGS::Files')
497 ->create_tempfile( $temp_dir, 'job_config_file' );
499 nstore
$job_config, $job_config_file
501 "job config file: $! serializing job config to $job_config_file ";
504 'mx-run solGS::JobSubmission'
505 . ' --prerequisite_jobs '
507 . ' --dependent_jobs '
509 . ' --analysis_report_job '
514 my $cluster_job_args = {
516 'config' => $job_config,
517 'background_job' => $background_job,
518 'temp_dir' => $temp_dir,
519 'async' => $c->stash->{async
},
522 my $job = $self->submit_job_cluster( $c, $cluster_job_args );
526 sub get_selection_pop_query_args
{
527 my ( $self, $c ) = @_;
529 my $selection_pop_id = $c->stash->{selection_pop_id
};
530 my $protocol_id = $c->stash->{genotyping_protocol_id
};
531 my $selection_pop_geno_file;
534 if ($selection_pop_id) {
535 $c->controller('solGS::Files')
536 ->genotype_file_name( $c, $selection_pop_id, $protocol_id );
537 $selection_pop_geno_file = $c->stash->{genotype_file_name
};
541 if ( $selection_pop_id =~ /list/ ) {
542 $c->controller('solGS::List')->get_genotypes_list_details($c);
543 $genotypes_ids = $c->stash->{genotypes_ids
};
546 elsif ( $selection_pop_id =~ /dataset/ ) {
547 $pop_type = 'dataset';
553 $c->stash->{population_type
} = $pop_type;
554 my $temp_file_template = "genotype-data-query-${selection_pop_id}";
555 $self->create_cluster_accessible_tmp_files( $c, $temp_file_template );
556 my $in_file = $c->stash->{in_file_temp
};
557 my $out_temp_file = $c->stash->{out_file_temp
};
558 my $err_temp_file = $c->stash->{err_file_temp
};
560 my $selection_pop_query_args = {
561 'trial_id' => $selection_pop_id,
562 'genotype_file' => $selection_pop_geno_file,
563 'genotypes_ids' => $genotypes_ids,
564 'dataset_id' => $c->stash->{dataset_id
},
565 'out_file' => $out_temp_file,
566 'err_file' => $err_temp_file,
567 'population_type' => $pop_type,
568 'genotyping_protocol_id' => $protocol_id
571 $c->stash->{selection_pop_query_args
} = $selection_pop_query_args;
575 sub get_cluster_query_job_args
{
576 my ( $self, $c ) = @_;
578 my $pop_id = $c->stash->{selection_pop_id
};
579 my $protocol_id = $c->stash->{genotyping_protocol_id
};
581 $c->controller('solGS::Files')
582 ->genotype_file_name( $c, $pop_id, $protocol_id );
583 my $geno_file = $c->stash->{genotype_file_name
};
587 if ( !-s
$geno_file ) {
588 $c->stash->{r_temp_file
} = "genotype-data-query-${pop_id}";
589 $self->create_cluster_accessible_tmp_files($c);
590 my $out_temp_file = $c->stash->{out_file_temp
};
591 my $err_temp_file = $c->stash->{err_file_temp
};
593 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
594 my $background_job = $c->stash->{background_job
};
596 $self->get_selection_pop_query_args($c);
597 my $query_args = $c->stash->{selection_pop_query_args
};
598 my $genotype_file = $query_args->{genotype_file
};
599 my $args_file = $c->controller('solGS::Files')
600 ->create_tempfile( $temp_dir, "geno-data-args_file-${pop_id}" );
602 my $pop_type = $query_args->{population_type
};
603 my $data_type = 'genotype';
605 nstore
$query_args, $args_file
607 "data query script: $! serializing model details to $args_file ";
609 my $dbhost = $c->config->{dbhost
};
610 my $dbname = $c->config->{dbname
};
611 my $dbpass = $c->config->{dbpass
};
612 my $dbuser = $c->config->{dbuser
};
615 'mx-run solGS::queryJobs '
626 . ' --population_type '
632 'temp_dir' => $temp_dir,
633 'out_file' => $out_temp_file,
634 'err_file' => $err_temp_file,
635 'cluster_host' => 'localhost'
638 my $config = $self->create_cluster_config( $c, $config_args );
643 'background_job' => $background_job,
644 'temp_dir' => $temp_dir,
645 'genotype_file' => $genotype_file
648 push @queries, $job_args;
652 $c->stash->{cluster_query_job_args
} = \
@queries;
655 sub get_selection_pop_query_args_file
{
656 my ( $self, $c ) = @_;
658 $self->get_cluster_query_job_args($c);
659 my $selection_pop_query_args = $c->stash->{cluster_query_job_args
};
661 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
662 my $selection_pop_query_file = $c->controller('solGS::Files')
663 ->create_tempfile( $temp_dir, 'selection_pop_query_args' );
665 nstore
$selection_pop_query_args, $selection_pop_query_file
667 "selection pop query job : $! serializing selection pop data query details to $selection_pop_query_file";
669 $c->stash->{selection_pop_query_args_file
} = $selection_pop_query_file;
672 sub get_gs_modeling_jobs_args_file
{
673 my ( $self, $c ) = @_;
675 my $modeling_jobs = [];
677 if ( $c->stash->{training_traits_ids
} ) {
678 $modeling_jobs = $self->modeling_jobs($c);
681 if ($modeling_jobs) {
682 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
683 my $model_file = $c->controller('solGS::Files')
684 ->create_tempfile( $temp_dir, 'gs_model_args' );
686 nstore
$modeling_jobs, $model_file
687 or croak
"gs r script: $! serializing model details to $model_file";
689 $c->stash->{gs_modeling_jobs_args_file
} = $model_file;
694 sub get_cluster_r_job_args
{
695 my ( $self, $c ) = @_;
697 my $r_script = $c->stash->{r_script
};
698 my $input_files = $c->stash->{input_files
};
699 my $output_files = $c->stash->{output_files
};
701 if ( $r_script =~ /gs/ ) {
702 $self->get_gs_r_temp_file($c);
705 $self->create_cluster_accessible_tmp_files($c);
706 my $in_file = $c->stash->{in_file_temp
};
707 my $out_temp_file = $c->stash->{out_file_temp
};
708 my $err_temp_file = $c->stash->{err_file_temp
};
711 $c->stash->{analysis_tempfiles_dir
} || $c->stash->{solgs_tempfiles_dir
};
714 my $r_cmd_file = $c->path_to($r_script);
715 copy
( $r_cmd_file, $in_file )
716 or die "could not copy '$r_cmd_file' to '$in_file'";
720 'temp_dir' => $temp_dir,
721 'out_file' => $out_temp_file,
722 'err_file' => $err_temp_file
725 my $config = $self->create_cluster_config( $c, $config_args );
729 . "$in_file $out_temp_file "
736 'background_job' => $c->stash->{background_job
},
740 $c->stash->{cluster_r_job_args
} = $job_args;
744 sub create_cluster_config
{
745 my ( $self, $c, $args ) = @_;
748 temp_base
=> $args->{temp_dir
},
749 queue
=> $c->config->{'web_cluster_queue'},
750 max_cluster_jobs
=> 1_000_000_000
,
751 out_file
=> $args->{out_file
},
752 err_file
=> $args->{err_file
},
755 sleep => $args->{sleep}
758 if ( $args->{cluster_host
} =~ /localhost/ || !$c->config->{cluster_host
} ) {
759 $config->{backend
} = 'Slurm';
760 $config->{submit_host
} = 'localhost';
763 $config->{backend
} = $c->config->{backend
};
764 $config->{submit_host
} = $c->config->{cluster_host
};
770 sub submit_job_cluster
{
771 my ( $self, $c, $args ) = @_;
776 $job = CXGN
::Tools
::Run
->new( $args->{config
} );
777 $job->do_not_cleanup(1);
779 if ( $args->{background_job
} ) {
781 $job->run_async( $args->{cmd
} );
783 $c->stash->{r_job_tempdir
} = $job->job_tempdir();
784 $c->stash->{r_job_id
} = $job->jobid();
785 $c->stash->{cluster_job_id
} = $job->cluster_job_id();
786 $c->stash->{cluster_job
} = $job;
789 $job->run_async( $args->{cmd
} );
796 'Error occured submitting the job ' . $@
. "\nJob: " . $args->{cmd
};
797 $c->stash->{status
} =
798 'Error occured submitting the job ' . $@
. "\nJob: " . $args->{cmd
};
806 my ( $self, $c ) = @_;
808 my $modeling_traits =
809 $c->stash->{training_traits_ids
} || [ $c->stash->{trait_id
} ];
810 my $training_pop_id = $c->stash->{training_pop_id
};
811 my $selection_pop_id = $c->stash->{selection_pop_id
};
815 if ($modeling_traits) {
817 foreach my $trait_id (@
$modeling_traits) {
818 $c->stash->{trait_id
} = $trait_id;
819 $c->controller('solGS::Trait')->get_trait_details($c);
821 if ( $c->stash->{analysis_type
} =~ /multiple_models/ ) {
822 $c->stash->{analysis_type
} = 'training_model';
825 $c->controller('solGS::solGS')->input_files($c);
826 $c->controller('solGS::solGS')->output_files($c);
828 my $selection_pop_gebvs_file =
829 $c->stash->{rrblup_selection_gebvs_file
};
830 my $training_pop_gebvs_file =
831 $c->stash->{rrblup_training_gebvs_file
};
833 if ( ( $training_pop_id && !-s
$training_pop_gebvs_file )
834 || ( $selection_pop_id && !-s
$selection_pop_gebvs_file ) )
836 $self->get_gs_r_temp_file($c);
837 $c->stash->{r_script
} = 'R/solGS/gs.r';
838 $self->get_cluster_r_job_args($c);
840 push @modeling_jobs, $c->stash->{cluster_r_job_args
};
845 return \
@modeling_jobs;
848 sub get_gs_r_temp_file
{
849 my ( $self, $c ) = @_;
851 my $pop_id = $c->stash->{training_pop_id
};
852 my $trait_id = $c->stash->{trait_id
};
854 my $data_set_type = $c->stash->{data_set_type
};
856 my $selection_pop_id = $c->stash->{selection_pop_id
};
857 $c->stash->{selection_pop_id
} = $selection_pop_id;
859 $pop_id = $c->stash->{combo_pops_id
} if !$pop_id;
861 $selection_pop_id ?
$pop_id . '-' . $selection_pop_id : $pop_id;
863 if ( $data_set_type =~ /combined_populations/ ) {
864 my $combo_identifier = $c->stash->{combo_pops_id
};
865 $c->stash->{r_temp_file
} = "gs-rrblup-combo-${identifier}-${trait_id}";
868 $c->stash->{r_temp_file
} = "gs-rrblup-${identifier}-${trait_id}";
874 my ( $self, $c ) = @_;
876 if ( $c->stash->{background_job
} ) {
877 $self->get_gs_modeling_jobs_args_file($c);
878 $c->stash->{dependent_jobs
} = $c->stash->{gs_modeling_jobs_args_file
};
879 $self->run_async($c);
882 $self->get_cluster_r_job_args($c);
883 my $cluster_job_args = $c->stash->{cluster_r_job_args
};
884 $self->submit_job_cluster( $c, $cluster_job_args );
889 sub submit_cluster_compare_trials_markers
{
890 my ( $self, $c, $geno_files ) = @_;
892 $c->stash->{r_temp_file
} = 'compare-trials-markers';
893 $self->create_cluster_accessible_tmp_files($c);
894 my $out_temp_file = $c->stash->{out_file_temp
};
895 my $err_temp_file = $c->stash->{err_file_temp
};
897 my $temp_dir = $c->stash->{solgs_tempfiles_dir
};
898 my $background_job = $c->stash->{background_job
};
903 my $compare_trials_job = CXGN
::Tools
::Run
->run_cluster_perl(
907 "SGN::Controller::solGS::Search" =>
908 "compare_genotyping_platforms"
910 args
=> [ 'SGN::Context', $geno_files ],
912 [ 'SGN::Controller::solGS::Search', 'SGN::Context' ],
914 out_file
=> $out_temp_file,
915 err_file
=> $err_temp_file,
916 working_dir
=> $temp_dir,
917 max_cluster_jobs
=> 1_000_000_000
,
923 $c->stash->{r_job_tempdir
} = $compare_trials_job->tempdir();
925 $c->stash->{r_job_id
} = $compare_trials_job->job_id();
926 $c->stash->{cluster_job
} = $compare_trials_job;
928 unless ($background_job) {
929 $compare_trials_job->wait();
935 $status =~ s/\n at .+//s;