Skip to content

Commit 84a909f

Browse files
committed
Nreport and chromosome
1 parent 97e7551 commit 84a909f

File tree

6 files changed

+44
-3
lines changed

6 files changed

+44
-3
lines changed

configs/container.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
process {
22
// guppy container config is located in the guppy_gpu module
33
withLabel: minimap2 { container = 'nanozoo/minimap2:2.26--d9ef6b6' }
4+
withLabel: plasflow { container = 'quay.io/biocontainers/plasflow:1.1.0--py35_0' }
45
}

configs/local.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
process {
22
withLabel: minimap2 { cpus = params.cores }
3+
withLabel: plasflow { cpus = params.cores }
34
}

configs/nodes.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
process {
22
withLabel: minimap2 { cpus = 24 ; memory = '32 GB' }
3+
withLabel: plasflow { cpus = 18 ; memory = '24 GB' }
34
}

workflows/mask_regions.nf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include { minimap2 } from './process/minimap2.nf'
2+
include { plasflow } from './process/plasflow.nf'
23

34
workflow mask_regions_wf {
45
take:
@@ -13,11 +14,18 @@ workflow mask_regions_wf {
1314
no_match = combined_ch.ifEmpty{ log.info "\033[0;33mCould not match any reads to genomes, please read the help via --help\033[0m" }
1415

1516
minimap2(combined_ch)
17+
plasflow(minimap2.out.fasta)
1618

1719
// report masked status
18-
report_ch = minimap2.out.view { name, file, masked -> "Sample: $name has $masked masked bases" }
20+
report_ch = plasflow.out.report.view { name, all, chr -> "$name: Total masked Bases $all with $chr on the chromosome only." }
1921

20-
emit: minimap2.out
22+
report_write_ch = plasflow.out.report
23+
.collectFile(seed: 'name,total masked bases,masked bases chromosome\n',
24+
storeDir: params.output + "/") {
25+
row -> [ "masked_bases_summary.csv", row[0] + ',' + row[1] + ',' + row[2] + '\n']
26+
}
27+
28+
emit: minimap2.out.fasta
2129

2230

2331
}

workflows/process/minimap2.nf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@ process minimap2 {
44
input:
55
tuple val(name), path(fasta), path(reads)
66
output:
7-
tuple val(name), file("${name}.masked.fasta"), env(MASKREGIONS)
7+
tuple val(name), file("${name}.masked.fasta"), env(MASKREGIONS), emit: fasta
8+
tuple val(name), file("${name}.masked.sorted.bam"), emit: bam
89
script:
910
"""
1011
minimap2 -t ${task.cpus} -o ${name}.sam -ax map-ont ${fasta} ${reads}
1112
samtools view -bS ${name}.sam | samtools sort - -@ ${task.cpus} -o ${name}.minimap.sorted.bam
1213
1314
# consensus
1415
samtools consensus -@ ${task.cpus} -f fasta -X r10.4_sup ${name}.minimap.sorted.bam -o ${name}.masked.fasta
16+
rm ${name}.minimap.sorted.bam
1517
1618
# get Masked Bases
1719
MASKREGIONS=\$(grep -v ">" ${name}.masked.fasta | grep -o "N" | wc -l)
1820
21+
# rebam to masked file for visuals
22+
minimap2 -t ${task.cpus} -o ${name}.masked.sam -ax map-ont ${name}.masked.fasta ${reads}
23+
samtools view -bS ${name}.masked.sam | samtools sort - -@ ${task.cpus} -o ${name}.masked.sorted.bam
1924
"""
2025
stub:
2126
"""

workflows/process/plasflow.nf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
process plasflow {
2+
label 'plasflow'
3+
publishDir "${params.output}/${name}/", mode: 'copy'
4+
input:
5+
tuple val(name), path(fasta), val(allmasked)
6+
output:
7+
tuple val(name), path("${name}_chromosomes.fasta"), emit: chromosomes optional true
8+
tuple val(name), path("${name}_plasmids.fasta"), emit: plasmids optional true
9+
tuple val(name), path("${name}_unclassified.fasta"), emit: unclassified optional true
10+
tuple val(name), val(allmasked), env(MASKREGIONS), emit: report
11+
script:
12+
"""
13+
PlasFlow.py --input ${fasta} --output ${name} --threshold 0.7
14+
15+
# remove empty file
16+
find . -name "*.fasta" -type f -size 0 -print0 | xargs -0 echo rm
17+
18+
# get Masked Bases
19+
MASKREGIONS=\$(grep -v ">" ${name}_chromosomes.fasta | grep -o "N" | wc -l)
20+
"""
21+
stub:
22+
"""
23+
touch ${name}_chromosomes.fasta ${name}_plasmids.fasta ${name}_unclassified.fasta
24+
"""
25+
}

0 commit comments

Comments
 (0)