-
Notifications
You must be signed in to change notification settings - Fork 1
/
genocross.nf
146 lines (108 loc) · 3.51 KB
/
genocross.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env nextflow
/*
Simply run nextflow pipeline as:
nextflow run genocross.nf --input "*vcf" --parents "5856x9452" --db hdf5_file --db_acc hdf5_acc_file --outdir output_folder
*/
/*
* SET UP CONFIGURATION VARIABLES
*/
params.input = false
params.parents=false
params.windows=200000
params.hmm = false
params.outdir = 'genotype_cross'
params.genome = "athaliana_tair10"
params.project = "the1001genomes"
// databases
params.db = "/lustre/scratch/projects/the1001genomes/rahul/101.VCF_1001G_1135/1135g_SNP_BIALLELIC.hetfiltered.snpmat.6oct2015.hdf5"
params.db_acc= "/lustre/scratch/projects/the1001genomes/rahul/101.VCF_1001G_1135/1135g_SNP_BIALLELIC.hetfiltered.snpmat.6oct2015.acc.hdf5"
//input files
input_files = Channel
.fromPath ( params.input )
.map { [ "$it.baseName", "${it.getParent()}", file("$it") ] }
.ifEmpty { exit 1, "Cannot find any input files matching: ${params.input}\nNB: Path needs to be enclosed in quotes!\n" }
db_file = Channel
.fromPath ( params.db )
.ifEmpty { exit 1, "please provide hdf5 file as a database" }
db_acc_file = Channel
.fromPath ( params.db_acc )
.ifEmpty { exit 1, "please provide hdf5 acc file as a database" }
process parse_inputfiles {
tag { "${prefix}" }
storeDir "${input_folder}"
input:
set val(prefix), val(input_folder), file(input_file) from input_files
output:
set val(prefix), file("${input_file}.snpmatch.npz") into input_gzips
file "${input_file}.snpmatch.stats.json" into input_stats
script:
"""
snpmatch parser -v -i $input_file
"""
}
input_files_dbs = input_gzips.combine(db_file).combine(db_acc_file)
if (params.hmm) {
process genotype_cross {
tag { "${prefix}" }
publishDir "$params.outdir", mode: 'copy'
errorStrategy { task.exitStatus in [143,137] ? 'retry' : 'ignore' }
input:
set val(prefix), file(input_npz), file(f_db), file(f_db_acc) from input_files_dbs
output:
file "${prefix}.genotyper.txt" into snpmatch_output
script:
"""
snpmatch genotype_cross -v -e $f_db_acc -i $input_npz -p "$params.parents" -b "$params.windows" -o ${prefix}.genotyper.txt --hmm
"""
}
} else {
process genotype_cross {
tag { "${prefix}" }
publishDir "$params.outdir", mode: 'copy'
errorStrategy { task.exitStatus in [143,137] ? 'retry' : 'ignore' }
input:
set val(prefix), file(input_npz), file(f_db), file(f_db_acc) from input_files_dbs
output:
file "${prefix}.genotyper.txt" into snpmatch_output
script:
"""
snpmatch genotype_cross -v -e $f_db_acc -i $input_npz -p "$params.parents" -b "$params.windows" -o ${prefix}.genotyper.txt --genome $params.genome
"""
}
}
snpmatch_output
.collect()
.into{ input_csv; input_hdf5 }
if (params.hmm) {
process genotyper_csv {
publishDir "$params.outdir", mode: 'copy'
input:
file "*" from input_csv
output:
file "genotyper.csv" into output_table
"""
python $workflow.projectDir/bin/03_makeCSVTable_CrossGenotyper.py -o genotyper.csv -i ./
"""
}
} else {
process genotyper_csv {
input:
file "*" from input_csv
output:
file "genotyper_temp.csv" into output_table
"""
python $workflow.projectDir/bin/03_makeCSVTable_CrossGenotyper.py -o genotyper_temp.csv -i ./
"""
}
process fill_geno {
publishDir "$params.outdir", mode: 'copy'
label 'env_rcsv'
input:
file incsv from output_table
output:
file "genotyper.csv" into filled_csv
"""
Rscript $workflow.projectDir/bin/04_fill_geno.R -i $incsv -o genotyper
"""
}
}