Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct president stub #5904

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 19 additions & 15 deletions modules/nf-core/president/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,38 @@ process PRESIDENT {

input:
tuple val(meta), path(fasta)
path reference
tuple val(meta2), path(reference)
val compress

output:
tuple val(meta), path("output/*.fasta*"), emit: fasta
tuple val(meta), path("output/*.tsv") , emit: report
tuple val(meta), path("output/*.log") , emit: log
path "versions.yml" , emit: versions
tuple val(meta), path("${prefix}valid.fasta*") , emit: valid_fasta
tuple val(meta), path("${prefix}invalid.fasta*"), emit: invalid_fasta
tuple val(meta), path("*.tsv") , emit: report
tuple val(meta), path("*.log") , emit: log
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: ''
if (prefix != ''){
prefix = "--prefix " + prefix
}

prefix = task.ext.prefix ?: "${meta.id}_"
if ("${fasta}" == "${reference}") error "Input and reference names are the same!"
if ("${fasta}" == "${prefix}valid.fasta") error "Input and output file names are the same, use \"task.ext.prefix\" to disambiguate!"
if ("${fasta}" == "${prefix}invalid.fasta") error "Input and output file names are the same, use \"task.ext.prefix\" to disambiguate!"
if ("${fasta}" == "${prefix}valid.fasta.gz" && compress) error "Input and output file names are the same, use \"task.ext.prefix\" to disambiguate!"
if ("${fasta}" == "${prefix}invalid.fasta.gz" && compress) error "Input and output file names are the same, use \"task.ext.prefix\" to disambiguate!"
"""
mkdir output
president \\
--query $fasta \\
--reference $reference \\
--path output \\
--path . \\
--threads $task.cpus \\
$prefix \\
--prefix $prefix \\
$args

if [ "$compress" = true ] ; then
gzip output/*.fasta;
gzip ${prefix}*.fasta;
fi

cat <<-END_VERSIONS > versions.yml
Expand All @@ -50,12 +51,15 @@ process PRESIDENT {

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: ''
prefix = task.ext.prefix ?: "${meta.id}_"
compress_command = compress ? "gzip ${prefix}*.fasta" : ""

"""
touch ${prefix}report.tsv
touch ${prefix}president_logger.log
touch ${prefix}valid.fasta
touch ${prefix}invalid.fasta
$compress_command

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
3 changes: 3 additions & 0 deletions modules/nf-core/president/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ input:
type: file
description: One fasta file or a list of multiple fasta files to perform president on. Has to be uncompressed!
pattern: "*.{fasta,fas,fa,fna,ffn,faa,mpfa,frn}"
- meta2:
type: map
description: Groovy Map containing information about the reference genome
- reference:
type: file
description: Fasta of a reference genome. Has to be uncompressed!
Expand Down
99 changes: 69 additions & 30 deletions modules/nf-core/president/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ nextflow_process {

when {
process {
"""
input[0] = [[],file(params.test_data['sarscov2']['genome']['all_sites_fas'], checkIfExists: true)]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
"""
input[0] = [
[id: "test" ],
file(params.test_data['sarscov2']['genome']['all_sites_fas'], checkIfExists: true)
]
input[1] = [[id: "genome" ], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)]
input[2] = []
"""

Expand All @@ -32,22 +35,16 @@ nextflow_process {

assertAll(
{assert process.success},
{assert snapshot(process.out.versions,
process.out.valid_fasta,
process.out.invalid_fasta).match()},
{assert process.out.log != null},
{assert process.out.log.size() == 1},
{assert process.out.log.get(0).get(1) ==~ ".*/president_logger.log"},
{assert process.out.log.get(0).get(1) ==~ ".*president_logger.log"},
{assert process.out.report != null},
{assert process.out.report.size() == 1},
{assert process.out.report.get(0).get(1) ==~ ".*/report.tsv"},
{assert process.out.report.get(0).get(1) ==~ ".*report.tsv"},
{assert firstReportEntry == firstReportAssert},
{assert process.out.fasta != null},
{assert process.out.fasta.size() == 1},
{assert process.out.fasta.get(0).get(1).size() == 2},
{assert process.out.fasta.get(0).get(1).get(0) ==~ ".*/invalid.fasta"},
{assert path(process.out.fasta.get(0).get(1).get(0)).readLines().size() == 2},
{assert path(process.out.fasta.get(0).get(1).get(0)).md5 == "5e16f45d529bac4c6d757a84802ac772"},
{assert process.out.fasta.get(0).get(1).get(1) ==~ ".*/valid.fasta"},
{assert path(process.out.fasta.get(0).get(1).get(1)).readLines().size() == 6},
{assert path(process.out.fasta.get(0).get(1).get(1)).md5 == "16031b5d95fff7ff01b60615728df4ab"}
)
}
}
Expand All @@ -56,9 +53,12 @@ nextflow_process {

when {
process {
"""
input[0] = [[],file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/alignment/all_sites.fas', checkIfExists: true)]
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
"""
input[0] = [
[id: "test" ],
file(params.test_data['sarscov2']['genome']['all_sites_fas'], checkIfExists: true)
]
input[1] = [[id: "genome" ], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)]
input[2] = "true"
"""
}
Expand All @@ -73,28 +73,67 @@ nextflow_process {
firstReportAssert.add(sdf.format(date))
assertAll(
{assert process.success},

{assert snapshot(process.out.versions,
process.out.valid_fasta,
process.out.invalid_fasta).match()},
{assert process.out.log != null},
{assert process.out.log.size() == 1},
{assert process.out.log.get(0).get(1) ==~ ".*/president_logger.log"},
{assert process.out.log.get(0).get(1) ==~ ".*president_logger.log"},

{assert process.out.report != null},
{assert process.out.report.size() == 1},
{assert process.out.report.get(0).get(1) ==~ ".*/report.tsv"},

{assert process.out.report.get(0).get(1) ==~ ".*report.tsv"},
{assert firstReportEntry == firstReportAssert},
)
}
}

{assert process.out.fasta != null},
{assert process.out.fasta.size() == 1},
{assert process.out.fasta.get(0).get(1).size() == 2},
{assert process.out.fasta.get(0).get(1).get(0) ==~ ".*/invalid.fasta.gz"},
{assert path(process.out.fasta.get(0).get(1).get(0)).linesGzip.size() == 2},
{assert path(process.out.fasta.get(0).get(1).get(0)).md5 == "5e16f45d529bac4c6d757a84802ac772"},
test("president - nocompress - stub") {
options "-stub"
when {
process {
"""
input[0] = [
[id: "test" ],
file(params.test_data['sarscov2']['genome']['all_sites_fas'], checkIfExists: true)
]
input[1] = [[id: "genome" ], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)]
input[2] = false
"""

}
}

{assert process.out.fasta.get(0).get(1).get(1) ==~ ".*/valid.fasta.gz"},
{assert path(process.out.fasta.get(0).get(1).get(1)).linesGzip.size() == 6},
{assert path(process.out.fasta.get(0).get(1).get(1)).md5 == "16031b5d95fff7ff01b60615728df4ab"}
then {
assertAll(
{assert process.success},
{assert snapshot(process.out).match()}
)
}
}

test("president - compress - stub") {
options "-stub"
when {
process {
"""
input[0] = [
[id: "test" ],
file(params.test_data['sarscov2']['genome']['all_sites_fas'], checkIfExists: true)
]
input[1] = [[id: "genome" ], file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)]
input[2] = true
"""

}
}

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

}
Loading
Loading