-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathljaAssembly.nf
164 lines (123 loc) · 3 KB
/
ljaAssembly.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env nextflow
params.design = false
params.outDir = false
params.help = false
params.k = false
params.K = false
def helpMessage() {
log.info"""
Usage:
The typical command for running the pipeline is as follows:
hlaAssembly.nf --design --outDir path/to/results.pdf
Mandatory arguments:
--design [file] Path to a csv file with specie,path/to/ccs. Multiple ccs can be used by assigning same specie to different file.
--outDir [path] Path to a diectory to save the bigwig coveage files (can be local or valid S3 location.
""".stripIndent()
}
if (params.help){
helpMessage()
exit 0
}
if (!(params.design&& params.outDir)) {
exit 1, "--bamDir and --outDi are required arguments. Use --help to get the full usage."
}
if (params.k) {
k = params.k.toString().split(/,/,-1)
} else {
k = 501
}
if (params.K) {
K = params.K.toString().split(/,/,-1)
} else {
K = 5001
}
Channel
.from(k)
.set{k_ch}
Channel
.from(K)
.set{K_ch}
Channel
.fromPath(params.design)
.splitCsv()
.map { id, ccs ->
return(tuple (id,ccs,'--reads ' + file(ccs).name))
}
.groupTuple()
.set{CCS_ch}
process jla {
label 'cpu'
tag '_${id}'
container 'dovetailg/lja:alpha'
errorStrategy { task.exitStatus == 1 ? 'ignore' : 'retry' }
publishDir "${params.outDir}",
mode: "copy"
input:
tuple val(k), val(K), val(sp), path(ccs), val(cmd) from k_ch
.combine(K_ch)
.combine(CCS_ch)
output:
path("${id}")
tuple id, path("${id}/assembly.fasta") into fasta_busco_ch, fasta_n50_ch
script:
reads = cmd[0]
id = "${sp}_k${k}_K${K}"
"""
lja -k ${k} -K ${K} -t ${task.cpus} -o ${id} ${reads}
"""
}
process busco {
label 'cpu'
tag '_${id}'
container 'ezlabgva/busco:v5.3.1_cv1'
input:
tuple id, path(fasta),val(recNum) from fasta_busco_ch
.map{id,fasta ->
recNum = fasta.countFasta()
return(tuple(id,fasta,recNum))
}
output:
tuple id, path("${id}/short_summary.specific.*.txt") into busco_report_ch
when:
recNum > 0
script:
"""
busco -m genome -i ${fasta} -f -o ${id} -l eukaryota_odb10 --cpu ${task.cpus} --quiet
"""
}
process busco_reports {
label 'mezzo'
tag '_${id}'
container 'ubuntu:20.04'
publishDir "${params.outDir}/busco",
mode: "copy"
input:
tuple id, path(busco) from busco_report_ch.collect()
output:
path("*.csv")
script:
"""
busco_report.sh ${busco} > busco_report.csv
"""
}
process n50 {
label 'mezzo'
tag '_${id}'
container 'mblanche/n50'
publishDir "${params.outDir}/n50",
mode: "copy"
input:
tuple id, path(fasta), val(recNum) from fasta_n50_ch
.map{id,fasta ->
recNum = fasta.countFasta()
return(tuple(id,fasta,recNum))
}
output:
path("*.json")
when:
recNum > 0
script:
"""
n50.py -a ${fasta} -o ${id}_n50.json
"""
}