-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassembly.nf
130 lines (100 loc) · 2.72 KB
/
assembly.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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
params.read_length = 250
params.accessions = "data/course_run_ids.txt"
params.min_contig_len = 1000
params.min_length = 60
params.min_quality = 20
params.trim_front = 5
params.threads = 24
params.gtdb = "/proj/gibbons/refs/gtdb"
process download {
publishDir "${baseDir}/data/sra"
cpus 4
input:
val(id)
output:
tuple val(id), path("${id}_*.fastq.gz")
"""
fasterq-dump -t ${task.cpus} ${id}
gzip *.fastq
"""
}
process preprocess {
cpus 4
publishDir "${baseDir}/data/preprocessed"
input:
tuple val(id), path(reads)
output:
tuple val(id), path("${id}_filtered_R*.fastq.gz"), path("${id}_fastp.json"), path("${id}.html")
"""
fastp -i ${reads[0]} -I ${reads[1]} \
-o ${id}_filtered_R1.fastq.gz -O ${id}_filtered_R2.fastq.gz \
--json ${id}_fastp.json --html ${id}.html \
--trim_front1 ${params.trim_front} -l ${params.min_length} \
-3 -M ${params.min_quality} -r -w ${task.cpus}
"""
}
process multiqc {
publishDir "${baseDir}/data", mode: "copy", overwrite: true
input:
val(preprocess)
output:
path("multiqc_report.html")
"""
multiqc ${baseDir}/data/preprocessed
"""
}
process megahit {
cpus 4
publishDir "${baseDir}/data/", mode: "copy", overwrite: true
input:
tuple val(id), path(reads), path(json), path(report)
output:
tuple val(id), path("assembled/${id}.asm1.fna")
"""
megahit -1 ${reads[0]} -2 ${reads[1]} -o contigs -t ${task.cpus} -m 0.5 \
--min-contig-len ${params.min_contig_len} --out-prefix ${id}
mv contigs/${id}.contigs.fa contigs/${id}.asm1.fna
"""
}
process classify {
cpus params.threads
publishDir "${baseDir}/data", mode: "copy", overwrite: true
input:
path(genomes)
output:
path("gtdb")
"""
mkdir assemblies && mv *.asm1.fna assemblies
GTDBTK_DATA_PATH=${params.gtdb} gtdbtk classify_wf \
--genome_dir assemblies/ --prefix assemblies \
--cpus ${task.cpus} --out_dir gtdb
"""
}
process tree {
cpus params.threads
publishDir "${baseDir}/data", mode: "copy", overwrite: true
input:
path(gtdb)
output:
path("bacteria.nwk")
"""
OMP_NUM_THREADS=${task.cpus} FastTreeMP \
-wag -out bacteria.nwk ${gtdb}/assemblies.bac120.user_msa.fasta
"""
}
workflow {
ids = Channel
.fromPath("${baseDir}/${params.accessions}")
.splitText()
.map{it -> it.trim()}
ids | download | preprocess | megahit
multiqc(preprocess.out.collect())
megahit.out
.map{it -> it[1]}
.filter{it.size() > 0}
.collect()
.set{assemblies}
assemblies| classify | tree
}