-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
94 lines (71 loc) · 2.2 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
#!/usr/bin/env nextflow
params.reads = "$launchDir/*_R{1,2}.{fastq}"
params.outdir = "$launchDir/nf-out"
params.reference = "$launchDir/genes/verum_myst.fasta"
Channel.fromPath(params.reference)
.into {fasta_ch;fasta_ch1}
Channel
.fromFilePairs( params.reads )
.ifEmpty { error "Oops! Cannot find any file matching: ${params.reads}" }
.into { read_pairs_ch; read_pairs2_ch }
process index {
input:
file reference from fasta_ch
output:
file "${reference.baseName}*" into index_ch
script:
"""
bowtie2-build $reference ${reference.simpleName}
"""
}
process mapping {
tag "$pair_id ${index.simpleName.first()}"
publishDir "${params.outdir}/bam/${index.simpleName.first()}", mode:'copy', pattern: '*.sam'
publishDir "${params.outdir}/bam/${index.simpleName.first()}/logs", mode:'copy', pattern: '*.log'
cpus 12
maxForks 3
input:
file index from index_ch.collect()
set pair_id, file(reads) from read_pairs_ch
output:
file '*.sam' into sam
file "${index.simpleName.first()}_${pair_id}.log" into logs
script:
"""
bowtie2 \\
--threads $task.cpus \\
-x ${index.simpleName.first()} \\
-q -1 ${reads[0]} -2 ${reads[1]} \\
--very-sensitive-local \\
-S ${index.simpleName.first()}_${pair_id}.sam \\
--no-unal \\
2>&1 | tee ${index.simpleName.first()}_${pair_id}.log
"""
}
process index_samtools {
input:
file reference from fasta_ch1
output:
file "${reference}*" into index_ch1
script:
"""
samtools faidx $reference
"""
}
process remove_clipping {
conda "bioconda::samclip"
tag "${index.simpleName}"
publishDir "${params.outdir}/bam/${index.simpleName}", mode:'copy', pattern: '*.sam'
input:
file(samf) from sam
file index from index_ch1.collect()
output:
file '*.sam' into sam_out
script:
"""
samclip --ref ${index} < ${samf} > clean.${samf}
"""
}
workflow.onComplete {
log.info( workflow.success ? "\nDone! Your files can be found in $launchDir/nf-out\n" : "Oops .. something went wrong" )
}