1
1
rmats_docker <- " xinglab/rmats:v4.3.0"
2
+ cwl_version <- " v1.2"
2
3
3
4
get_array_type <- function (item_type ) {
4
5
return (list (type = " array" , items = item_type ))
@@ -9,7 +10,9 @@ get_2d_array_type <- function(item_type) {
9
10
10
11
# # Workflow inputs
11
12
wf_bam_g1_input <- InputParam(id = " wf_bam_g1" , type = " File[]" , position = - 1 )
12
- wf_bam_g2_input <- InputParam(id = " wf_bam_g2" , type = " File[]" , position = - 1 )
13
+ # # Rcwl doesn't seem to support []. Convert [null] to [] later
14
+ wf_bam_g2_input <- InputParam(id = " wf_bam_g2" , type = " File[]?" , default = list (NULL ),
15
+ position = - 1 )
13
16
wf_gtf_input <- InputParam(id = " wf_gtf" , type = " File" , position = - 1 )
14
17
wf_is_single_end_input <- InputParam(id = " wf_is_single_end" , type = " boolean?" , default = FALSE ,
15
18
position = - 1 )
@@ -90,19 +93,20 @@ prep_read_outcome_output <- OutputParam(id = "prep_read_outcome", type = "File",
90
93
glob = " $('prep_' + inputs.prep_bam_id + '_read_outcomes_by_bam.txt')" )
91
94
prep_bam_name_output <- OutputParam(id = " prep_bam_name" , type = " string" ,
92
95
outputEval = " $(inputs.prep_bam.path.split('/').pop())" )
93
- rmats_prep <- cwlProcess(baseCommand = " bash script.sh" ,
94
- requirements = list (prep_docker_req , prep_js_req , prep_init_work_dir_req ,
95
- prep_resource_req ),
96
- inputs = InputParamList(prep_bam_input , prep_bam_id_input , prep_gtf_input ,
97
- prep_is_single_end_input , prep_readLength_input ,
98
- prep_out_dir_input , prep_lib_type_input ,
99
- prep_variable_read_length_input ,
100
- prep_anchorLength_input , prep_novelSS_input ,
101
- prep_mil_input , prep_mel_input ,
102
- prep_allow_clipping_input , prep_machine_mem_gb_input ,
103
- prep_disk_space_gb_input ),
104
- outputs = OutputParamList(prep_out_rmats_output , prep_read_outcome_output ,
105
- prep_bam_name_output ))
96
+ rmats_prep <- cwlProcess(cwlVersion = cwl_version ,
97
+ baseCommand = " bash script.sh" ,
98
+ requirements = list (prep_docker_req , prep_js_req , prep_init_work_dir_req ,
99
+ prep_resource_req ),
100
+ inputs = InputParamList(prep_bam_input , prep_bam_id_input , prep_gtf_input ,
101
+ prep_is_single_end_input , prep_readLength_input ,
102
+ prep_out_dir_input , prep_lib_type_input ,
103
+ prep_variable_read_length_input ,
104
+ prep_anchorLength_input , prep_novelSS_input ,
105
+ prep_mil_input , prep_mel_input ,
106
+ prep_allow_clipping_input , prep_machine_mem_gb_input ,
107
+ prep_disk_space_gb_input ),
108
+ outputs = OutputParamList(prep_out_rmats_output , prep_read_outcome_output ,
109
+ prep_bam_name_output ))
106
110
107
111
# # Expression tool steps to convert Files to locations.
108
112
# # This avoids loading all the Files to the disk of a single worker machine.
@@ -112,7 +116,8 @@ exp_file_to_loc_file_input <- InputParam(id = "exp_file_to_loc_file", type = "Fi
112
116
exp_file_to_loc_js_req <- requireJS()
113
117
exp_file_to_loc_js <- " ${return({'exp_file_to_loc_loc': inputs.exp_file_to_loc_file.location})}"
114
118
exp_file_to_loc_loc_output <- OutputParam(id = " exp_file_to_loc_loc" , type = " string" )
115
- exp_file_to_loc <- cwlProcess(cwlClass = " ExpressionTool" ,
119
+ exp_file_to_loc <- cwlProcess(cwlVersion = cwl_version ,
120
+ cwlClass = " ExpressionTool" ,
116
121
requirements = list (exp_file_to_loc_js_req ),
117
122
inputs = InputParamList(exp_file_to_loc_file_input ),
118
123
outputs = OutputParamList(exp_file_to_loc_loc_output ),
@@ -142,7 +147,8 @@ exp_bam_id_ids_js <- paste(sep = "\n",
142
147
" }" ,
143
148
" return({'exp_bam_id_ids': id_strings})}" )
144
149
exp_bam_id_ids_output <- OutputParam(id = " exp_bam_id_ids" , type = " string[]" )
145
- exp_bam_id <- cwlProcess(cwlClass = " ExpressionTool" ,
150
+ exp_bam_id <- cwlProcess(cwlVersion = cwl_version ,
151
+ cwlClass = " ExpressionTool" ,
146
152
requirements = list (exp_bam_id_js_req ),
147
153
inputs = InputParamList(exp_bam_id_bams_input , exp_bam_id_prefix_input ),
148
154
outputs = OutputParamList(exp_bam_id_ids_output ),
@@ -151,9 +157,20 @@ exp_bam_id <- cwlProcess(cwlClass = "ExpressionTool",
151
157
step_exp_prep_g1 <- cwlStep(id = " step_exp_prep_g1" , run = exp_bam_id ,
152
158
In = list (exp_bam_id_bams = " step_exp_file_to_loc_g1/exp_file_to_loc_loc" ,
153
159
exp_bam_id_prefix = list (valueFrom = " g1_" )))
160
+
161
+ # # The 'when' expression will cause this step to be skipped if
162
+ # # there are no group 2 bams.
163
+ # # Cavatica would otherwise hang waiting for this step to complete.
164
+ # # According to the CWL specification it seems like it should be fine to
165
+ # # run this anyway and get an empty list.
166
+ # # If it is skipped then the output will be null.
167
+ # # That should not be an issue for step_prep_g2 since it scatters on
168
+ # # "prep_bam" and "prep_bam_id" and if any scatter param evaluates to []
169
+ # # then the step is skipped and produces [] as output.
154
170
step_exp_prep_g2 <- cwlStep(id = " step_exp_prep_g2" , run = exp_bam_id ,
155
171
In = list (exp_bam_id_bams = " step_exp_file_to_loc_g2/exp_file_to_loc_loc" ,
156
- exp_bam_id_prefix = list (valueFrom = " g2_" )))
172
+ exp_bam_id_prefix = list (valueFrom = " g2_" )),
173
+ when = " $(inputs.exp_bam_id_bams.length > 0)" )
157
174
158
175
# # Prep step scatter over bam_g1
159
176
step_prep_g1 <- cwlStep(id = " step_prep_g1" ,
@@ -225,6 +242,9 @@ post_disk_space_gb_input <- InputParam(id = "post_disk_space_gb", type = "int",
225
242
226
243
post_script_string <- paste(sep = " \n " ,
227
244
" ${" ,
245
+ " var has_g2 = inputs.post_bam_name_g2.length > 0" ,
246
+ " var b2_opt = has_g2 ? '--b2' : ''" ,
247
+ " var b2_val = has_g2 ? 'bam_g2.txt' : ''" ,
228
248
" var anchorLength_opt = inputs.post_anchorLength != null ? '--anchorLength' : ''" ,
229
249
" var anchorLength_string = inputs.post_anchorLength != null ? inputs.post_anchorLength : ''" ,
230
250
" var is_default_stats = (!inputs.post_paired_stats) && (!inputs.post_darts_model)" ,
@@ -287,7 +307,7 @@ post_script_string <- paste(sep = "\n",
287
307
" }" ,
288
308
" }" ,
289
309
" script += ' > bam_g2.txt\\ n'" ,
290
- " script += 'python /rmats/rmats.py --b1 bam_g1.txt --b2 bam_g2.txt --gtf ' + inputs.post_gtf.path + ' --readLength ' + inputs.post_readLength + ' --nthread ' + inputs.post_nthread + ' --od ' + inputs.post_out_dir + ' --tmp fd_rmats --task post ' + anchorLength_opt + ' ' + anchorLength_string + ' --tstat ' + inputs.post_tstat + ' ' + cstat_opt + ' ' + cstat_val + ' ' + statoff_opt + ' ' + paired_stats_opt + ' ' + darts_model_opt + ' ' + darts_cutoff_opt + ' ' + darts_cutoff_val + ' ' + novelSS_opt + ' ' + mil_opt + ' ' + mil_val + ' ' + mel_opt + ' ' + mel_val + ' ' + individual_counts_opt + '\\ n'" ,
310
+ " script += 'python /rmats/rmats.py --b1 bam_g1.txt ' + b2_opt + ' ' + b2_val + ' --gtf ' + inputs.post_gtf.path + ' --readLength ' + inputs.post_readLength + ' --nthread ' + inputs.post_nthread + ' --od ' + inputs.post_out_dir + ' --tmp fd_rmats --task post ' + anchorLength_opt + ' ' + anchorLength_string + ' --tstat ' + inputs.post_tstat + ' ' + cstat_opt + ' ' + cstat_val + ' ' + statoff_opt + ' ' + paired_stats_opt + ' ' + darts_model_opt + ' ' + darts_cutoff_opt + ' ' + darts_cutoff_val + ' ' + novelSS_opt + ' ' + mil_opt + ' ' + mil_val + ' ' + mel_opt + ' ' + mel_val + ' ' + individual_counts_opt + '\\ n'" ,
291
311
" script += 'tar czf ' + inputs.post_out_dir + '.tar.gz ' + inputs.post_out_dir + '\\ n'" ,
292
312
" return(script)}" )
293
313
@@ -300,7 +320,8 @@ post_resource_req <- requireResource(coresMin = "$(inputs.post_nthread)",
300
320
outdirMin = " $(inputs.post_disk_space_gb * 1024)" )
301
321
post_out_tar_output <- OutputParam(id = " post_out_tar" , type = " File" ,
302
322
glob = " $(inputs.post_out_dir + '.tar.gz')" )
303
- rmats_post <- cwlProcess(baseCommand = " bash script.sh" ,
323
+ rmats_post <- cwlProcess(cwlVersion = cwl_version ,
324
+ baseCommand = " bash script.sh" ,
304
325
requirements = list (post_docker_req , post_js_req , post_init_work_dir_req ,
305
326
post_resource_req ),
306
327
inputs = InputParamList(post_bam_name_g1_input , post_bam_name_g2_input ,
@@ -360,7 +381,8 @@ exp_read_outcome_outcomes_js <- paste(sep = "\n",
360
381
" }" ,
361
382
" return({'exp_read_outcome_outcomes': outcomes})}" )
362
383
exp_read_outcome_outcomes_output <- OutputParam(id = " exp_read_outcome_outcomes" , type = " File[]" )
363
- exp_read_outcome <- cwlProcess(cwlClass = " ExpressionTool" ,
384
+ exp_read_outcome <- cwlProcess(cwlVersion = cwl_version ,
385
+ cwlClass = " ExpressionTool" ,
364
386
requirements = list (exp_read_outcome_js_req ),
365
387
inputs = InputParamList(exp_read_outcome_prep_g1_input ,
366
388
exp_read_outcome_prep_g2_input ),
@@ -378,7 +400,7 @@ wf_out_tar_output <- OutputParam(id = "wf_out_tar", type = "File",
378
400
outputSource = " step_post/post_out_tar" )
379
401
wf_scatter_req <- requireScatter()
380
402
wf_step_input_exp_req <- requireStepInputExpression()
381
- workflow <- cwlWorkflow(cwlVersion = " v1.0 " ,
403
+ workflow <- cwlWorkflow(cwlVersion = cwl_version ,
382
404
requirements = list (wf_scatter_req , wf_step_input_exp_req ),
383
405
inputs = InputParamList(wf_bam_g1_input , wf_bam_g2_input , wf_gtf_input ,
384
406
wf_is_single_end_input , wf_readLength_input ,
0 commit comments