From 3aaf92fd11a03350f16d18d8644becc654456594 Mon Sep 17 00:00:00 2001 From: Mauro Saporita <64437596+mauro-saporita@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:58:21 +0100 Subject: [PATCH] Picard extractfingerprint (#4506) * first commit - Picard picard_extractfingerprint * add nf-tests * improved bam list declaration Co-authored-by: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com> * change for alphabetical order Co-authored-by: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com> * add tags to main.nf.test * updated snap * new snap * picard version 3.1.0 * changed tests * add test for tbi * change test solving snapshot issue * using new nf-test version * add EOL * adde new EOL * correct typo in tags * version 3.0.0 * revert to version 3.1.1 (latest) * add linesGzip test * remove samtools version from main.nf * fix stub * fix version.yml --------- Co-authored-by: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com> --- .../picard/extractfingerprint/environment.yml | 7 ++ .../nf-core/picard/extractfingerprint/main.nf | 66 +++++++++++++++++++ .../picard/extractfingerprint/meta.yml | 46 +++++++++++++ .../extractfingerprint/tests/main.nf.test | 47 +++++++++++++ .../tests/main.nf.test.snap | 16 +++++ .../picard/extractfingerprint/tests/tags.yml | 2 + 6 files changed, 184 insertions(+) create mode 100644 modules/nf-core/picard/extractfingerprint/environment.yml create mode 100644 modules/nf-core/picard/extractfingerprint/main.nf create mode 100644 modules/nf-core/picard/extractfingerprint/meta.yml create mode 100644 modules/nf-core/picard/extractfingerprint/tests/main.nf.test create mode 100644 modules/nf-core/picard/extractfingerprint/tests/main.nf.test.snap create mode 100644 modules/nf-core/picard/extractfingerprint/tests/tags.yml diff --git a/modules/nf-core/picard/extractfingerprint/environment.yml b/modules/nf-core/picard/extractfingerprint/environment.yml new file mode 100644 index 00000000000..40429b416b3 --- /dev/null +++ b/modules/nf-core/picard/extractfingerprint/environment.yml @@ -0,0 +1,7 @@ +name: picard_extractfingerprint +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::picard=3.1.1 diff --git a/modules/nf-core/picard/extractfingerprint/main.nf b/modules/nf-core/picard/extractfingerprint/main.nf new file mode 100644 index 00000000000..c10c3847ead --- /dev/null +++ b/modules/nf-core/picard/extractfingerprint/main.nf @@ -0,0 +1,66 @@ +process PICARD_EXTRACTFINGERPRINT { + tag "$meta.id" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/picard:3.1.1--hdfd78af_0' : + 'biocontainers/picard:3.1.1--hdfd78af_0' }" + + input: + tuple val(meta), path(bam), path(bai) + path haplotype_map + path fasta + path fasta_fai + path sequence_dictionary + + output: + tuple val(meta), path("*.vcf.gz") , emit: vcf + tuple val(meta), path("*.vcf.gz.tbi"), emit: tbi + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + def reference = fasta ? "--REFERENCE_SEQUENCE ${fasta}" : "" + def bam_name = bam.simpleName + + def avail_mem = 3072 + if (!task.memory) { + log.info '[PICARD ExtractFingerprint] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } else { + avail_mem = (task.memory.mega*0.8).intValue() + } + + """ + picard \\ + -Xmx${avail_mem}M \\ + ExtractFingerprint \\ + --INPUT ${bam} \\ + --HAPLOTYPE_MAP ${haplotype_map} \\ + --OUTPUT ${prefix}.vcf.gz \\ + ${reference} \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + picard: \$(echo \$(picard ExtractFingerprint --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.vcf + touch ${prefix}.vcf.gz.tbi + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + picard: \$(echo \$(picard ExtractFingerprint --version 2>&1) | grep -o 'Version:.*' | cut -f2- -d:) + END_VERSIONS + """ +} diff --git a/modules/nf-core/picard/extractfingerprint/meta.yml b/modules/nf-core/picard/extractfingerprint/meta.yml new file mode 100644 index 00000000000..5c6ccb42ccc --- /dev/null +++ b/modules/nf-core/picard/extractfingerprint/meta.yml @@ -0,0 +1,46 @@ +name: "picard_extractfingerprint" +description: Computes/Extracts the fingerprint genotype likelihoods from the supplied file. It is given as a list of PLs at the fingerprinting sites. +keywords: + - picard + - extract + - fingerprint + - bam +tools: + - picard: + description: | + A set of command line tools (in Java) for manipulating high-throughput sequencing (HTS) + data and formats such as SAM/BAM/CRAM and VCF. + homepage: https://broadinstitute.github.io/picard/ + documentation: https://broadinstitute.github.io/picard/ + tool_dev_url: https://github.com/broadinstitute/picard/ + licence: ["MIT"] +input: + - meta: + type: file + description: | + Input SAM/BAM/CRAM file + - reference: + type: file + description: | + Reference sequence file + - haplotype_map: + type: file + description: | + A file of haplotype information. The file lists a set of SNPs, optionally arranged in high-LD blocks, to be used for fingerprinting. + See https://software.broadinstitute.org/gatk/documentation/article?id=9526 for details. + pattern: "*.{txt,vcf,vcf.gz}" +output: + - fingerprint: + type: file + description: | + Output fingerprint file (VCF) + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@adamrtalbot" + - "@mauro-saporita" +maintainers: + - "@adamrtalbot" + - "@mauro-saporita" diff --git a/modules/nf-core/picard/extractfingerprint/tests/main.nf.test b/modules/nf-core/picard/extractfingerprint/tests/main.nf.test new file mode 100644 index 00000000000..13f8534009b --- /dev/null +++ b/modules/nf-core/picard/extractfingerprint/tests/main.nf.test @@ -0,0 +1,47 @@ +nextflow_process { + + name "Test Process PICARD_EXTRACTFINGERPRINT" + script "../main.nf" + process "PICARD_EXTRACTFINGERPRINT" + tag "modules" + tag "modules_nfcore" + tag "picard" + tag "picard/extractfingerprint" + + test("extract_fingerprint") { + when { + params { + outdir = "$outputDir" + } + process { + """ + bam = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) + ] + fasta = [file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)] + fai = [file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)] + dict = [file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)] + haplotype_map = [file(params.test_data['homo_sapiens']['genome']['haplotype_map'], checkIfExists: true)] + + input[0] = bam + input[1] = haplotype_map + input[2] = fasta + input[3] = fai + input[4] = dict + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert process.out.vcf.get(0).get(1) ==~ ".*.vcf.gz" }, + { assert process.out.tbi.get(0).get(1) ==~ ".*.vcf.gz.tbi" }, + { assert snapshot(process.out.versions).match("versions") }, + { assert snapshot(path(process.out.vcf.get(0).get(1)).linesGzip[0]).match() } + ) + } + } +} diff --git a/modules/nf-core/picard/extractfingerprint/tests/main.nf.test.snap b/modules/nf-core/picard/extractfingerprint/tests/main.nf.test.snap new file mode 100644 index 00000000000..fe61840bcc6 --- /dev/null +++ b/modules/nf-core/picard/extractfingerprint/tests/main.nf.test.snap @@ -0,0 +1,16 @@ +{ + "versions": { + "content": [ + [ + "versions.yml:md5,90dca36c10677c9d6ad5ef7e42c4d788" + ] + ], + "timestamp": "2023-12-04T15:53:39.112154" + }, + "extract_fingerprint": { + "content": [ + "##fileformat=VCFv4.2" + ], + "timestamp": "2023-12-04T15:53:39.12594" + } +} \ No newline at end of file diff --git a/modules/nf-core/picard/extractfingerprint/tests/tags.yml b/modules/nf-core/picard/extractfingerprint/tests/tags.yml new file mode 100644 index 00000000000..5a853126d42 --- /dev/null +++ b/modules/nf-core/picard/extractfingerprint/tests/tags.yml @@ -0,0 +1,2 @@ +picard/extractfingerprint: + - modules/nf-core/picard/extractfingerprint/**