From 34d86427a6e5f30392a6887ec62616a7126f3f9a Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Tue, 24 Nov 2020 19:55:52 -0600 Subject: [PATCH] test(samtools): Refactor flagstat to use pytest-workflow --- .../workflows/software/samtools_flagstat.yml | 22 ++++++++++++------- .../test/input/test.paired_end.sorted.bam | 1 - .../test/input/test.paired_end.sorted.bam.bai | 1 - software/samtools/flagstat/test/main.nf | 19 ---------------- .../samtools/flagstat/test/nextflow.config | 20 ----------------- .../test.paired_end.sorted.bam.flagstat | 13 ----------- tests/software/samtools/main.nf | 15 +++++++++++++ tests/software/samtools/test.yml | 8 +++++++ 8 files changed, 37 insertions(+), 62 deletions(-) delete mode 120000 software/samtools/flagstat/test/input/test.paired_end.sorted.bam delete mode 120000 software/samtools/flagstat/test/input/test.paired_end.sorted.bam.bai delete mode 100755 software/samtools/flagstat/test/main.nf delete mode 100644 software/samtools/flagstat/test/nextflow.config delete mode 100644 software/samtools/flagstat/test/output/samtools/test.paired_end.sorted.bam.flagstat create mode 100644 tests/software/samtools/main.nf create mode 100644 tests/software/samtools/test.yml diff --git a/.github/workflows/software/samtools_flagstat.yml b/.github/workflows/software/samtools_flagstat.yml index 69267617..6ade3ee8 100644 --- a/.github/workflows/software/samtools_flagstat.yml +++ b/.github/workflows/software/samtools_flagstat.yml @@ -17,14 +17,20 @@ jobs: env: NXF_ANSI_LOG: false steps: + - uses: actions/checkout@v2 - - uses: actions/checkout@v2 + - name: Install Nextflow + run: | + export NXF_VER="20.07.1" + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ - - name: Install Nextflow - run: | - export NXF_VER="20.07.1" - 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: nextflow run ./software/samtools/flagstat/test/ -profile docker + # Test the module + - run: pytest --tag samtools_flagstat --symlink --wt 2 diff --git a/software/samtools/flagstat/test/input/test.paired_end.sorted.bam b/software/samtools/flagstat/test/input/test.paired_end.sorted.bam deleted file mode 120000 index af606d91..00000000 --- a/software/samtools/flagstat/test/input/test.paired_end.sorted.bam +++ /dev/null @@ -1 +0,0 @@ -../../../../../tests/data/bam/test.paired_end.sorted.bam \ No newline at end of file diff --git a/software/samtools/flagstat/test/input/test.paired_end.sorted.bam.bai b/software/samtools/flagstat/test/input/test.paired_end.sorted.bam.bai deleted file mode 120000 index 61a71557..00000000 --- a/software/samtools/flagstat/test/input/test.paired_end.sorted.bam.bai +++ /dev/null @@ -1 +0,0 @@ -../../../../../tests/data/bam/test.paired_end.sorted.bam.bai \ No newline at end of file diff --git a/software/samtools/flagstat/test/main.nf b/software/samtools/flagstat/test/main.nf deleted file mode 100755 index 680f70dd..00000000 --- a/software/samtools/flagstat/test/main.nf +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { SAMTOOLS_FLAGSTAT } from '../main.nf' addParams( options: [:] ) - -workflow test { - - def input = [] - input = [ [ id:'test', single_end:false ], // meta map - file("${baseDir}/input/test.paired_end.sorted.bam", checkIfExists: true), - file("${baseDir}/input/test.paired_end.sorted.bam.bai", checkIfExists: true) ] - - SAMTOOLS_FLAGSTAT ( input ) -} - -workflow { - test() -} diff --git a/software/samtools/flagstat/test/nextflow.config b/software/samtools/flagstat/test/nextflow.config deleted file mode 100644 index 4149feea..00000000 --- a/software/samtools/flagstat/test/nextflow.config +++ /dev/null @@ -1,20 +0,0 @@ - -params { - outdir = "output/" - publish_dir_mode = "copy" - enable_conda = false -} - -profiles { - conda { - params.enable_conda = true - } - docker { - docker.enabled = true - docker.runOptions = '-u \$(id -u):\$(id -g)' - } - singularity { - singularity.enabled = true - singularity.autoMounts = true - } -} diff --git a/software/samtools/flagstat/test/output/samtools/test.paired_end.sorted.bam.flagstat b/software/samtools/flagstat/test/output/samtools/test.paired_end.sorted.bam.flagstat deleted file mode 100644 index c25f585c..00000000 --- a/software/samtools/flagstat/test/output/samtools/test.paired_end.sorted.bam.flagstat +++ /dev/null @@ -1,13 +0,0 @@ -20000 + 0 in total (QC-passed reads + QC-failed reads) -0 + 0 secondary -0 + 0 supplementary -0 + 0 duplicates -20000 + 0 mapped (100.00% : N/A) -20000 + 0 paired in sequencing -10000 + 0 read1 -10000 + 0 read2 -20000 + 0 properly paired (100.00% : N/A) -20000 + 0 with itself and mate mapped -0 + 0 singletons (0.00% : N/A) -0 + 0 with mate mapped to a different chr -0 + 0 with mate mapped to a different chr (mapQ>=5) diff --git a/tests/software/samtools/main.nf b/tests/software/samtools/main.nf new file mode 100644 index 00000000..79aefd31 --- /dev/null +++ b/tests/software/samtools/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SAMTOOLS_FLAGSTAT } from '../../../software/samtools/flagstat/main.nf' addParams( options: [:] ) + +workflow test_samtools_flagstat { + + def input = [] + input = [ [ id:'test', single_end:false ], // meta map + file("${launchDir}/tests/data/bam/test.paired_end.sorted.bam", checkIfExists: true), + file("${launchDir}/tests/data/bam/test.paired_end.sorted.bam.bai", checkIfExists: true) ] + + SAMTOOLS_FLAGSTAT ( input ) +} diff --git a/tests/software/samtools/test.yml b/tests/software/samtools/test.yml new file mode 100644 index 00000000..effcf4a2 --- /dev/null +++ b/tests/software/samtools/test.yml @@ -0,0 +1,8 @@ +- name: Run samtools flagstat test workflow + command: nextflow run ./tests/software/samtools/ -profile docker -entry test_samtools_flagstat -c tests/config/nextflow.config + tags: + - samtools + - samtools_flagstat + files: + - path: output/samtools/test.paired_end.sorted.bam.flagstat + md5sum: 80590621c74f5ee43ada20d010a3837f