From bad832c2ea8af993e6f43bfa76c6c7307485f195 Mon Sep 17 00:00:00 2001 From: Thiseas Christos Lamnidis Date: Fri, 29 Apr 2022 14:28:45 +0200 Subject: [PATCH 1/6] Add Sexdeterrmine module --- modules/sexdeterrmine/main.nf | 38 ++++++++++++++++ modules/sexdeterrmine/meta.yml | 48 +++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/sexdeterrmine/main.nf | 16 +++++++ tests/modules/sexdeterrmine/nextflow.config | 8 ++++ tests/modules/sexdeterrmine/test.yml | 12 ++++++ 6 files changed, 126 insertions(+) create mode 100644 modules/sexdeterrmine/main.nf create mode 100644 modules/sexdeterrmine/meta.yml create mode 100644 tests/modules/sexdeterrmine/main.nf create mode 100644 tests/modules/sexdeterrmine/nextflow.config create mode 100644 tests/modules/sexdeterrmine/test.yml diff --git a/modules/sexdeterrmine/main.nf b/modules/sexdeterrmine/main.nf new file mode 100644 index 00000000..f8754764 --- /dev/null +++ b/modules/sexdeterrmine/main.nf @@ -0,0 +1,38 @@ +process SEXDETERRMINE { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::sexdeterrmine=1.1.2" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/sexdeterrmine:1.1.2--hdfd78af_1': + 'quay.io/biocontainers/sexdeterrmine:1.1.2--hdfd78af_1' }" + + input: + tuple val(meta), path(depth) + path(sample_list_file) + + output: + tuple val(meta), path("*.json"), emit: json + tuple val(meta), path("*.tsv") , emit: tsv + 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 sample_list = sample_list_file ? '-f ${sample_list_file}' : '' + """ + sexdeterrmine \\ + -I $depth \\ + $sample_list \\ + $args \\ + > ${prefix}.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sexdeterrmine: \$(echo \$(sexdeterrmine --version 2>&1)) + END_VERSIONS + """ +} diff --git a/modules/sexdeterrmine/meta.yml b/modules/sexdeterrmine/meta.yml new file mode 100644 index 00000000..6e24c817 --- /dev/null +++ b/modules/sexdeterrmine/meta.yml @@ -0,0 +1,48 @@ +name: "sexdeterrmine" +description: Calculate the relative coverage on the Gonosomes vs Autosomes from the output of samtools depth, with error bars. +keywords: + - "sex determination" + - "genetic sex" + - "relative coverage" +tools: + - "sexdeterrmine": + description: "A python script carry out calculate the relative coverage of X and Y chromosomes, and their associated error bars, out of capture data." + homepage: "https://github.com/TCLamnidis/Sex.DetERRmine" + documentation: "https://github.com/TCLamnidis/Sex.DetERRmine/README.md" + tool_dev_url: "https://github.com/TCLamnidis/Sex.DetERRmine" + doi: "https://doi.org/10.1038/s41467-018-07483-5" + licence: "['GPL v3']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + # + - depth: + type: file + description: output from samtools depth (with header) + pattern: "*" + +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" + - json: + type: file + description: JSON formatted table of relative coverages on the X and Y, with associated error bars. + pattern: "*.json" + - tsv: + type: file + description: TSV table of relative coverages on the X and Y, with associated error bars. + pattern: "*.tsv" + +authors: + - "@TCLamnidis" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index a1a969e7..60c2d46d 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1703,6 +1703,10 @@ seqwish/induce: - modules/seqwish/induce/** - tests/modules/seqwish/induce/** +sexdeterrmine: + - modules/sexdeterrmine/** + - tests/modules/sexdeterrmine/** + shovill: - modules/shovill/** - tests/modules/shovill/** diff --git a/tests/modules/sexdeterrmine/main.nf b/tests/modules/sexdeterrmine/main.nf new file mode 100644 index 00000000..c9d869f5 --- /dev/null +++ b/tests/modules/sexdeterrmine/main.nf @@ -0,0 +1,16 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SAMTOOLS_DEPTH } from '../../../modules/samtools/depth/main.nf' +include { SEXDETERRMINE } from '../../../modules/sexdeterrmine/main.nf' + +workflow test_sexdeterrmine { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam'], checkIfExists: true) ] + + SAMTOOLS_DEPTH ( input ) + SEXDETERRMINE ( SAMTOOLS_DEPTH.out.tsv, [] ) +} diff --git a/tests/modules/sexdeterrmine/nextflow.config b/tests/modules/sexdeterrmine/nextflow.config new file mode 100644 index 00000000..763d7ad6 --- /dev/null +++ b/tests/modules/sexdeterrmine/nextflow.config @@ -0,0 +1,8 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName:SAMTOOLS_DEPTH { + ext.args = "-aa -H" + } +} diff --git a/tests/modules/sexdeterrmine/test.yml b/tests/modules/sexdeterrmine/test.yml new file mode 100644 index 00000000..5eca8a30 --- /dev/null +++ b/tests/modules/sexdeterrmine/test.yml @@ -0,0 +1,12 @@ +## TODO nf-core: Please run the following command to build this file: +# nf-core modules create-test-yml sexdeterrmine +- name: "sexdeterrmine" + command: nextflow run ./tests/modules/sexdeterrmine -entry test_sexdeterrmine -c ./tests/config/nextflow.config -c ./tests/modules/sexdeterrmine/nextflow.config + tags: + - "sexdeterrmine" + # + files: + - path: "output/sexdeterrmine/test.bam" + md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: output/sexdeterrmine/versions.yml + md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b From 4317ad85aede53086cdb1ac2410a46e85e00bed4 Mon Sep 17 00:00:00 2001 From: Thiseas Christos Lamnidis Date: Fri, 29 Apr 2022 15:07:32 +0200 Subject: [PATCH 2/6] Passing test --- modules/sexdeterrmine/main.nf | 2 ++ tests/modules/sexdeterrmine/main.nf | 2 +- tests/modules/sexdeterrmine/nextflow.config | 6 +++++- tests/modules/sexdeterrmine/test.yml | 21 ++++++++++++--------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/sexdeterrmine/main.nf b/modules/sexdeterrmine/main.nf index f8754764..dd8b5a70 100644 --- a/modules/sexdeterrmine/main.nf +++ b/modules/sexdeterrmine/main.nf @@ -23,6 +23,8 @@ process SEXDETERRMINE { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def sample_list = sample_list_file ? '-f ${sample_list_file}' : '' + if ("$depth" == "${prefix}.tsv") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + """ sexdeterrmine \\ -I $depth \\ diff --git a/tests/modules/sexdeterrmine/main.nf b/tests/modules/sexdeterrmine/main.nf index c9d869f5..2c90d280 100644 --- a/tests/modules/sexdeterrmine/main.nf +++ b/tests/modules/sexdeterrmine/main.nf @@ -9,7 +9,7 @@ workflow test_sexdeterrmine { input = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam'], checkIfExists: true) ] + file("https://github.com/nf-core/test-datasets/raw/eager/testdata/Human/bam/JK2067_downsampled_s0.1.bam", checkIfExists: true) ] SAMTOOLS_DEPTH ( input ) SEXDETERRMINE ( SAMTOOLS_DEPTH.out.tsv, [] ) diff --git a/tests/modules/sexdeterrmine/nextflow.config b/tests/modules/sexdeterrmine/nextflow.config index 763d7ad6..4ba3dfe3 100644 --- a/tests/modules/sexdeterrmine/nextflow.config +++ b/tests/modules/sexdeterrmine/nextflow.config @@ -3,6 +3,10 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } withName:SAMTOOLS_DEPTH { - ext.args = "-aa -H" + ext.args = "-H" + } + + withName:SEXDETERRMINE { + ext.prefix = { "${meta.id}_sexdet" } } } diff --git a/tests/modules/sexdeterrmine/test.yml b/tests/modules/sexdeterrmine/test.yml index 5eca8a30..54c471ba 100644 --- a/tests/modules/sexdeterrmine/test.yml +++ b/tests/modules/sexdeterrmine/test.yml @@ -1,12 +1,15 @@ -## TODO nf-core: Please run the following command to build this file: -# nf-core modules create-test-yml sexdeterrmine -- name: "sexdeterrmine" - command: nextflow run ./tests/modules/sexdeterrmine -entry test_sexdeterrmine -c ./tests/config/nextflow.config -c ./tests/modules/sexdeterrmine/nextflow.config +- name: sexdeterrmine test_sexdeterrmine + command: nextflow run tests/modules/sexdeterrmine -entry test_sexdeterrmine -c tests/config/nextflow.config tags: - - "sexdeterrmine" - # + - sexdeterrmine files: - - path: "output/sexdeterrmine/test.bam" - md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: output/samtools/test.tsv + md5sum: c894abd0c78ea7760e0b54bbafb93722 + - path: output/samtools/versions.yml + md5sum: dbd04b700335c8ad236bd667254c8dd8 + - path: output/sexdeterrmine/sexdeterrmine.json + md5sum: 16d9e7891d4c92bc1d66db2e70e9d86f + - path: output/sexdeterrmine/test_sexdet.tsv + md5sum: 7ffc35e478de66939819a9ca4a5df2d7 - path: output/sexdeterrmine/versions.yml - md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b + md5sum: 077361101e8e7997aec3da8a01e59eee From 070dee0f5bef37951493cf02dfec4c22472010d4 Mon Sep 17 00:00:00 2001 From: Thiseas Christos Lamnidis Date: Mon, 23 May 2022 15:22:22 +0200 Subject: [PATCH 3/6] Use newly added test bam --- tests/modules/sexdeterrmine/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/sexdeterrmine/main.nf b/tests/modules/sexdeterrmine/main.nf index 2c90d280..056c63d5 100644 --- a/tests/modules/sexdeterrmine/main.nf +++ b/tests/modules/sexdeterrmine/main.nf @@ -9,7 +9,7 @@ workflow test_sexdeterrmine { input = [ [ id:'test', single_end:false ], // meta map - file("https://github.com/nf-core/test-datasets/raw/eager/testdata/Human/bam/JK2067_downsampled_s0.1.bam", checkIfExists: true) ] + file(params.test_data['homo_sapiens']['illumina']['test3.single_end.markduplicates.sorted.bam'], checkIfExists: true) ] SAMTOOLS_DEPTH ( input ) SEXDETERRMINE ( SAMTOOLS_DEPTH.out.tsv, [] ) From 9011fc7212ba3889792b5026e883e2f60c714028 Mon Sep 17 00:00:00 2001 From: Thiseas Christos Lamnidis Date: Mon, 23 May 2022 17:08:40 +0200 Subject: [PATCH 4/6] Corrected test-datasets input --- tests/modules/sexdeterrmine/main.nf | 2 +- tests/modules/sexdeterrmine/test.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/modules/sexdeterrmine/main.nf b/tests/modules/sexdeterrmine/main.nf index 056c63d5..fc777905 100644 --- a/tests/modules/sexdeterrmine/main.nf +++ b/tests/modules/sexdeterrmine/main.nf @@ -9,7 +9,7 @@ workflow test_sexdeterrmine { input = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['homo_sapiens']['illumina']['test3.single_end.markduplicates.sorted.bam'], checkIfExists: true) ] + file(params.test_data['homo_sapiens']['illumina']['test3_single_end_markduplicates_sorted_bam'], checkIfExists: true) ] SAMTOOLS_DEPTH ( input ) SEXDETERRMINE ( SAMTOOLS_DEPTH.out.tsv, [] ) diff --git a/tests/modules/sexdeterrmine/test.yml b/tests/modules/sexdeterrmine/test.yml index 54c471ba..bb3f701e 100644 --- a/tests/modules/sexdeterrmine/test.yml +++ b/tests/modules/sexdeterrmine/test.yml @@ -4,12 +4,12 @@ - sexdeterrmine files: - path: output/samtools/test.tsv - md5sum: c894abd0c78ea7760e0b54bbafb93722 + md5sum: fa2992ca1ea93a6e1b3e838476191935 - path: output/samtools/versions.yml md5sum: dbd04b700335c8ad236bd667254c8dd8 - path: output/sexdeterrmine/sexdeterrmine.json - md5sum: 16d9e7891d4c92bc1d66db2e70e9d86f + md5sum: bafb2419bb8630eda29a251c20e97166 - path: output/sexdeterrmine/test_sexdet.tsv - md5sum: 7ffc35e478de66939819a9ca4a5df2d7 + md5sum: 1cf8a2b97b38353eb97a96ab872dcca9 - path: output/sexdeterrmine/versions.yml md5sum: 077361101e8e7997aec3da8a01e59eee From 96260ced83ba3ad25ad03f85e085c459c54a1373 Mon Sep 17 00:00:00 2001 From: Thiseas Christos Lamnidis Date: Mon, 23 May 2022 17:15:57 +0200 Subject: [PATCH 5/6] Add test data to config --- tests/config/test_data.config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/config/test_data.config b/tests/config/test_data.config index 559c0d6f..61bd1e40 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -219,10 +219,11 @@ params { test2_paired_end_umi_unsorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/umi/test2.paired_end.umi_unsorted.bam" test2_paired_end_umi_unsorted_tagged_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/umi/test2.paired_end.unsorted_tagged.bam" - mitochon_standin_recalibrated_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/mitochon_standin.recalibrated.sorted.bam" mitochon_standin_recalibrated_sorted_bam_bai = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/mitochon_standin.recalibrated.sorted.bam.bai" + test3_single_end_markduplicates_sorted_bam = "${test_data_dir}/genomics/homo_sapiens/illumina/bam/test3.single_end.markduplicates.sorted.bam" + test_paired_end_sorted_cram = "${test_data_dir}/genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram" test_paired_end_sorted_cram_crai = "${test_data_dir}/genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram.crai" test_paired_end_markduplicates_sorted_cram = "${test_data_dir}/genomics/homo_sapiens/illumina/cram/test.paired_end.markduplicates.sorted.cram" From fe855a1c234b26540f0ef9eb10376619ae781ab3 Mon Sep 17 00:00:00 2001 From: "Thiseas C. Lamnidis" Date: Fri, 10 Jun 2022 11:03:01 +0200 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: James A. Fellows Yates --- modules/sexdeterrmine/main.nf | 4 ++-- modules/sexdeterrmine/meta.yml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/sexdeterrmine/main.nf b/modules/sexdeterrmine/main.nf index dd8b5a70..98c72307 100644 --- a/modules/sexdeterrmine/main.nf +++ b/modules/sexdeterrmine/main.nf @@ -9,7 +9,7 @@ process SEXDETERRMINE { input: tuple val(meta), path(depth) - path(sample_list_file) + path sample_list_file output: tuple val(meta), path("*.json"), emit: json @@ -23,7 +23,7 @@ process SEXDETERRMINE { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def sample_list = sample_list_file ? '-f ${sample_list_file}' : '' - if ("$depth" == "${prefix}.tsv") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + if ("$depth" == "${prefix}.tsv") error "Input depth and output TSV names are the same, set prefix in module configuration to disambiguate!" """ sexdeterrmine \\ diff --git a/modules/sexdeterrmine/meta.yml b/modules/sexdeterrmine/meta.yml index 6e24c817..3f56b0ab 100644 --- a/modules/sexdeterrmine/meta.yml +++ b/modules/sexdeterrmine/meta.yml @@ -1,9 +1,10 @@ name: "sexdeterrmine" description: Calculate the relative coverage on the Gonosomes vs Autosomes from the output of samtools depth, with error bars. keywords: - - "sex determination" - - "genetic sex" - - "relative coverage" + - sex determination + - genetic sex + - relative coverage + - ancient dna tools: - "sexdeterrmine": description: "A python script carry out calculate the relative coverage of X and Y chromosomes, and their associated error bars, out of capture data." @@ -19,10 +20,9 @@ input: description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - # - depth: type: file - description: output from samtools depth (with header) + description: Output from samtools depth (with header) pattern: "*" output: