-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplots.nf
54 lines (42 loc) · 1.24 KB
/
plots.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Folder containing the input files
params.input_fld = "results/test_dataset"
// input files directory
input_dir = file(params.input_fld.replaceAll('/$',''))
assert input_dir.isDirectory()
// function to extract vial number from folder name
def extract_vial_n(fld) {
regex = /\/vial_(\d+)$/
match = (fld =~ regex)[0]
return [vial: match[1] as Integer, fld: fld]
}
// process to perform plots
process plot_script {
label 'q6h_1core'
conda 'conda_envs/bioinfo_raw.yml'
publishDir "figures/${input_dir.getName()}/vial_${vial}/", mode: 'copy'
input:
tuple val(vial), path(vial_fld)
each script
output:
path("*.pdf")
path("*.csv") optional true
script:
"""
python3 $baseDir/scripts/$script --vial_fld $vial_fld --fig_fld .
"""
}
workflow {
// channel for vial folders [vial_n, vial_fld]
vials = Channel.fromPath("${input_dir}/vial_*", type:"dir")
.map { it -> extract_vial_n(it) }
// list of plot scripts
scripts = [
"plot_coverage.py",
"plot_consensus_freq.py",
"plot_gaps.py",
"plot_insertions.py",
"plot_clips.py"
]
// execute plot scripts on each vial
plot_script(vials, scripts)
}