Skip to content

Commit

Permalink
Migrate from nf-val to nf-schema. Basic nf-test (real data)
Browse files Browse the repository at this point in the history
  • Loading branch information
mberacochea committed May 30, 2024
1 parent 1edc01b commit 988ca49
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 54 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: nf-test CI
on:
push:
branches:
- dev
pull_request:
release:
types: [published]

env:
NXF_ANSI_LOG: false
NFTEST_VER: "0.8.4"

jobs:
test:
name: Run pipeline with test data
runs-on: ubuntu-latest

steps:
- name: Check out pipeline code
uses: actions/checkout@v4

- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
distribution: "temurin"
java-version: "17"

- name: Setup Nextflow
uses: nf-core/setup-nextflow@v2

- name: Install nf-test
uses: nf-core/setup-nf-test@v1

- name: Run pipeline with test data
run: |
nf-test test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ results/
.pytest_cache/

assets/fetch_tool_credentials.json
.nf-test.log
.nf-test/
Binary file added assets/mgnify_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions assets/multiqc_config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
report_comment: >
This report has been generated by the <a href="https://github.com/ebi-metagenomics/miassembler/" target="_blank">ebi-metagenomics/miassembler</a>
analysis pipeline.
report_section_order:
"ebi-metagenomics-miassembler-methods-description":
order: -1000
software_versions:
order: -1001
"ebi-metagenomics-miassembler-summary":
order: -1002

export_plots: true

skip_versions_section: true

top_modules:
- fastqc
- quast
Expand Down
3 changes: 0 additions & 3 deletions assets/samplesheet.csv

This file was deleted.

2 changes: 1 addition & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nextflow.enable.dsl = 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

include { validateParameters; paramsHelp; paramsSummaryLog; paramsSummaryMap; } from 'plugin/nf-validation'
include { validateParameters; paramsHelp; paramsSummaryLog; paramsSummaryMap; } from 'plugin/nf-schema'

def summary_params = paramsSummaryMap(workflow)

Expand Down
14 changes: 7 additions & 7 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ params {
max_cpus = 32
max_time = '168.h' // 7 days

// Schema validation default options
validationFailUnrecognisedParams = false
validationLenientMode = false
validationShowHiddenParams = false
validate_params = true

// Assembler versions
spades_version = "3.15.5"
megahit_version = "1.2.9"

}

validation {
failUnrecognisedParams = true
lenientMode = false
showHiddenParams = false
}

// Load base.config by default for all pipelines
includeConfig 'conf/base.config'

Expand Down Expand Up @@ -192,7 +192,7 @@ singularity.registry = 'quay.io'

// Nextflow plugins
plugins {
id 'nf-[email protected]' // Validation of pipeline parameters and creation of an input channel from a sample sheet
id 'nf-[email protected]'
}

// Export these variables to prevent local Python/R libraries from conflicting with those in the container
Expand Down
38 changes: 5 additions & 33 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/ebi-metagenomics/miassembler/master/nextflow_schema.json",
"title": "ebi-metagenomics/miassembler pipeline parameters",
"description": "Microbiome Informatics metagenomes assembly pipeline",
"type": "object",
"definitions": {
"defs": {
"input_output_options": {
"title": "Input/output options",
"type": "object",
Expand Down Expand Up @@ -241,47 +241,19 @@
"type": "string",
"description": "Custom MultiQC yaml file containing HTML including a methods description.",
"fa_icon": "fas fa-cog"
},
"validate_params": {
"type": "boolean",
"description": "Boolean whether to validate parameters against the schema at runtime",
"default": true,
"fa_icon": "fas fa-check-square",
"hidden": true
},
"validationShowHiddenParams": {
"type": "boolean",
"fa_icon": "far fa-eye-slash",
"description": "Show all params when using `--help`",
"hidden": true,
"help_text": "By default, parameters set as _hidden_ in the schema are not shown on the command line when a user runs with `--help`. Specifying this option will tell the pipeline to show all parameters."
},
"validationFailUnrecognisedParams": {
"type": "boolean",
"fa_icon": "far fa-check-circle",
"description": "Validation of parameters fails when an unrecognised parameter is found.",
"hidden": true,
"help_text": "By default, when an unrecognised parameter is found, it returns a warinig."
},
"validationLenientMode": {
"type": "boolean",
"fa_icon": "far fa-check-circle",
"description": "Validation of parameters in lenient more.",
"hidden": true,
"help_text": "Allows string values that are parseable as numbers or booleans. For further information see [JSONSchema docs](https://github.com/everit-org/json-schema#lenient-mode)."
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/input_output_options"
"$ref": "#/defs/input_output_options"
},
{
"$ref": "#/definitions/max_job_request_options"
"$ref": "#/defs/max_job_request_options"
},
{
"$ref": "#/definitions/generic_options"
"$ref": "#/defs/generic_options"
}
]
}
7 changes: 7 additions & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
config {

testsDir "tests"
workDir ".nf-test"
configFile "tests/nextflow.config"
profile "test,docker"
}
25 changes: 25 additions & 0 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
nextflow_pipeline {

name "Test Workflow EBIMETAGENOMICS_MIASSEMBLER"
script "main.nf"

test("Should run without failures") {

when {
params {
outdir = "tests/results"
bwamem2_reference_genomes_folder = "$projectDir/tests/human_phix/bwa2mem"
blast_reference_genomes_folder = "$projectDir/tests/human_phix/blast"
}
}

then {
with(workflow) {
assert success
assert trace.tasks().size() == 19
}
}

}

}
5 changes: 5 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
========================================================================================
Nextflow config file for running tests
========================================================================================
*/
16 changes: 8 additions & 8 deletions workflows/miassembler.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

include { paramsSummaryLog; paramsSummaryMap } from 'plugin/nf-validation'
include { paramsSummaryLog; paramsSummaryMap } from 'plugin/nf-schema'

def logo = NfcoreTemplate.logo(workflow, params.monochrome_logs)
def citation = '\n' + WorkflowMain.citation(workflow) + '\n'
Expand All @@ -21,7 +21,7 @@ log.info logo + paramsSummaryLog(workflow) + citation

ch_multiqc_config = Channel.fromPath("$projectDir/assets/multiqc_config.yml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath( params.multiqc_config, checkIfExists: true ) : Channel.empty()
ch_multiqc_logo = params.multiqc_logo ? Channel.fromPath( params.multiqc_logo, checkIfExists: true ) : Channel.empty()
ch_multiqc_logo = params.multiqc_logo ? Channel.fromPath( params.multiqc_logo, checkIfExists: true ) : Channel.fromPath("$projectDir/assets/mgnify_logo.png")
ch_multiqc_custom_methods_description = params.multiqc_methods_description ? file(params.multiqc_methods_description, checkIfExists: true) : file("$projectDir/assets/methods_description_template.yml", checkIfExists: true)

/*
Expand Down Expand Up @@ -50,11 +50,11 @@ include { ASSEMBLY_COVERAGE } from '../subworkflows/local/assembly_coverage'
//
include { FASTQC as FASTQC_BEFORE } from '../modules/nf-core/fastqc/main'
include { FASTQC as FASTQC_AFTER } from '../modules/nf-core/fastqc/main'
include { MULTIQC } from '../modules/nf-core/multiqc/main'
include { CUSTOM_DUMPSOFTWAREVERSIONS } from '../modules/nf-core/custom/dumpsoftwareversions/main'
include { SPADES } from '../modules/nf-core/spades/main'
include { MEGAHIT } from '../modules/nf-core/megahit/main'
include { QUAST } from '../modules/nf-core/quast/main'
include { MULTIQC } from '../modules/nf-core/multiqc/main'
include { CUSTOM_DUMPSOFTWAREVERSIONS } from '../modules/nf-core/custom/dumpsoftwareversions/main'
include { SPADES } from '../modules/nf-core/spades/main'
include { MEGAHIT } from '../modules/nf-core/megahit/main'
include { QUAST } from '../modules/nf-core/quast/main'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -149,7 +149,7 @@ workflow MIASSEMBLER {

SPADES(
qc_reads.xspades.map { meta, reads -> [meta, reads, [], []] },
params.assembler,
params.assembler ?: "metaspades",
[], // yml input parameters, which we don't use
[] // hmm, not used
)
Expand Down

0 comments on commit 988ca49

Please sign in to comment.