Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/nf-core/parsnp/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- "bioconda::parsnp=2.1.5"
56 changes: 56 additions & 0 deletions modules/nf-core/parsnp/main.nf
Comment thread
emmcauley marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
process PARSNP {
tag "${meta.id}"
label 'process_high'

conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/78/78d7fff752adf0b7ff156545536bbe58f8e6e8c5e1b1513f9a726747ee686900/data'
: 'community.wave.seqera.io/library/parsnp:2.1.5--2c7f64ad14a79523'}"

input:
tuple val(meta), path(genomes, stageAs: "genomes/*")
path reference

output:
tuple val(meta), path("*.xmfa"), emit: xmfa
tuple val(meta), path("*.ggr"), emit: ggr
tuple val(meta), path("*.snps.mblocks"), emit: snps_mblocks, optional: true
tuple val(meta), path("*.tree"), emit: tree
tuple val(meta), path("partition"), emit: partition, optional: true
tuple val("${task.process}"), val('parsnp'), eval("parsnp --version 2>/dev/null | tail -n 1 | sed 's/parsnp //'"), topic: versions, emit: versions_parsnp

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
parsnp \\
-r "${reference}" \\
-d genomes/ \\
-o parsnp_out \\
-p ${task.cpus} \\
${args}

mv parsnp_out/parsnp.xmfa ${prefix}.xmfa
mv parsnp_out/parsnp.ggr ${prefix}.ggr
if [ -f parsnp_out/parsnp.snps.mblocks ]; then
mv parsnp_out/parsnp.snps.mblocks "${prefix}.snps.mblocks"
fi
mv parsnp_out/parsnp.tree ${prefix}.tree
if [ -d parsnp_out/partition ]; then
mv parsnp_out/partition .
fi
"""

stub:
Comment thread
famosab marked this conversation as resolved.
def prefix = task.ext.prefix ?: "${meta.id}"
Comment thread
emmcauley marked this conversation as resolved.
"""
touch ${prefix}.xmfa
touch ${prefix}.ggr
touch ${prefix}.snps.mblocks
touch ${prefix}.tree
mkdir partition
Comment thread
emmcauley marked this conversation as resolved.
Outdated
"""
}
120 changes: 120 additions & 0 deletions modules/nf-core/parsnp/meta.yml
Comment thread
emmcauley marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "parsnp"
description: "Parsnp is a command-line-tool for efficient microbial core genome alignment and SNP detection."
keywords:
- alignment
- bacteria
- phylogeny
- microbial genomics
- core genome
- SNP

tools:
- "parsnp":
description: "Parsnp is a command-line-tool for efficient microbial core genome alignment and SNP detection."
homepage: "https://harvest.readthedocs.io/en/latest/content/parsnp/tutorial.html"
documentation: "https://harvest.readthedocs.io/en/latest/content/parsnp/tutorial.html"
tool_dev_url: "https://github.com/marbl/parsnp"
doi: "10.1093/bioinformatics/btae311"
licence: ["custom; see https://raw.githubusercontent.com/marbl/parsnp/master/LICENSE"]
identifier: biotools:parsnp

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- genomes:
type: directory
description: Directory containing genome assemblies in FASTA format to be aligned
- reference:
type: file
description: Reference genome in FASTA format
pattern: "*.{fasta,fa,fna}"
ontologies:
- edam: "http://edamontology.org/format_1929" # FASTA

output:
xmfa:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*.xmfa":
type: file
description: Core-genome multiple sequence alignment in XMFA format
pattern: "*.xmfa"
Comment thread
emmcauley marked this conversation as resolved.
ontologies: []
ggr:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*.ggr":
type: file
description: Compressed binary representation of the alignment generated by the Harvest toolkit, used for visualization with Gingr
pattern: "*.ggr"
Comment thread
emmcauley marked this conversation as resolved.
ontologies: []
snps_mblocks:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*.snps.mblocks":
type: file
description: Core-SNP signature of each sequence in FASTA format, used to generate the phylogeny. Absent when no SNPs are detected.
pattern: "*.snps.mblocks"
ontologies:
- edam: "http://edamontology.org/format_1929" # FASTA
tree:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*.tree":
type: file
description: Resulting phylogeny in Newick format
pattern: "*.tree"
ontologies:
- edam: "http://edamontology.org/format_1910" # Newick
partition:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "partition":
type: directory
description: Output directory from partition mode containing results of each partitioned run. Only present when --partition is specified.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a --partition test then to see if this works? :)

pattern: "partition"
versions_parsnp:
- - ${task.process}:
type: string
description: The name of the process
- parsnp:
type: string
description: The name of the tool
- "parsnp --version 2>/dev/null | tail -n 1 | sed 's/parsnp //'":
type: eval
description: The expression to obtain the version of the tool

topics:
versions:
- - ${task.process}:
type: string
description: The process
- parsnp:
type: string
description: The tool name
- parsnp --version 2>/dev/null | tail -n 1 | sed 's/parsnp //':
type: eval
description: The expression to obtain the version of the tool
authors:
- "@emmcauley"
maintainers:
- "@emmcauley"
107 changes: 107 additions & 0 deletions modules/nf-core/parsnp/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
nextflow_process {

name "Test Process PARSNP"
script "../main.nf"
process "PARSNP"

tag "modules"
tag "modules_nfcore"
tag "parsnp"

test("candidatus_portiera_aleyrodidarum - fasta") {
when {
process {
"""
def genome = file('https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/prokaryotes/candidatus_portiera_aleyrodidarum/genome/genome.fasta', checkIfExists: true)
def genome2 = genome.copyTo('portiera_2.fa')
Comment thread
famosab marked this conversation as resolved.

input[0] = [[ id:'test' ], [genome, genome2]]
input[1] = genome
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(sanitizeOutput(process.out)).match() }
)
}
}

test("candidatus_portiera_aleyrodidarum - fasta - stub") {

options "-stub"

when {
process {
"""
def genome = file('https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/prokaryotes/candidatus_portiera_aleyrodidarum/genome/genome.fasta', checkIfExists: true)
def genome2 = genome.copyTo('portiera_2.fa')
input[0] = [[ id:'test' ], [genome, genome2]]
input[1] = genome
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(sanitizeOutput(process.out)).match() }
)
}

}

test("candidatus_portiera_aleyrodidarum - fasta - partition") {

when {
params {
Comment thread
emmcauley marked this conversation as resolved.
module_args = '--partition 1'
}
process {
"""
def genome = file('https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/prokaryotes/candidatus_portiera_aleyrodidarum/genome/genome.fasta', checkIfExists: true)
def genome2 = genome.copyTo('portiera_2.fa')
input[0] = [[ id:'test' ], [genome, genome2]]
input[1] = genome
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(sanitizeOutput(process.out)).match() }
)
}

}

test("candidatus_portiera_aleyrodidarum - fasta - partition - stub") {

options "-stub"

when {
params {
module_args = '--partition 1'
}
process {
"""
def genome = file('https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/prokaryotes/candidatus_portiera_aleyrodidarum/genome/genome.fasta', checkIfExists: true)
def genome2 = genome.copyTo('portiera_2.fa')
input[0] = [[ id:'test' ], [genome, genome2]]
input[1] = genome
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(sanitizeOutput(process.out)).match() }
)
}

}

}
Loading
Loading