diff --git a/.github/workflows/multiqc.yml b/.github/workflows/multiqc.yml new file mode 100644 index 00000000..37a830bd --- /dev/null +++ b/.github/workflows/multiqc.yml @@ -0,0 +1,38 @@ +name: multiqc +on: + push: + paths: + - software/multiqc/** + - .github/workflows/multiqc.yml + - tests + pull_request: + paths: + - software/multiqc/** + - .github/workflows/multiqc.yml + - tests + +jobs: + ci_test: + runs-on: ubuntu-latest + env: + NXF_ANSI_LOG: false + steps: + + - 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: 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 multiqc --symlink --wt 2 + diff --git a/software/multiqc/functions.nf b/software/multiqc/functions.nf new file mode 100644 index 00000000..d25eea86 --- /dev/null +++ b/software/multiqc/functions.nf @@ -0,0 +1,59 @@ +/* + * ----------------------------------------------------- + * Utility functions used in nf-core DSL2 module files + * ----------------------------------------------------- + */ + +/* + * Extract name of software tool from process name using $task.process + */ +def getSoftwareName(task_process) { + return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase() +} + +/* + * Function to initialise default values and to generate a Groovy Map of available options for nf-core modules + */ +def initOptions(Map args) { + def Map options = [:] + options.args = args.args ?: '' + options.args2 = args.args2 ?: '' + options.publish_by_id = args.publish_by_id ?: false + options.publish_dir = args.publish_dir ?: '' + options.publish_files = args.publish_files + options.suffix = args.suffix ?: '' + return options +} + +/* + * Tidy up and join elements of a list to return a path string + */ +def getPathFromList(path_list) { + def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries + paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes + return paths.join('/') +} + +/* + * Function to save/publish module results + */ +def saveFiles(Map args) { + if (!args.filename.endsWith('.version.txt')) { + def ioptions = initOptions(args.options) + def path_list = [ ioptions.publish_dir ?: args.publish_dir ] + if (ioptions.publish_by_id) { + path_list.add(args.publish_id) + } + if (ioptions.publish_files instanceof Map) { + for (ext in ioptions.publish_files) { + if (args.filename.endsWith(ext.key)) { + def ext_list = path_list.collect() + ext_list.add(ext.value) + return "${getPathFromList(ext_list)}/$args.filename" + } + } + } else if (ioptions.publish_files == null) { + return "${getPathFromList(path_list)}/$args.filename" + } + } +} diff --git a/software/multiqc/main.nf b/software/multiqc/main.nf new file mode 100644 index 00000000..09d223fc --- /dev/null +++ b/software/multiqc/main.nf @@ -0,0 +1,31 @@ +// Import generic module functions +include { initOptions; saveFiles; getSoftwareName } from './functions' + +params.options = [:] +def options = initOptions(params.options) + +process MULTIQC { + 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: '') } + + conda (params.enable_conda ? "bioconda::multiqc=1.9" : null) + container "quay.io/biocontainers/multiqc:1.9--pyh9f0ad1d_0" + + input: + path multiqc_files + + output: + path "*multiqc_report.html", emit: report + path "*_data" , emit: data + path "*_plots" , optional:true, emit: plots + path "*.version.txt" , emit: version + + script: + def software = getSoftwareName(task.process) + """ + multiqc -f $options.args . + multiqc --version | sed -e "s/multiqc, version //g" > ${software}.version.txt + """ +} diff --git a/software/multiqc/meta.yml b/software/multiqc/meta.yml new file mode 100644 index 00000000..684ccd5e --- /dev/null +++ b/software/multiqc/meta.yml @@ -0,0 +1,55 @@ +name: MultiQC +description: Aggregate results from bioinformatics analyses across many samples into a single report +keywords: + - QC + - bioinformatics tools + - Beautiful stand-alone HTML report +tools: + - multiqc: + description: | + MultiQC searches a given directory for analysis logs and compiles a HTML report. + It's a general use tool, perfect for summarising the output from numerous bioinformatics tools. + homepage: https://multiqc.info/ + documentation: https://multiqc.info/docs/ +params: + - outdir: + type: string + description: | + The pipeline's output directory. By default, the module will + output files into `$params.outdir/` + - publish_dir_mode: + type: string + description: | + Value for the Nextflow `publishDir` mode parameter. + Available: symlink, rellink, link, copy, copyNoFollow, move. + - enable_conda: + type: boolean + description: | + Run the module with Conda using the software specified + via the `conda` directive +input: + - multiqc_files: + type: file + description: | + List of reports / files recognised by MultiQC, for example the html and zip output of FastQC +output: + - report: + type: file + description: MultiQC report file + pattern: "multiqc_report.html" + - data: + type: dir + description: MultiQC data dir + pattern: "multiqc_data" + - plots: + type: file + description: Plots created by MultiQC + pattern: "*_data" + - version: + type: file + description: File containing software version + pattern: "*.{version.txt}" +authors: + - "@abhi18av" + - "@bunop" + - "@drpatelh" diff --git a/tests/data/fastqc/test_1_fastqc.html b/tests/data/fastqc/test_1_fastqc.html new file mode 100644 index 00000000..e33dddbe --- /dev/null +++ b/tests/data/fastqc/test_1_fastqc.html @@ -0,0 +1,187 @@ +test_1.fastq.gz FastQC Report
FastQCFastQC Report
Fri 7 Aug 2020
test_1.fastq.gz

Summary

[OK]Basic Statistics

MeasureValue
Filenametest_1.fastq.gz
File typeConventional base calls
EncodingSanger / Illumina 1.9
Total Sequences10000
Sequences flagged as poor quality0
Sequence length76
%GC44

[OK]Per base sequence quality

Per base quality graph

[OK]Per tile sequence quality

Per tile quality graph

[OK]Per sequence quality scores

Per Sequence quality graph

[FAIL]Per base sequence content

Per base sequence content

[OK]Per sequence GC content

Per sequence GC content graph

[OK]Per base N content

N content graph

[OK]Sequence Length Distribution

Sequence length distribution

[OK]Sequence Duplication Levels

Duplication level graph

[WARN]Overrepresented sequences

SequenceCountPercentagePossible Source
GTATCAACGCAGAGTACTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT230.22999999999999998No Hit
GGTATCAACGCAGAGTACTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT160.16No Hit
TATCAACGCAGAGTACTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT150.15No Hit

[OK]Adapter Content

Adapter graph

\ No newline at end of file diff --git a/tests/data/fastqc/test_1_fastqc.zip b/tests/data/fastqc/test_1_fastqc.zip new file mode 100644 index 00000000..82b12818 Binary files /dev/null and b/tests/data/fastqc/test_1_fastqc.zip differ diff --git a/tests/data/fastqc/test_2_fastqc.html b/tests/data/fastqc/test_2_fastqc.html new file mode 100644 index 00000000..5fb48f29 --- /dev/null +++ b/tests/data/fastqc/test_2_fastqc.html @@ -0,0 +1,187 @@ +test_2.fastq.gz FastQC Report
FastQCFastQC Report
Fri 7 Aug 2020
test_2.fastq.gz

Summary

[OK]Basic Statistics

MeasureValue
Filenametest_2.fastq.gz
File typeConventional base calls
EncodingSanger / Illumina 1.9
Total Sequences10000
Sequences flagged as poor quality0
Sequence length76
%GC44

[OK]Per base sequence quality

Per base quality graph

[OK]Per tile sequence quality

Per tile quality graph

[OK]Per sequence quality scores

Per Sequence quality graph

[FAIL]Per base sequence content

Per base sequence content

[OK]Per sequence GC content

Per sequence GC content graph

[OK]Per base N content

N content graph

[OK]Sequence Length Distribution

Sequence length distribution

[OK]Sequence Duplication Levels

Duplication level graph

[WARN]Overrepresented sequences

SequenceCountPercentagePossible Source
GTATCAACGCAGAGTACTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT190.19No Hit

[OK]Adapter Content

Adapter graph

\ No newline at end of file diff --git a/tests/data/fastqc/test_2_fastqc.zip b/tests/data/fastqc/test_2_fastqc.zip new file mode 100644 index 00000000..b8741db9 Binary files /dev/null and b/tests/data/fastqc/test_2_fastqc.zip differ diff --git a/tests/software/fastqc/main.nf b/tests/software/fastqc/main.nf index 629b4632..2a4b8677 100644 --- a/tests/software/fastqc/main.nf +++ b/tests/software/fastqc/main.nf @@ -23,11 +23,16 @@ workflow test_single_end { 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) ] ] + 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) + + emit: + html = FASTQC_PE.out.html + zip = FASTQC_PE.out.zip - FASTQC_PE ( input ) } // TODO Test e2e diff --git a/tests/software/multiqc/main.nf b/tests/software/multiqc/main.nf new file mode 100644 index 00000000..06b466ab --- /dev/null +++ b/tests/software/multiqc/main.nf @@ -0,0 +1,16 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { MULTIQC } from '../../../software/multiqc/main.nf' addParams(options: [publish_dir: 'test_multiqc']) +include { test_paired_end } from '../fastqc/main.nf' addParams(options: [publish_dir: 'test_paired_end']) + +workflow test_multiqc { + test_paired_end() + + input = [ + test_paired_end.out.zip.collect { it[1] }.ifEmpty([]) + ] + + MULTIQC(*input) +} diff --git a/tests/software/multiqc/test.yml b/tests/software/multiqc/test.yml new file mode 100644 index 00000000..7fc6d7a3 --- /dev/null +++ b/tests/software/multiqc/test.yml @@ -0,0 +1,7 @@ +- name: Run multiqc test workflow + command: nextflow run ./tests/software/multiqc/ -profile docker -entry test_multiqc -c tests/config/nextflow.config + tags: + - multiqc + files: + - path: output/test_multiqc/multiqc_report.html +