-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimap.nf
104 lines (74 loc) · 2.12 KB
/
minimap.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
#!/usr/bin/env nextflow
params.fastaDir = false
params.outDir = false
params.genome = 'hg38'
params.help = false
def helpMessage() {
log.info"""
Usage:
The typical command for running the pipeline is as follows:
mininmap --fastaDir ./path/to/fasta --outDir path/to/results
Mandatory arguments:
--fastaDir [path] Path to a directory containing the fasta files to align (can be local or valid S3 location)..
--outDir [path] Path to a diectory to save the bigwig coveage files (can be local or valid S3 location).
Facultative arguments
--genome [path or def] Id of existing genome or path to a fasta file. Default: hg38
""".stripIndent()
}
if (params.help){
helpMessage()
exit 0
}
if ( !(params.fastaDir && params.outDir) ) {
exit 1, "--fastaDir and --outDir are required arguments. Use --help to get the full usage."
}
if (!params.genome =~ /hg19|hg38|mm10|dm3|hg38_hla|susScr11|rn6|GRCg6a/){
Channel
.fromPath("${params.genome}")
.set { mm_ref }
} else {
Channel
.fromPath("${HOME}/ebs/genome/nextflow/${params.genome}/${params.genome}.fa/", checkIfExists: true)
.set { mm_ref }
}
process minimap {
echo true
label 'cpu'
tag "_${id}"
container 'mblanche/minimap2'
publishDir "${params.outDir}",
mode: 'copy'
input:
path(fasta) from Channel
.fromPath("${params.fastaDir}/*.{fasta,fa,fasta.gz,fa.gz}")
path(ref) from mm_ref.first()
output:
tuple val(id), env(chrN), path("*.paf") into paf_ch
script:
id = (fasta.name.toString().split(/\./))[0]
"""
chrN=\$(grep -c '^>' ${ref})
minimap2 -x asm5 -t ${task.cpus} ${ref} ${fasta} > ${id}.paf
"""
}
process plotly {
label 'median'
tag "_${id}"
container 'mblanche/minimap2'
publishDir "${params.outDir}/plots",
mode: 'copy'
input:
tuple id, val(chrN), path(paf) from paf_ch
output:
path "*"
script:
"""
pafCoordsDotPlotly.R \
-i ${paf} \
-o ${id}.plot \
-m 2000 \
-q 500000 \
-k ${chrN} \
-s -t -l -p 12
"""
}