forked from WarrenLab/hic-scaffolding-nf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.nf
133 lines (104 loc) · 2.65 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
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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
process PRINT_VERSIONS {
output:
path("versions.txt")
"""
echo "Chromap: \$(chromap --version 2>&1)" > versions.txt
echo "YAHS: \$(yahs --version)" >> versions.txt
java -jar $params.juicerToolsJar -V | grep Version >> versions.txt
echo "assembly-stats: \$(assembly-stats -v)" >> versions.txt
"""
}
process SAMTOOLS_FAIDX {
input:
path(contigsFasta)
output:
path("${contigsFasta}.fai")
"""
samtools faidx $contigsFasta
"""
}
process CHROMAP_INDEX {
input:
path(contigsFasta)
output:
path("contigs.index")
"""
chromap -i -r $contigsFasta -o contigs.index
"""
}
process CHROMAP_ALIGN {
input:
path(contigsFasta)
path(contigsChromapIndex)
path(r1Reads)
path(r2Reads)
output:
path("aligned.bam")
"""
chromap \
--preset hic \
-r $contigsFasta \
-x $contigsChromapIndex \
--remove-pcr-duplicates \
-1 $r1Reads \
-2 $r2Reads \
--SAM \
-o aligned.sam \
-t ${task.cpus}
samtools view -bh aligned.sam | samtools sort -n > aligned.bam
"""
}
process YAHS_SCAFFOLD {
input:
path("contigs.fa")
path("contigs.fa.fai")
path("aligned.bam")
output:
path("yahs.out.bin"), emit: bin
path("yahs.out_scaffolds_final.agp"), emit: agp
path("yahs.out_scaffolds_final.fa"), emit: fasta
"""
yahs contigs.fa aligned.bam
"""
}
process JUICER_PRE {
input:
path("yahs.out.bin")
path("yahs.out_scaffolds_final.agp")
path("contigs.fa.fai")
output:
path("out_JBAT.*")
"""
juicer pre -a -o out_JBAT \
yahs.out.bin \
yahs.out_scaffolds_final.agp \
contigs.fa.fai
asm_size=\$(awk '{s+=\$2} END{print s}' contigs.fa.fai)
java -Xmx36G -jar $params.juicerToolsJar \
pre out_JBAT.txt out_JBAT.hic <(echo "assembly \${asm_size}")
"""
}
process ASSEMBLY_STATS {
input:
path("yahs.out_scaffolds_final.fa")
output:
path("assembly_stats.txt")
"""
assembly-stats yahs.out_scaffolds_final.fa > assembly_stats.txt
"""
}
workflow {
// TODO do a parameter check
PRINT_VERSIONS()
r1Reads = Channel.fromPath(params.r1Reads)
r2Reads = Channel.fromPath(params.r2Reads)
contigs = Channel.fromPath(params.contigs)
SAMTOOLS_FAIDX(contigs)
CHROMAP_INDEX(contigs)
CHROMAP_ALIGN(contigs, CHROMAP_INDEX.out, r1Reads, r2Reads)
YAHS_SCAFFOLD(contigs, SAMTOOLS_FAIDX.out, CHROMAP_ALIGN.out)
JUICER_PRE(YAHS_SCAFFOLD.out.bin, YAHS_SCAFFOLD.out.agp, SAMTOOLS_FAIDX.out)
ASSEMBLY_STATS(YAHS_SCAFFOLD.out.fasta)
}