-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
116 lines (89 loc) · 2.76 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env nextflow
if(params.help) {
usage = file("$baseDir/USAGE")
cpu_count = Runtime.runtime.availableProcessors()
bindings = ["cpu_count":"$cpu_count"]
engine = new groovy.text.SimpleTemplateEngine()
template = engine.createTemplate(usage.text).make(bindings)
print template.toString()
return
}
cpu_count = Runtime.runtime.availableProcessors()
if (!params.processes){
processes = cpu_count
}
else{
processes = params.processes
}
log.info "Correlation Flow"
log.info "==============================================="
log.info ""
log.info "Start time: $workflow.start"
log.info ""
log.debug "[Command-line]"
log.debug "$workflow.commandLine"
log.debug ""
log.info "[Git Info]"
log.info "$workflow.repository - $workflow.revision [$workflow.commitId]"
log.info ""
log.info "Options"
log.info "======="
log.info "Num Processes: ${processes}"
log.info ""
log.info ""
workflow.onComplete {
log.info "Pipeline completed at: $workflow.complete"
log.info "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
log.info "Execution duration: $workflow.duration"
}
log.info "Input: $params.input"
root = file(params.input)
Channel
.fromFilePairs("$root/**/*/Register_Streamlines/*trk", size: -1) { it.parent.parent.parent.name }
.set{ subjects } // [sid, AF.trk, IFOF.trk, ...]
subjects_config = Channel.fromPath("$params.subjects_config")
Channel.fromPath("$params.bundles_config").into{ bundles_config; bundles_config_for_agreements }
subjects
.combine(subjects_config)
.combine(bundles_config)
.set{files_for_agreements}
process Compute_Agreements {
errorStrategy 'ignore'
memory '2 GB'
input:
set sid, file(subjects), file(subjects_config), file(bundles_config) from files_for_agreements
output:
file "*.json" into agreement_results
script:
String bundles_list = subjects.join(", ").replace(',', '')
"""
bundle=\$(jq 'keys[]' ${bundles_config})
for b in \$bundle
do
b=\$(eval echo \$b)
if [[ "${bundles_list}" == *"\${b}"* ]]; then
files=\$(echo ${bundles_list} |xargs -d' ' -n 1| grep \$b)
scil_evaluate_bundles_pairwise_agreement_measures.py \$files ${sid}_\${b}.json \
--indent 4 --sort_keys -f --processes ${processes}
fi
done
"""
}
agreement_results
.collect()
.set{all_files_for_agreements}
process Aggregate_Agreements {
publishDir = params.statsPublishDir
cache false
input:
file(metrics) from all_files_for_agreements
file(config) from bundles_config_for_agreements
output:
file "*.html"
file "*.json"
script:
String metrics_list = metrics.join(", ").replace(',', '')
"""
plot_agreements.py ${metrics_list} . --bundles_config ${config}
"""
}