-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.nf
executable file
·77 lines (67 loc) · 2.7 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
include {check_files; get_sites_only_1; combine_vcfs_1; bcftools_stats; parse_bcftools_stats; combine_csv } from './modules/qc'
workflow report{
take:
main:
datasets = []
params.datasets.each { dataset, description, dataset_vcf, dataset_sample ->
datas = []
dataset_vcfs = file(dataset_vcf)
if (dataset_vcfs instanceof List){
dataset_vcfs.each{ vcf ->
datas = [ dataset, description.split().join('-') ]
check_files([vcf, dataset_sample])
datas << vcf
datas << dataset_sample
datasets << datas
}
}
else{
datas = [ dataset, description.split().join('-') ]
check_files([dataset_vcf, dataset_sample])
datas << dataset_vcf
datas << dataset_sample
datasets << datas
}
}
datasets_sites = []
params.datasets_sites.each { dataset, description, dataset_vcf, dataset_sample ->
datas = []
dataset_vcfs = file(dataset_vcf)
if (dataset_vcfs instanceof List){
dataset_vcfs.each{ vcf ->
datas = [ dataset, description.split().join('-') ]
check_files([vcf, dataset_sample])
datas << vcf
datas << dataset_sample
datasets_sites << datas
}
}
else{
datas = [ dataset, description.split().join('-') ]
check_files([dataset_vcf, dataset_sample])
datas << dataset_vcf
datas << dataset_sample
datasets_sites << datas
}
}
datasets_ch = Channel.from(datasets)
datasets_sites_ch = Channel.from(datasets_sites)
get_sites_only_1(datasets_ch.map{ dataset, description, vcf, sample -> [ dataset, description, file(vcf) ] })
sites_datas = get_sites_only_1.out.groupTuple(by:[0,1])
.mix(datasets_sites_ch.groupTuple(by:[0,1])
.map{ dataset, desc, vcfs, samples -> [ dataset, desc, vcfs ]})
combine_vcfs_1(sites_datas)
bcftools_stats(combine_vcfs_1.out)
parse_bcftools_stats(bcftools_stats.out)
all_stats = parse_bcftools_stats.out.map{ dataset, step, stats -> [ 'H3A_report', dataset, step, stats ] }
.groupTuple(by:0)
.map{ group, datasets, steps, stats -> [ group, stats, 'csv' ] }
combine_csv(all_stats)
emit:
datasets_ch
}
workflow{
report()
}