-
Notifications
You must be signed in to change notification settings - Fork 1
/
eval.nf
60 lines (45 loc) · 2.27 KB
/
eval.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
//load in help function
File helppages_class_file = new File("./src/Helppages.groovy");
Class HelppagesClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(helppages_class_file);
GroovyObject help = (GroovyObject) HelppagesClass.newInstance();
if (params.help) { exit 0, help.helpEval(workflow.manifest.version, params) }
if (params.callsets_dir == "" && params.sample_sheet == "" || params.callsets_dir != "" && params.sample_sheet != ""){
exit 1, "Data input incorrect - please supply only one of the following parameters: sample_sheet, callsets_dir\n"
}
// include modules - here, modules are single processes
include { SAMTOOLS_FAIDX } from './modules/samtools/faidx/main.nf'
include { HAPPY } from './modules/happy/main.nf'
include { SOMPY_SUMMARY } from './modules/reporting/main.nf'
workflow{
// ------------------
// | Input channels |
// ------------------
ch_ref = Channel.value("$baseDir/" + params.reference)
ch_ref_idx = SAMTOOLS_FAIDX(ch_ref)
if (params.callsets_dir != "") {
ch_callsets = Channel.fromPath(params.callsets_dir + "/" + "*.{vcf,vcf.gz}", checkIfExists: true)
ch_callsets
.map { it -> tuple(it.toString().split('/')[-1].tokenize('_')[1].replaceFirst('.vcf', '').replaceFirst('.gz', '').toInteger(), file(it)) }
.set {ch_callsets}
// ch_callsets.view()
ch_truthsets = Channel.fromPath(params.outdir + "/" + "simulated_hap*.vcf", checkIfExists: true)
ch_truthsets
.map { it -> tuple(it.toString().split('/')[-1].tokenize('_')[1].replaceFirst('hap', '').replaceFirst('.vcf', '').toInteger(), file(it)) }
.set {ch_truthsets}
// ch_truthsets.view()
ch_truthsets.join(ch_callsets, by: 0)
.set {ch_variantsets_map}
// ch_variantsets_map.view()
} else {
ch_variantsets_map = Channel
.fromPath(params.sample_sheet, checkIfExists: true)
.splitCsv(header: true, sep: ",")
.map {row -> [row["index"] as Integer, row["truthset"], row["callset"]]}
// .view()
}
// ------------------
// | Main processes |
// ------------------
(ch_csv,ch_json) = HAPPY(ch_variantsets_map,ch_ref,ch_ref_idx)
SOMPY_SUMMARY(ch_csv.collect())
}