-
Notifications
You must be signed in to change notification settings - Fork 0
/
wgs.nf
201 lines (149 loc) · 4.05 KB
/
wgs.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// make sure required packages are installed in system conda environment with environment name as tool name.
// reads should be present in hqreads folder as output of np_processing.nf workflow.
// the folders associated are given below
// bwa index should be present in the index folder
// keep fasta file in index folder with *.fasta name
// name the index prefix as genome
params.reads="$projectDir/hqReads/*_{1,2}.fastq.gz"
params.index="$projectDir/index/*.{amb,ann,pac,bwt,sa}"
params.fasta="$projectDir/index/*.fasta"
params.outdir="$projectDir/result"
params.tempdir="$projectDir/tempdir"
// inputs values required
params.seed=19
// #location of the programs programs
params.prgms="/home/akshay/miniconda3/envs"
log.info """\
Quality Control Report Workflow
Raw Reads : "${params.reads}"
index location : "${params.index}"
aligner : "bwa mem"
output directory : "${params.outdir}"
"""
process alignment {
cpus 4
conda "${params.prgms}/wgs_bwa"
input:
tuple val(sample_id), path(reads)
val seedlen
path bwa_index
output:
path "${sample_id}.bam"
script:
def index_name="${bwa_index[0]}";
def new_name=index_name.replaceAll(".amb","");
"""
bwa mem -t ${task.cpus} "${new_name}" "${reads[0]}" "${reads[1]}" | samtools view -b -hS -@ ${task.cpus} -o "${sample_id}.bam" -
"""
}
process bam_nsort {
conda "${params.prgms}/wgs_bwa"
cpus 4
input:
path bamfile
output:
path "${bamfile.baseName}_nsort.bam"
script:
"""
samtools sort -@ ${task.cpus} -n -o "${bamfile.baseName}_nsort.bam" "${bamfile}"
"""
}
process bam_fixmate {
conda "${params.prgms}/wgs_bwa"
cpus 4
input:
path nsortbam
output:
path "${nsortbam.baseName}_fixmate.bam"
script:
"""
samtools fixmate -m "${nsortbam}" "${nsortbam.baseName}_fixmate.bam"
"""
}
process bam_psort {
conda "${params.prgms}/wgs_bwa"
cpus 4
input:
path fixmatebam
output:
path "${fixmatebam.baseName}_psort.bam"
script:
"""
samtools sort -@ ${task.cpus} -o "${fixmatebam.baseName}_psort.bam" "${fixmatebam}"
"""
}
process markdupbam {
publishDir "${params.outdir}/bamfile", mode: 'copy'
conda "${params.prgms}/wgs_bwa"
cpus 4
input:
path psortbam
output:
path "${psortbam.baseName}_markdup.bam"
script:
"""
samtools markdup -@ ${task.cpus} "${psortbam}" "${psortbam.baseName}_markdup.bam"
"""
}
process bamsummary {
publishDir "${params.outdir}/bamreport", mode: 'copy'
conda "${params.prgms}/qualimap"
cpus 4
input:
path finalbam
output:
path "${new_name}_bamsummary"
script:
def bamname="${finalbam}";
def new_name=bamname.replaceAll("\\_nsort_fixmate_psort_markdup\\.bam","");
"""
qualimap bamqc -nt ${task.cpus} -bam ${finalbam} -outdir "${new_name}_bamsummary" --java-mem-size=4G
"""
}
// create fai index for mpileup
process faindx {
conda "${params.prgms}/wgs_bwa"
input:
path fasta_file
output:
path "${fasta_file}.fai"
script:
"""
samtools faidx "${fasta_file}"
"""
}
process mpileup {
conda "${params.prgms}/wgs_bwa"
input:
path finalbam
path fasta
path fasta_index
output:
path "${new_name}.mpileup"
script:
def bamname="${finalbam}";
def new_name=bamname.replaceAll("\\_nsort_fixmate_psort_markdup\\.bam","");
"""
samtools mpileup -f "${fasta}" -s "${finalbam}" -o "${new_name}.mpileup"
"""
}
process varscanSNP {
}
// process varscanindel {
// }
// process variantSummary {
// }
workflow {
channel.fromFilePairs(params.reads, checkIfExists: true).set{ read_ch }
channel.value(params.seed).set{ seed_ch }
bwa_index = channel.fromPath(params.index, checkIfExists: true).collect()
fasta_ch = channel.fromPath(params.fasta, checkIfExists: true)
faidx_ch = faindx(fasta_ch)
align_ch = alignment(read_ch,seed_ch,bwa_index)
nsort_ch = bam_nsort(align_ch)
fixmate_ch = bam_fixmate(nsort_ch)
psort_ch = bam_psort(fixmate_ch)
markdup_ch = markdupbam(psort_ch)
bamreport_ch = bamsummary(markdup_ch)
mpileup_ch = mpileup(markdup_ch,fasta_ch,faidx_ch)
}