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

Adding meta to multivcfanalyzer, updating test to nf-test #5773

Merged
merged 11 commits into from
Jun 21, 2024
60 changes: 44 additions & 16 deletions modules/nf-core/multivcfanalyzer/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ process MULTIVCFANALYZER {
'biocontainers/multivcfanalyzer:0.85.2--hdfd78af_1' }"

input:
path vcfs
path fasta
path snpeff_results
path gff
tuple val(meta), path(vcfs)
tuple val(meta2), path(fasta)
tuple val(meta3), path(snpeff_results)
tuple val(meta4), path(gff)
val allele_freqs
val genotype_quality
val coverage
val homozygous_freq
val heterozygous_freq
path gff_exclude
tuple val(meta5), path(gff_exclude)


output:
path('fullAlignment.fasta.gz') , emit: full_alignment
path('info.txt') , emit: info_txt
path('snpAlignment.fasta.gz') , emit: snp_alignment
path('snpAlignmentIncludingRefGenome.fasta.gz') , emit: snp_genome_alignment
path('snpStatistics.tsv') , emit: snpstatistics
path('snpTable.tsv') , emit: snptable
path('snpTableForSnpEff.tsv') , emit: snptable_snpeff
path('snpTableWithUncertaintyCalls.tsv') , emit: snptable_uncertainty
path('structureGenotypes.tsv') , emit: structure_genotypes
path('structureGenotypes_noMissingData-Columns.tsv') , emit: structure_genotypes_nomissing
path('MultiVCFAnalyzer.json') , emit: json
tuple val(meta), path('fullAlignment.fasta.gz') , emit: full_alignment
tuple val(meta), path('info.txt') , emit: info_txt
tuple val(meta), path('snpAlignment.fasta.gz') , emit: snp_alignment
tuple val(meta), path('snpAlignmentIncludingRefGenome.fasta.gz') , emit: snp_genome_alignment
tuple val(meta), path('snpStatistics.tsv') , emit: snpstatistics
tuple val(meta), path('snpTable.tsv') , emit: snptable
tuple val(meta), path('snpTableForSnpEff.tsv') , emit: snptable_snpeff
tuple val(meta), path('snpTableWithUncertaintyCalls.tsv') , emit: snptable_uncertainty
tuple val(meta), path('structureGenotypes.tsv') , emit: structure_genotypes
tuple val(meta), path('structureGenotypes_noMissingData-Columns.tsv') , emit: structure_genotypes_nomissing
tuple val(meta), path('MultiVCFAnalyzer.json') , emit: json
path "versions.yml" , emit: versions

when:
Expand Down Expand Up @@ -69,4 +69,32 @@ process MULTIVCFANALYZER {
multivcfanalyzer: \$(echo \$(multivcfanalyzer --help | head -n 1) | cut -f 3 -d ' ' )
END_VERSIONS
"""
stub:

def args2 = task.ext.args2 ?: ''

def cmd_snpeff_results = snpeff_results ? "${snpeff_results}" : "NA"
def cmd_gff = gff ? "${gff}" : "NA"
def cmd_allele_freqs = allele_freqs ? "T" : "F"
def cmd_gff_exclude = gff_exclude ? "${gff}" : "NA"

"""
echo "" | gzip > fullAlignment.fasta.gz
touch info.txt
echo "" | gzip > snpAlignment.fasta.gz
echo "" | gzip > snpAlignmentIncludingRefGenome.fasta.gz
touch snpStatistics.tsv
touch snpTable.tsv
touch snpTableForSnpEff.tsv
touch snpTableWithUncertaintyCalls.tsv
touch structureGenotypes.tsv
touch structureGenotypes_noMissingData-Columns.tsv
touch MultiVCFAnalyzer.json

cat <<-END_VERSIONS > versions.yml
"${task.process}":
multivcfanalyzer: \$(echo \$(multivcfanalyzer --help | head -n 1) | cut -f 3 -d ' ' )
END_VERSIONS

"""
}
124 changes: 124 additions & 0 deletions modules/nf-core/multivcfanalyzer/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "multivcfanalyzer"

setup {
run("GATK_UNIFIEDGENOTYPER") {
script "../../gatk/unifiedgenotyper/main.nf"
process{
"""
input[0] = Channel.of([ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true)
],
[ [ id:'test2' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam_bai'], checkIfExists: true)
]
)
input[1] = [ [],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
input[2] = [ [],
file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
]
input[3] = [ [],
file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true)
]
input[4] = [[],[]]
input[5] = [[],[]]
input[6] = [[],[]]
input[7] = [[],[]]
"""
}
}
run("GUNZIP") {
script "../../gunzip/main.nf"
process{
"""
input[0] = GATK_UNIFIEDGENOTYPER.out.vcf
"""
}
}
}

test("sarscov2 - vcf") {

when {
process {
"""
input[0] = GUNZIP.out.gunzip.collect{ meta, vcf -> vcf }.map{ vcf -> [[ id: 'testVCF'], vcf]}
input[1] = [ [] ,
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
input[2] = [[],[]]
input[3] = [[],[]]
input[4] = true
input[5] = 30
input[6] = 5
input[7] = 0.8
input[8] = 0.2
input[9] = [[],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.full_alignment,
process.out.snp_alignment,
process.out.snp_genome_alignment,
process.out.snpstatistics,
process.out.snptable,
process.out.snptable_snpeff,
process.out.snptable_uncertainty,
process.out.structure_genotypes,
process.out.structure_genotypes_nomissing,
process.out.json,
process.out.versions,
file(process.out.info_txt[0][1]).readLines().any { it.contains('Run finished:') }).match() }
)
}

}

test("sarscov2 - vcf - stub") {

options "-stub"

when {
process {
"""
input[0] = GUNZIP.out.gunzip.collect{ meta, vcf -> vcf }.map{ vcf -> [[ id: 'testVCF'], vcf]}
input[1] = [ [] ,
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
input[2] = [[],[]]
input[3] = [[],[]]
input[4] = true
input[5] = 30
input[6] = 5
input[7] = 0.8
input[8] = 0.2
input[9] = [[],[]]
"""
}
}

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

}

}
Loading
Loading