Skip to content

Commit

Permalink
QUILT nf-test and bamlist (nf-core#5515)
Browse files Browse the repository at this point in the history
* Migrate quilt to nf-test and swithc bamlist to auto generation inside the module

* Fix tests

* Fix test

* Fix tests

* Add snap

* Update license

* Add quilt tag

* Specify build hash for conda environment

* Specify build hash for conda environment

* Undo commit

* Update nf-test snapshot

* Fix config name

* Update snapshot

* Update meta.yml

* Add r-base to environment

* Update snapshot generation

* Update meta.yml

* Update snap

* Update snap

* Force sorting

* Update snapshot
  • Loading branch information
LouisLeNezet authored and adamrtalbot committed Apr 30, 2024
1 parent 979fe8b commit cde646a
Show file tree
Hide file tree
Showing 13 changed files with 540 additions and 276 deletions.
3 changes: 2 additions & 1 deletion modules/nf-core/quilt/quilt/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ channels:
- bioconda
- defaults
dependencies:
- bioconda::r-quilt=1.0.5
- bioconda::r-quilt=1.0.5=r43h06b5641_0
- r-base=4.3.1
10 changes: 5 additions & 5 deletions modules/nf-core/quilt/quilt/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process QUILT_QUILT {
'biocontainers/r-quilt:1.0.5--r43h06b5641_0' }"

input:
tuple val(meta), path(bams), path(bais), path(bamlist), path(reference_haplotype_file), path(reference_legend_file), val(chr), val(regions_start), val(regions_end), val(ngen), val(buffer), path(genetic_map_file)
tuple val(meta), path(bams), path(bais), path(reference_haplotype_file), path(reference_legend_file), val(chr), val(regions_start), val(regions_end), val(ngen), val(buffer), path(genetic_map_file)
tuple val(meta2), path(posfile), path(phasefile)
tuple val(meta3), path(fasta)

Expand All @@ -27,18 +27,18 @@ process QUILT_QUILT {
def prefix = task.ext.prefix ?: "${meta.id}"
def extensions = bams.collect { it.extension }
def extension = extensions.flatten().unique()
def list_command = extension == ["bam"] ? "--bamlist=${bamlist}" :
extension == ["cram"] ? "--cramlist=${bamlist} --reference=${fasta}" : ""
def list_command = extension == ["bam"] ? "--bamlist=" :
extension == ["cram"] ? "--reference=${fasta} --cramlist=" : ""
def genetic_map_file_command = genetic_map_file ? "--genetic_map_file=${genetic_map_file}" : ""
def posfile_command = posfile ? "--posfile=${posfile}" : ""
def phasefile_command = phasefile ? "--phasefile=${phasefile}" : ""
if (!(args ==~ /.*--seed.*/)) {args += " --seed=1"}

"""
printf "%s\\n" $bams | tr -d '[],' > all_files.txt
QUILT.R \\
$list_command \\
${list_command}all_files.txt \\
$genetic_map_file_command \\
$posfile_command \\
$phasefile_command \\
Expand Down
11 changes: 5 additions & 6 deletions modules/nf-core/quilt/quilt/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tools:
documentation: "https://github.com/rwdavies/quilt"
tool_dev_url: "https://github.com/rwdavies/quilt"
doi: "10.1038/s41588-021-00877-0"
licence: "['GPL v3']"
licence: ["GPL v3"]
input:
- meta:
type: map
Expand All @@ -28,10 +28,6 @@ input:
type: file
description: (Mandatory) BAM/CRAM index files
pattern: "*.{bai}"
- bamlist:
type: file
description: (Mandatory) "Path to file with bam file locations. File is one row per entry, path to bam files. Bam index files should exist in same directory as for each bam, suffixed either .bam.bai or .bai.
pattern: "*.{txt}"
- reference_haplotype_file:
type: file
description: (Mandatory) Reference haplotype file in IMPUTE format (file with no header and no rownames, one row per SNP, one column per reference haplotype, space separated, values must be 0 or 1)
Expand Down Expand Up @@ -99,9 +95,12 @@ output:
type: file
description: TBI file of the VCF.
pattern: "*.{vcf.gz.tbi}"
- RData:
- rdata:
type: directory
description: Optional directory path to prepared RData file with reference objects (useful with --save_prepared_reference=TRUE).
- plots:
type: directory
description: Optional directory path to save plots.
authors:
- "@atrigila"
maintainers:
Expand Down
132 changes: 132 additions & 0 deletions modules/nf-core/quilt/quilt/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Input data
def path = "file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/quilt/"
def bam = "[${path}NA12878.haplotagged.1.0.bam', checkIfExists: true), ${path}NA12878.ont.1.0.bam', checkIfExists: true), ${path}NA12878.illumina.1.0.bam', checkIfExists: true)]"
def bai = "[${path}NA12878.haplotagged.1.0.bam.bai', checkIfExists: true), ${path}NA12878.ont.1.0.bam.bai', checkIfExists: true),${path}NA12878.illumina.1.0.bam.bai', checkIfExists: true)]"

// Input reference data
def reference_haplotype_file = "file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/quilt/ALL.chr20_GRCh38.genotypes.20170504.chr20.2000001.2100000.noNA12878.hap.gz', checkIfExists: true)"
def reference_legend_file = "file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/quilt/ALL.chr20_GRCh38.genotypes.20170504.chr20.2000001.2100000.noNA12878.legend.gz', checkIfExists: true)"
def genetic_map_file = "file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/quilt/CEU-chr20-final.b38.txt.gz', checkIfExists: true)"

// Parameters
def chr = "'chr20'"
def regions_start = "2000001"
def regions_end = "2100000"
def ngen = "100"
def buffer = "10000"


// (optional) input truth data
def posfile = "file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/quilt/ALL.chr20_GRCh38.genotypes.20170504.chr20.2000001.2100000.posfile.txt', checkIfExists: true)"
def phasefile = "file('https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/quilt/ALL.chr20_GRCh38.genotypes.20170504.chr20.2000001.2100000.phasefile.txt', checkIfExists: true)"
def posfile_phasefile = "[[ id:'test', chr:'chr20' ], [$posfile], [$phasefile]]"
def fasta = "[[id:'test'], []]"

// Input channel quilt
def ch_input = "[ id:'test', chr:'chr20' ], $bam, $bai, [$reference_haplotype_file], [$reference_legend_file], $chr, $regions_start, $regions_end, $ngen, $buffer"
def ch_input_gmap = "[$ch_input, [$genetic_map_file]]"
def ch_input_nogmap = "[$ch_input, []]"

nextflow_process {

name "Test Process QUILT"
script "../main.nf"
process "QUILT_QUILT"

tag "modules"
tag "modules_nfcore"
tag "quilt/quilt"
tag "quilt"

test("QUILT") {
config ("./quilt_default.config")
when {
process {
"""
input[0] = $ch_input_gmap
input[1] = $posfile_phasefile
input[2] = $fasta
"""
}
}

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

}

test("QUILT no optional files") {
config ("./quilt_default.config")
when {
process {
"""
input[0] = $ch_input_nogmap
input[1] = [[id: null], [], []]
input[2] = $fasta
"""
}
}

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

}

test("QUILT optional output") {
config ("./quilt_optional.config")
when {
process {
"""
input[0] = $ch_input_gmap
input[1] = $posfile_phasefile
input[2] = $fasta
"""
}
}

then {
def dir = new File(process.out.plots[0][1])
def list = []
dir.eachFileRecurse { file -> list << file.getName() }
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf + process.out.tbi +
list.sort() +
process.out.rdata + process.out.versions
).match() }
)
}

}

test("QUILT no seed") {
config ("./quilt_noseed.config")
when {
process {
"""
input[0] = $ch_input_gmap
input[1] = $posfile_phasefile
input[2] = $fasta
"""
}
}

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

}

}
Loading

0 comments on commit cde646a

Please sign in to comment.