Skip to content

Commit

Permalink
update picard/crosscheckfingerprints (nf-core#5077)
Browse files Browse the repository at this point in the history
* update picard/crosscheckfingerprints

* Update modules/nf-core/picard/crosscheckfingerprints/main.nf

Co-authored-by: Maxime U Garcia <[email protected]>

* fix linting

* prettier

* add input indexes

---------

Co-authored-by: Maxime U Garcia <[email protected]>
  • Loading branch information
matthdsm and maxulysse authored Mar 13, 2024
1 parent c6df797 commit 5154596
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 44 deletions.
33 changes: 23 additions & 10 deletions modules/nf-core/picard/crosscheckfingerprints/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ process PICARD_CROSSCHECKFINGERPRINTS {
'biocontainers/picard:3.1.1--hdfd78af_0' }"

input:
tuple val(meta), path(input1)
path input2
path haplotype_map
tuple val(meta), path(input1), path(input1_index), path(input2), path(input2_index), path(haplotype_map)
tuple val(meta2), path(fasta)

output:
tuple val(meta), path("*.crosscheck_metrics.txt"), emit: crosscheck_metrics
Expand All @@ -23,8 +22,9 @@ process PICARD_CROSSCHECKFINGERPRINTS {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

def input1_string = input1.join(" --INPUT ")
def input2_string = input2 ? "--SECOND_INPUT " + input2.join(" --SECOND_INPUT ") : ""
def input1_cmd = input1.collect{"--INPUT $it"}.join(' ')
def input2_cmd = input2.collect{"--SECOND_INPUT $it"}.join(' ')
def reference_cmd = fasta ? "--REFERENCE_SEQUENCE $fasta" : ""

def avail_mem = 3072
if (!task.memory) {
Expand All @@ -36,16 +36,29 @@ process PICARD_CROSSCHECKFINGERPRINTS {
picard \\
-Xmx${avail_mem}M \\
CrosscheckFingerprints \\
$args \\
--NUM_THREADS ${task.cpus} \\
--INPUT $input1_string \\
$input2_string \\
${input1_cmd} \\
${input2_cmd} \\
${reference_cmd} \\
--HAPLOTYPE_MAP ${haplotype_map} \\
--OUTPUT ${prefix}.crosscheck_metrics.txt
--OUTPUT ${prefix}.crosscheck_metrics.txt \\
--NUM_THREADS ${task.cpus} \\
$args
cat <<-END_VERSIONS > versions.yml
"${task.process}":
picard: \$( picard CrosscheckFingerprints --version 2>&1 | grep -o 'Version:.*' | cut -f2- -d: )
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.crosscheck_metrics.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
picard: \$(echo \$(picard CollectHsMetrics --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:)
END_VERSIONS
"""
}
30 changes: 26 additions & 4 deletions modules/nf-core/picard/crosscheckfingerprints/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,50 @@ input:
type: file
description: List containing 1 or more bam/vcf files or a file containing filepaths
pattern: "*.{bam,vcf,vcf.gz,txt,fofn}"
- input1_index:
type: file
description: List containing 1 or more bam/vcf files indexes
pattern: "*.{bai,csi,crai,tbi}"
- input2:
type: file
description: Optional list containing 1 or more bam/vcf files or a file containing filepaths
pattern: "*.{bam,vcf,vcf.gz,txt,fofn}"
- input2_index:
type: file
description: List containing 1 or more bam/vcf files indexes
pattern: "*.{bai,csi,crai,tbi}"
- haplotype_map:
type: file
description: Haplotype map file
pattern: "*.{txt,vcf,vcf.gz}"
- meta2:
type: map
description: |
Groovy Map containing reference information
e.g. [ id:'genome' ]
- fasta:
type: file
description: Reference genome file
pattern: "*.{fasta,fa,fasta.gz,fa.gz}"
- fasta_index:
type: file
description: Reference genome index file
pattern: "*.{fai,fasta.fai,fa.fai,fasta.gz.fai,fa.gz.fai}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- crosscheck_metrics:
type: file
description: Metrics created by crosscheckfingerprints
pattern: "*.{crosscheck_metrics.txt}"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@matthdsm"
maintainers:
Expand Down
82 changes: 82 additions & 0 deletions modules/nf-core/picard/crosscheckfingerprints/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
nextflow_process {

name "Test Process PICARD_CROSSCHECKFINGERPRINTS"
script "../main.nf"
config "./nextflow.config"

process "PICARD_CROSSCHECKFINGERPRINTS"

tag "modules"
tag "modules_nfcore"
tag "picard"
tag "picard/crosscheckfingerprints"

test("homo sapiens - bam - index") {
when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], //meta
[
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true)
], // input1
[
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam_bai'], checkIfExists: true)
], // input1_index
[], // input2
[], // input2_index
file(params.test_data['homo_sapiens']['genome']['haplotype_map'], checkIfExists: true) // haplotype_map
]
input[1] = [[:],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.crosscheck_metrics[0][1]).name).match("Crosscheck - bam") },
{ assert snapshot(process.out.versions).match("Crosscheck versions - bam") }
)
}
}

test("homo sapiens - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], //meta
[
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true)
], // input1
[
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam_bai'], checkIfExists: true)
], // input1_index
[], // input2
[], // input2_index
file(params.test_data['homo_sapiens']['genome']['haplotype_map'], checkIfExists: true) // haplotype_map
]
input[1] = [[:],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.crosscheck_metrics[0][1]).name).match("Crosscheck stub") },
{ assert snapshot(process.out.versions).match("Crosscheck versions stub") }
)
}

}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
process {
withName: PICARD_CROSSCHECKFINGERPRINTS {ext.args = "--EXIT_CODE_WHEN_MISMATCH 0"}
}
2 changes: 2 additions & 0 deletions modules/nf-core/picard/crosscheckfingerprints/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
picard/crosscheckfingerprints:
- "modules/nf-core/picard/crosscheckfingerprints/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1649,9 +1649,6 @@ picard/collectwgsmetrics:
picard/createsequencedictionary:
- modules/nf-core/picard/createsequencedictionary/**
- tests/modules/nf-core/picard/createsequencedictionary/**
picard/crosscheckfingerprints:
- modules/nf-core/picard/crosscheckfingerprints/**
- tests/modules/nf-core/picard/crosscheckfingerprints/**
picard/fastqtosam:
- modules/nf-core/picard/fastqtosam/**
- tests/modules/nf-core/picard/fastqtosam/**
Expand Down
14 changes: 0 additions & 14 deletions tests/modules/nf-core/picard/crosscheckfingerprints/main.nf

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions tests/modules/nf-core/picard/crosscheckfingerprints/test.yml

This file was deleted.

0 comments on commit 5154596

Please sign in to comment.