-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_stats.nf
48 lines (35 loc) · 1.15 KB
/
extract_stats.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
// 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]
}
// run script to extract info
process extract_script {
label 'q6h_1core'
conda 'conda_envs/bioinfo_raw.yml'
publishDir "${input_dir}/vial_${vial}/stats/", mode: 'copy'
input:
tuple val(vial), path(vial_fld)
each script
output:
path("stats_table_*.pkl.gz")
script:
"""
python3 $baseDir/scripts/$script --vial_fld $vial_fld --output_fld . --verbose
"""
}
workflow {
// Channel for vial folders [vial_n, vial_fld]
vials = Channel.fromPath("${input_dir}/vial_*", type:"dir")
.map { it -> extract_vial_n(it) }
// set of scripts to run on each vial dataset
scripts = ["extract_consensus_freq.py", "extract_gap_freq.py"]
// Execute each script on each vial
extract_script(vials, scripts)
}