Merge pull request #80 from nf-core/pytest-workflow

Pytest-workflow
This commit is contained in:
Harshil Patel 2020-11-24 22:55:07 +00:00 committed by GitHub
commit 794a5cbd0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 59 additions and 678 deletions

View file

@ -26,5 +26,12 @@ jobs:
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/fastqc/test/ -profile docker
- run: pytest --tag fastqc --symlink --wt 2

View file

@ -1 +0,0 @@
../../../lib/

View file

@ -1,76 +0,0 @@
#!/usr/bin/env nextflow
import checksum
nextflow.preview.dsl = 2
params.out_dir = "test_output"
params.fastqc_args = ''
params.publish_dir_mode = "copy"
include { FASTQC } from '../main.nf'
/**
* Test if FASTQC runs with single-end data
*/
workflow test_single_end {
input_files = Channel.fromPath("${baseDir}/input/test_single_end.fastq.gz")
.map {f -> [f.name.replace(".fastq.gz", ""), true, f]}
FASTQC(input_files)
// test that the output looks as expected
FASTQC.out.html.map { name, is_single_end, html_file ->
html_hash = checksum.getMD5(new File("${html_file}"));
assert name == "test_single_end"
assert is_single_end == true
assert html_file.getName() == "test_single_end_fastqc.html"
// Hash seems to vary between local runs and GitHub Actions
// TODO: Might be solved when using Docker for tests?
// assert html_hash == "8ed68442ebb5b9706bf79b4f66701e15"
}
FASTQC.out.zip.map { name, is_single_end, zip_file ->
// NOTE: output zip files do not have a consistent hash
assert name == "test_single_end"
assert is_single_end == true
assert zip_file.getName() == "test_single_end_fastqc.zip"
}
}
/**
* Test if FASTQC runs with paired end data
*/
workflow test_paired_end {
input_files = Channel.fromFilePairs("input/test_R{1,2}.fastq.gz")
.map {f -> [f[0], false, f[1]]}
FASTQC(input_files)
// test that the output looks as expected
FASTQC.out.html.map { name, is_single_end, html_files ->
html_r1 = html_files[0]
html_r2 = html_files[1]
html_r1_hash = checksum.getMD5(new File("${html_r1}"));
html_r2_hash = checksum.getMD5(new File("${html_r2}"));
assert name == "test_R"
assert is_single_end == false
assert html_r1.getName() == "test_R_1_fastqc.html"
assert html_r2.getName() == "test_R_2_fastqc.html"
assert html_r1_hash == "082c13ce7163ea0f52a66b83cb57b0f0"
assert html_r2_hash == "4ff04ec8da77e3af512f03b8c09a9e04"
}
FASTQC.out.zip.map { name, is_single_end, zip_files ->
zip_r1 = zip_files[0]
zip_r2 = zip_files[1]
// NOTE: output zip files do not have a consistent hash
assert name == "test_R"
assert is_single_end == false
assert zip_r1.getName() == "test_R_1_fastqc.zip"
assert zip_r2.getName() == "test_R_2_fastqc.zip"
}
}
workflow {
test_single_end()
test_paired_end()
}

View file

@ -1 +0,0 @@
../../../../tests/data/fastq/rna/test_R1.fastq.gz

View file

@ -1 +0,0 @@
../../../../tests/data/fastq/rna/test_R2.fastq.gz

View file

@ -1 +0,0 @@
../../../../tests/data/fastq/rna/test_single_end.fastq.gz

View file

@ -1,36 +0,0 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FASTQC as FASTQC_SE } from '../main.nf' addParams( options: [ publish_dir:'test_single_end' ] )
include { FASTQC as FASTQC_PE } from '../main.nf' addParams( options: [ publish_dir:'test_paired_end' ] )
/*
* Test with single-end data
*/
workflow test_single_end {
def input = []
input = [ [ id:'test', single_end:true ], // meta map
[ file("${baseDir}/input/test_single_end.fastq.gz", checkIfExists: true) ] ]
FASTQC_SE ( input )
}
/*
* Test with paired-end data
*/
workflow test_paired_end {
def input = []
input = [ [ id:'test', single_end:false ], // meta map
[ file("${baseDir}/input/test_R1.fastq.gz", checkIfExists: true),
file("${baseDir}/input/test_R2.fastq.gz", checkIfExists: true) ] ]
FASTQC_PE ( input )
}
workflow {
test_single_end()
test_paired_end()
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,31 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { FASTQC as FASTQC_SE } from '../../../software/fastqc/main.nf' addParams( options: [ publish_dir:'test_single_end' ] )
include { FASTQC as FASTQC_PE } from '../../../software/fastqc/main.nf' addParams( options: [ publish_dir:'test_paired_end' ] )
/*
* Test with single-end data
*/
workflow test_single_end {
def input = []
input = [ [ id:'test', single_end:true ], // meta map
[ file("${launchDir}/tests/data/fastq/rna/test_single_end.fastq.gz", checkIfExists: true) ] ]
FASTQC_SE ( input )
}
/*
* Test with paired-end data
*/
workflow test_paired_end {
def input = []
input = [ [ id:'test', single_end:false ], // meta map
[ file("${launchDir}/tests/data/fastq/rna/test_R1.fastq.gz", checkIfExists: true),
file("${launchDir}/tests/data/fastq/rna/test_R2.fastq.gz", checkIfExists: true) ] ]
FASTQC_PE ( input )
}

View file

@ -0,0 +1,20 @@
- name: Run fastqc single-end test workflow
command: nextflow run ./tests/software/fastqc/ -profile docker -entry test_single_end -c tests/config/nextflow.config
tags:
- fastqc
files:
- path: output/test_single_end/test_fastqc.html
md5sum: 7027e72c3e55292c1567f12e02565e3b
- path: output/test_single_end/test_fastqc.zip
- name: Run fastqc paired-end test workflow
command: nextflow run ./tests/software/fastqc/ -profile docker -entry test_paired_end -c tests/config/nextflow.config
tags:
- fastqc
files:
- path: output/test_paired_end/test_1_fastqc.html
md5sum: b3796b4323dc34970b7461f813135254
- path: output/test_paired_end/test_2_fastqc.html
md5sum: 55182467f48ca5ed88a2608ea57a1afc
- path: output/test_paired_end/test_1_fastqc.zip
- path: output/test_paired_end/test_2_fastqc.zip