diff --git a/modules/endorspy/main.nf b/modules/endorspy/main.nf new file mode 100644 index 00000000..73bdd293 --- /dev/null +++ b/modules/endorspy/main.nf @@ -0,0 +1,38 @@ +process ENDORSPY { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::endorspy=0.4" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/endorspy:0.4--hdfd78af_0': + 'quay.io/biocontainers/endorspy:0.4--hdfd78af_0' }" + + input: + tuple val(meta), path(stats), path(stats_optional) + + output: + tuple val(meta), path("*_mqc.json"), emit: json + 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 optionalstats = stats_optional ? "statsOptional=${stats_optional}" : '' + + """ + endorspy \\ + $stats \\ + $optionalstats \\ + $args \\ + -o json \\ + -n $prefix + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + endorspy: \$(echo \$(endorspy --version 2>&1) | sed 's/^endorS.py //' ) + END_VERSIONS + """ +} diff --git a/modules/endorspy/meta.yml b/modules/endorspy/meta.yml new file mode 100644 index 00000000..43ae0f94 --- /dev/null +++ b/modules/endorspy/meta.yml @@ -0,0 +1,48 @@ +name: "endorspy" +description: endorS.py calculates endogenous DNA from samtools flagstat files and print to screen +keywords: + - endogenous DNA + - ancient DNA + - percent on target + - statistics +tools: + - "endorspy": + description: "endorS.py calculates endogenous DNA from samtools flagstat files and print to screen" + homepage: "https://github.com/aidaanva/endorS.py" + documentation: "https://github.com/aidaanva/endorS.py" + tool_dev_url: "https://github.com/aidaanva/endorS.py" + doi: "10.7717/peerj.10947" + licence: "['GPL v3']" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - stats: + type: file + description: output of samtools flagstat in a text file + - stats_optional: + type: file + description: output of a second samtools flagstat run in a text file. If two files are supplied, + the mapped reads of the second file is divided by the total reads in the first, since it + assumes that the are related to the same sample. Useful after BAM filtering. + +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: file with the endogenous DNA calculation tailored for multiQC + pattern: "*_mqc.json" + +authors: + - "@aidaanva" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index ec981331..454a06f7 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -727,6 +727,10 @@ emmtyper: - modules/emmtyper/** - tests/modules/emmtyper/** +endorspy: + - modules/endorspy/** + - tests/modules/endorspy/** + ensemblvep: - modules/ensemblvep/** - tests/modules/ensemblvep/** diff --git a/tests/modules/endorspy/main.nf b/tests/modules/endorspy/main.nf new file mode 100644 index 00000000..2f04c13a --- /dev/null +++ b/tests/modules/endorspy/main.nf @@ -0,0 +1,36 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ENDORSPY } from '../../../modules/endorspy/main.nf' +include { SAMTOOLS_FLAGSTAT } from '../../../modules/samtools/flagstat/main.nf' +include { SAMTOOLS_FLAGSTAT as SAMTOOLS_FLAGSTAT2 } from '../../../modules/samtools/flagstat/main.nf' +include { SAMTOOLS_VIEW } from '../../../modules/samtools/view/main.nf' +include { SAMTOOLS_INDEX } from '../../../modules/samtools/index/main.nf' + +workflow test_endorspy { + + input = [ + [ id:'test', single_end:false ], // 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) + ] + + + SAMTOOLS_FLAGSTAT ( input ) + SAMTOOLS_VIEW ( input, [] ) + SAMTOOLS_INDEX ( SAMTOOLS_VIEW.out.bam ) + input2 = SAMTOOLS_VIEW.out.bam + .mix(SAMTOOLS_INDEX.out.bai) + .groupTuple(by:0) + .map{ + def meta = it[0] + def bam = it[1][0] + def bai = it[1][1] + + [meta, bam, bai] + } + SAMTOOLS_FLAGSTAT2 ( input2 ) + ch_input_flagstat = SAMTOOLS_FLAGSTAT.out.flagstat.join(SAMTOOLS_FLAGSTAT2.out.flagstat) + ENDORSPY ( ch_input_flagstat ) +} diff --git a/tests/modules/endorspy/nextflow.config b/tests/modules/endorspy/nextflow.config new file mode 100644 index 00000000..0a243cef --- /dev/null +++ b/tests/modules/endorspy/nextflow.config @@ -0,0 +1,12 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName:SAMTOOLS_VIEW { + ext.args = "-q 30 -b" + } + + withName:SAMTOOLS_FLAGSTAT2 { + ext.prefix = "test.filtered" + } +} diff --git a/tests/modules/endorspy/test.yml b/tests/modules/endorspy/test.yml new file mode 100644 index 00000000..1369227f --- /dev/null +++ b/tests/modules/endorspy/test.yml @@ -0,0 +1,7 @@ +- name: endorspy test_endorspy + command: nextflow run ./tests/modules/endorspy -entry test_endorspy -c ./tests/config/nextflow.config -c ./tests/modules/endorspy/nextflow.config + tags: + - endorspy + files: + - path: output/endorspy/test_endogenous_dna_mqc.json + md5sum: fe7bea111d966db321dcde7fbfb062b1