diff --git a/.github/workflows/bedtools_complement b/.github/workflows/bedtools_complement new file mode 100644 index 00000000..e0b27a3c --- /dev/null +++ b/.github/workflows/bedtools_complement @@ -0,0 +1,40 @@ +name: bedtools_complement +on: + push: + paths: + - software/bedtools/complement/** + - .github/workflows/bedtools_complement.yml + - tests/software/bedtools/** + pull_request: + paths: + - software/bedtools/complement/** + - .github/workflows/bedtools_complement.yml + - tests/software/bedtools/** + +jobs: + ci_test: + runs-on: ubuntu-latest + strategy: + matrix: + nxf_version: [20.11.0-edge] + env: + NXF_ANSI_LOG: false + steps: + - uses: actions/checkout@v2 + + - name: Install Nextflow + env: + NXF_VER: ${{ matrix.nxf_version }} + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: python -m pip install --upgrade pip pytest-workflow + + # Test the module + - run: pytest --tag bedtools_complement --symlink --wt 2 diff --git a/.github/workflows/bedtools_genomecov b/.github/workflows/bedtools_genomecov new file mode 100644 index 00000000..dc80a464 --- /dev/null +++ b/.github/workflows/bedtools_genomecov @@ -0,0 +1,40 @@ +name: bedtools_genomecov +on: + push: + paths: + - software/bedtools/genomecov/** + - .github/workflows/bedtools_genomecov.yml + - tests/software/bedtools/** + pull_request: + paths: + - software/bedtools/genomecov/** + - .github/workflows/bedtools_genomecov.yml + - tests/software/bedtools/** + +jobs: + ci_test: + runs-on: ubuntu-latest + strategy: + matrix: + nxf_version: [20.11.0-edge] + env: + NXF_ANSI_LOG: false + steps: + - uses: actions/checkout@v2 + + - name: Install Nextflow + env: + NXF_VER: ${{ matrix.nxf_version }} + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: python -m pip install --upgrade pip pytest-workflow + + # Test the module + - run: pytest --tag bedtools_genomecov --symlink --wt 2 diff --git a/.github/workflows/bedtools_intersect b/.github/workflows/bedtools_intersect new file mode 100644 index 00000000..3f352dd0 --- /dev/null +++ b/.github/workflows/bedtools_intersect @@ -0,0 +1,40 @@ +name: bedtools_intersect +on: + push: + paths: + - software/bedtools/intersect/** + - .github/workflows/bedtools_intersect.yml + - tests/software/bedtools/** + pull_request: + paths: + - software/bedtools/intersect/** + - .github/workflows/bedtools_intersect.yml + - tests/software/bedtools/** + +jobs: + ci_test: + runs-on: ubuntu-latest + strategy: + matrix: + nxf_version: [20.11.0-edge] + env: + NXF_ANSI_LOG: false + steps: + - uses: actions/checkout@v2 + + - name: Install Nextflow + env: + NXF_VER: ${{ matrix.nxf_version }} + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: python -m pip install --upgrade pip pytest-workflow + + # Test the module + - run: pytest --tag bedtools_intersect --symlink --wt 2 diff --git a/.github/workflows/bedtools_merge b/.github/workflows/bedtools_merge new file mode 100644 index 00000000..6286931a --- /dev/null +++ b/.github/workflows/bedtools_merge @@ -0,0 +1,40 @@ +name: bedtools_merge +on: + push: + paths: + - software/bedtools/merge/** + - .github/workflows/bedtools_merge.yml + - tests/software/bedtools/** + pull_request: + paths: + - software/bedtools/merge/** + - .github/workflows/bedtools_merge.yml + - tests/software/bedtools/** + +jobs: + ci_test: + runs-on: ubuntu-latest + strategy: + matrix: + nxf_version: [20.11.0-edge] + env: + NXF_ANSI_LOG: false + steps: + - uses: actions/checkout@v2 + + - name: Install Nextflow + env: + NXF_VER: ${{ matrix.nxf_version }} + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: python -m pip install --upgrade pip pytest-workflow + + # Test the module + - run: pytest --tag bedtools_merge--symlink --wt 2 diff --git a/.github/workflows/bedtools_slop b/.github/workflows/bedtools_slop new file mode 100644 index 00000000..b3b03813 --- /dev/null +++ b/.github/workflows/bedtools_slop @@ -0,0 +1,40 @@ +name: bedtools_slop +on: + push: + paths: + - software/bedtools/slop/** + - .github/workflows/bedtools_slop.yml + - tests/software/bedtools/** + pull_request: + paths: + - software/bedtools/slop/** + - .github/workflows/bedtools_slop.yml + - tests/software/bedtools/** + +jobs: + ci_test: + runs-on: ubuntu-latest + strategy: + matrix: + nxf_version: [20.11.0-edge] + env: + NXF_ANSI_LOG: false + steps: + - uses: actions/checkout@v2 + + - name: Install Nextflow + env: + NXF_VER: ${{ matrix.nxf_version }} + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: python -m pip install --upgrade pip pytest-workflow + + # Test the module + - run: pytest --tag bedtools_slop--symlink --wt 2 diff --git a/.github/workflows/bedtools_sort b/.github/workflows/bedtools_sort new file mode 100644 index 00000000..e3a194b2 --- /dev/null +++ b/.github/workflows/bedtools_sort @@ -0,0 +1,40 @@ +name: bedtools_sort +on: + push: + paths: + - software/bedtools/sort/** + - .github/workflows/bedtools_sort.yml + - tests/software/bedtools/** + pull_request: + paths: + - software/bedtools/sort/** + - .github/workflows/bedtools_sort.yml + - tests/software/bedtools/** + +jobs: + ci_test: + runs-on: ubuntu-latest + strategy: + matrix: + nxf_version: [20.11.0-edge] + env: + NXF_ANSI_LOG: false + steps: + - uses: actions/checkout@v2 + + - name: Install Nextflow + env: + NXF_VER: ${{ matrix.nxf_version }} + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: python -m pip install --upgrade pip pytest-workflow + + # Test the module + - run: pytest --tag bedtools_sort--symlink --wt 2 diff --git a/software/bedtools/complement/main.nf b/software/bedtools/complement/main.nf index 402557c1..c77df40f 100644 --- a/software/bedtools/complement/main.nf +++ b/software/bedtools/complement/main.nf @@ -10,12 +10,15 @@ process BEDTOOLS_COMPLEMENT { mode: params.publish_dir_mode, saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/bedtools:2.29.2--hc088bd4_0" + } else { container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0" - + } + input: - tuple val(meta), path(beds) - path sizes + tuple val(meta), path(beds), path (sizes) output: tuple val(meta), path("*.complement.bed"), emit: complement diff --git a/software/bedtools/genomecov/functions.nf b/software/bedtools/genomecov/functions.nf index 5a7f09b3..54dc8fe8 100644 --- a/software/bedtools/genomecov/functions.nf +++ b/software/bedtools/genomecov/functions.nf @@ -22,7 +22,6 @@ def initOptions(Map args) { options.publish_dir = args.publish_dir ?: '' options.publish_files = args.publish_files options.suffix = args.suffix ?: '' - options.sizeA - args.sizeA ?: '-sizeA' return options } diff --git a/software/bedtools/genomecov/main.nf b/software/bedtools/genomecov/main.nf index 46f18580..7cb8f6d6 100644 --- a/software/bedtools/genomecov/main.nf +++ b/software/bedtools/genomecov/main.nf @@ -10,12 +10,15 @@ process BEDTOOLS_GENOMECOV { mode: params.publish_dir_mode, saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/bedtools:2.29.2--hc088bd4_0" + } else { container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0" + } input: - tuple val(meta), path(bams) - path sizes + tuple val(meta), path(bams), path (sizes) output: tuple val(meta), path("*.bed"), emit: coverage diff --git a/software/bedtools/intersect/main.nf b/software/bedtools/intersect/main.nf index 6c64c8f5..1edeb505 100644 --- a/software/bedtools/intersect/main.nf +++ b/software/bedtools/intersect/main.nf @@ -9,13 +9,16 @@ process BEDTOOLS_INTERSECT { publishDir "${params.outdir}", mode: params.publish_dir_mode, saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - - conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + + conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/bedtools:2.29.2--hc088bd4_0" + } else { container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0" + } input: - tuple val(meta), path(beds) - + tuple val(meta), path(bedfile1), path(bedfile2) output: tuple val(meta), path("*.intersect.bed"), emit: intersect path "*.version.txt", emit: version @@ -24,7 +27,7 @@ process BEDTOOLS_INTERSECT { def software = getSoftwareName(task.process) def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" """ - bedtools intersect -a ${beds[0]} -b ${beds[1]} ${options.args} > ${prefix}.intersect.bed + bedtools intersect -a ${bedfile1} -b ${bedfile2} ${options.args} > ${prefix}.intersect.bed bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt """ } diff --git a/software/bedtools/merge/main.nf b/software/bedtools/merge/main.nf index c650cb21..ea34f10b 100644 --- a/software/bedtools/merge/main.nf +++ b/software/bedtools/merge/main.nf @@ -4,27 +4,28 @@ include { initOptions; saveFiles; getSoftwareName } from './functions' def options = initOptions(params.options) process BEDTOOLS_MERGE { - tag "$meta.id" label 'process_medium' publishDir "${params.outdir}", mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } + saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:'') } - conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/bedtools:2.29.2--hc088bd4_0" + } else { container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0" - + } input: - tuple val(meta), path(beds) + path(sort) output: - tuple val(meta), path("*.merged.bed"), emit: merge + path("*.merged.bed"), emit: merge path "*.version.txt", emit: version - +// TODO fix output file naming script: def software = getSoftwareName(task.process) - def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" """ - bedtools merge -i $beds ${options.args} > ${prefix}.merged.bed + bedtools merge -i $sort ${options.args} > test.merged.bed bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt """ } diff --git a/software/bedtools/slop/main.nf b/software/bedtools/slop/main.nf index e43c9086..88027244 100644 --- a/software/bedtools/slop/main.nf +++ b/software/bedtools/slop/main.nf @@ -10,13 +10,16 @@ process BEDTOOLS_SLOP { mode: params.publish_dir_mode, saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/bedtools:2.29.2--hc088bd4_0" + } else { container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0" + } input: - tuple val(meta), path(beds) - path sizes + tuple val(meta), path(beds), path (sizes) output: tuple val(meta), path("*.slop.bed"), emit: slopbed diff --git a/software/bedtools/sort/main.nf b/software/bedtools/sort/main.nf index c683bc4b..3c490131 100644 --- a/software/bedtools/sort/main.nf +++ b/software/bedtools/sort/main.nf @@ -10,21 +10,25 @@ process BEDTOOLS_SORT { mode: params.publish_dir_mode, saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } - conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + conda (params.enable_conda ? "bioconda::bedtools =2.29.2" : null) + if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { + container "https://depot.galaxyproject.org/singularity/bedtools:2.29.2--hc088bd4_0" + } else { container "quay.io/biocontainers/bedtools:2.29.2--hc088bd4_0" + } input: tuple val(meta), path(beds) output: - tuple val(meta), path("*.sort.bed"), emit: sort + tuple val(meta), path("*.sort"), emit: sort path "*.version.txt", emit: version script: def software = getSoftwareName(task.process) def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" """ - bedtools sort -i $beds ${options.args} > ${prefix}.sort.bed + bedtools sort -i $beds ${options.args} > ${prefix}.sort bedtools --version | sed -e "s/Bedtools v//g" > ${software}.version.txt """ } diff --git a/tests/software/bedtools/main.nf b/tests/software/bedtools/main.nf new file mode 100644 index 00000000..f36a8b91 --- /dev/null +++ b/tests/software/bedtools/main.nf @@ -0,0 +1,88 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BEDTOOLS_COMPLEMENT } from '../../../software/bedtools/complement/main.nf' addParams( options: [:] ) +include { BEDTOOLS_GENOMECOV } from '../../../software/bedtools/genomecov/main.nf' addParams( options: [:] ) +include { BEDTOOLS_INTERSECT } from '../../../software/bedtools/intersect/main.nf' addParams( options: [:] ) +include { BEDTOOLS_MERGE } from '../../../software/bedtools/merge/main.nf' addParams( options: [:] ) +include { BEDTOOLS_SLOP as BEDTOOLS_SLOP_S} from '../../../software/bedtools/slop/main.nf' addParams( options: [:] ) +include { BEDTOOLS_SLOP as BEDTOOLS_SLOP_AS} from '../../../software/bedtools/slop/main.nf' addParams( options: [:] ) +include { BEDTOOLS_SORT } from '../../../software/bedtools/sort/main.nf' addParams( options: [publish_dir: 'test_bedtools_sort'] ) // needed for merge + + +workflow test_bedtools_complement { + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bed/A.bed", checkIfExists: true), + file("${launchDir}/tests/data/bed/genome.sizes", checkIfExists: true) ] //metamap + + BEDTOOLS_COMPLEMENT( input ) +} + +workflow test_bedtools_genomecov { + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bam/test.paired_end.sorted.bam", checkIfExists: true), + file("${launchDir}/tests/data/bed/genome.sizes", checkIfExists: true) ] //metamap + + BEDTOOLS_GENOMECOV( input ) +} + +workflow test_bedtools_intersect { + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bed/A.bed", checkIfExists: true), + file("${launchDir}/tests/data/bed/B.bed", checkIfExists: true) ] //metamap + + BEDTOOLS_INTERSECT( input ) +} + + +// ensure input file is presorted (uses output of sort module) +workflow test_bedtools_merge { + test_bedtools_sort() + def input = [] + input = [ + test_bedtools_sort.out.sort.collect { it[1] }.ifEmpty([]) + ] + BEDTOOLS_MERGE(*input) +} + +// TODO streamline slop module + +// To run with header and pct enabled, type --pct true and --header true with nextflow run command. +/* +Test with l/r method +*/ +workflow test_bedtools_slop_asymmetrical { + def input = [] + input = [ [ id:'test', symmetry: false], + file("${launchDir}/tests/data/bed/A.bed", checkIfExists: true), + file("${launchDir}/tests/data/bed/genome.sizes", checkIfExists: true) ] //metamap + BEDTOOLS_SLOP_AS( input ) +} +/* +Test with b method +*/ +workflow test_bedtools_slop_symmetrical { + def input = [] + input = [ [ id:'test', symmetry: true], + file("${launchDir}/tests/data/bed/A.bed", checkIfExists: true), + file("${launchDir}/tests/data/bed/genome.sizes", checkIfExists: true) ] //metamap + BEDTOOLS_SLOP_S( input ) +} + +workflow test_bedtools_sort { + def input = [] + input = [ [ id:'test'], + file("${launchDir}/tests/data/bed/A.bed", checkIfExists: true) ] + + BEDTOOLS_SORT( input ) + + emit: + sort = BEDTOOLS_SORT.out.sort + +} + + diff --git a/tests/software/bedtools/test.yml b/tests/software/bedtools/test.yml new file mode 100644 index 00000000..6cc6694c --- /dev/null +++ b/tests/software/bedtools/test.yml @@ -0,0 +1,67 @@ +- name: Run bedtools complement test workflow + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_complement -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_complement + files: + - path: output/bedtools/test.complement.bed + md5sum: 55a43973abb1a08ac57290ff44f6c502 + +- name: Run bedtools genomecov test workflow + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_genomecov -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_genomecov + files: + - path: output/bedtools/test.bed + md5sum: 5be12e847b933b02bf42437e8562d06c + +- name: Run bedtools intersect test workflow + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_intersect -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_intersect + files: + - path: output/bedtools/test.intersect.bed + md5sum: cc1bb317886e7df0a942b56f8a320d9c + + +- name: Run bedtools sort test workflow + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_sort -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_sort + files: + - path: output/bedtools/test.sort.bed + md5sum: 4279202e33fcce3d19f420f1b27fddee + +# linked to sort module +- name: Run bedtools merge test workflow + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_merge -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_merge + files: + - path: output/bedtools/test.merged.bed + md5sum: 13e5a3b254fac35fe0da0c92cbaf1761 + +- name: Run bedtools slop test workflow (symmetrical) + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_slop_symmetrical -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_slop + files: + - path: output/bedtools/test.slop.bed + md5sum: 4279202e33fcce3d19f420f1b27fddee + +- name: Run bedtools slop test workflow (asymmetrical) + command: nextflow run ./tests/software/bedtools/ -profile docker -entry test_bedtools_slop_asymmetrical -c tests/config/nextflow.config + tags: + - bedtools + - bedtools_slop + files: + - path: output/bedtools/test.slop.bed + md5sum: 4279202e33fcce3d19f420f1b27fddee + + +