├── .github └── workflows │ ├── build-docs.yml │ ├── build.yml │ └── pre-commit.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .prettierignore ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── buildSrc ├── build.gradle └── src │ └── main │ └── groovy │ ├── io.nextflow.groovy-application-conventions.gradle │ ├── io.nextflow.groovy-common-conventions.gradle │ └── io.nextflow.groovy-library-conventions.gradle ├── docs ├── background.md ├── contributing │ └── setup.md ├── images │ ├── help_monochrome_logs.png │ ├── help_not_monochrome_logs.png │ ├── nf-validation.png │ ├── nf-validation.svg │ ├── summary_monochrome_logs.png │ └── summary_not_monochrome_logs.png ├── index.md ├── nextflow_schema │ ├── create_schema.md │ ├── index.md │ ├── nextflow_schema_examples.md │ ├── nextflow_schema_specification.md │ ├── sample_sheet_schema_examples.md │ └── sample_sheet_schema_specification.md ├── parameters │ ├── help_text.md │ ├── summary_log.md │ └── validation.md ├── samplesheets │ ├── examples.md │ ├── fromSamplesheet.md │ └── validate_sample_sheet.md ├── schema_input.json └── stylesheets │ └── extra.css ├── examples ├── fromSamplesheetBasic │ ├── launch.sh │ ├── log.txt │ ├── pipeline │ │ ├── assets │ │ │ └── schema_input.json │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── fromSamplesheetMeta │ ├── launch.sh │ ├── log.txt │ ├── pipeline │ │ ├── assets │ │ │ └── schema_input.json │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── fromSamplesheetOrder │ ├── launch.sh │ ├── log.txt │ ├── pipeline │ │ ├── assets │ │ │ └── schema_input.json │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── paramsHelp │ ├── log.txt │ ├── log_outdir.txt │ ├── pipeline │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── paramsSummaryLog │ ├── log.txt │ ├── pipeline │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── paramsSummaryMap │ ├── log.txt │ ├── pipeline │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── validateParameters │ ├── log.txt │ ├── pipeline │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv ├── validationFailUnrecognisedParams │ ├── log.txt │ ├── pipeline │ │ ├── main.nf │ │ ├── nextflow.config │ │ └── nextflow_schema.json │ └── samplesheet.csv └── validationWarnUnrecognisedParams │ ├── log.txt │ ├── pipeline │ ├── main.nf │ ├── nextflow.config │ └── nextflow_schema.json │ └── samplesheet.csv ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── launch.sh ├── mkdocs.yml ├── overrides └── main.html ├── parameters_meta_schema.json ├── plugins ├── build.gradle └── nf-validation │ ├── build.gradle │ └── src │ ├── main │ └── nextflow │ │ └── validation │ │ ├── FormatValidators │ │ ├── DirectoryPathValidator.groovy │ │ ├── FilePathPatternValidator.groovy │ │ ├── FilePathValidator.groovy │ │ └── PathValidator.groovy │ │ ├── SamplesheetConverter.groovy │ │ ├── SchemaValidationException.groovy │ │ ├── SchemaValidator.groovy │ │ └── ValidationPlugin.groovy │ ├── resources │ └── META-INF │ │ ├── MANIFEST.MF │ │ └── extensions.idx │ ├── test │ └── nextflow │ │ └── validation │ │ ├── PluginExtensionMethodsTest.groovy │ │ └── SamplesheetConverterTest.groovy │ └── testResources │ ├── correct.csv │ ├── correct.tsv │ ├── correct.yaml │ ├── correct_quoted.csv │ ├── duplicate.csv │ ├── errors.csv │ ├── errorsBeforeConversion.csv │ ├── extraFields.csv │ ├── nextflow_schema.json │ ├── nextflow_schema_file_cloud_path.json │ ├── nextflow_schema_file_path_pattern.json │ ├── nextflow_schema_with_samplesheet.json │ ├── nextflow_schema_with_samplesheet_converter.json │ ├── nextflow_schema_with_samplesheet_no_header.json │ ├── nextflow_schema_with_samplesheet_no_meta.json │ ├── no_header.csv │ ├── no_header.yaml │ ├── no_header_schema.json │ ├── no_meta.csv │ ├── no_meta_schema.json │ ├── samplesheet.csv │ ├── samplesheet_no_header.csv │ ├── samplesheet_no_required.csv │ ├── samplesheet_schema.json │ ├── samplesheet_wrong_pattern.csv │ ├── schema_input.json │ ├── test.txt │ ├── testDir │ └── testFile.txt │ └── wrong.yaml └── settings.gradle /.github/workflows/build-docs.yml: -------------------------------------------------------------------------------- 1 | name: build docs 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - main 7 | - dev 8 | permissions: 9 | contents: write 10 | jobs: 11 | deploy: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-python@v4 16 | with: 17 | python-version: 3.x 18 | - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV 19 | - uses: actions/cache@v3 20 | with: 21 | key: mkdocs-material-${{ env.cache_id }} 22 | path: .cache 23 | restore-keys: | 24 | mkdocs-material- 25 | - run: pip install mkdocs-material pymdown-extensions pillow cairosvg 26 | - run: mkdocs gh-deploy --force 27 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: nf-validator CI 2 | on: 3 | push: 4 | branches: 5 | - '*' 6 | tags-ignore: 7 | - '*' 8 | pull_request: 9 | branches: 10 | - '*' 11 | jobs: 12 | build: 13 | name: Build nf-validator 14 | if: "!contains(github.event.head_commit.message, '[ci skip]')" 15 | runs-on: ubuntu-latest 16 | timeout-minutes: 10 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | java_version: [11, 17] 21 | 22 | steps: 23 | - name: Environment 24 | run: env | sort 25 | 26 | - name: Checkout 27 | uses: actions/checkout@v3 28 | with: 29 | fetch-depth: 1 30 | submodules: true 31 | 32 | - name: Setup Java ${{ matrix.java_version }} 33 | uses: actions/setup-java@v3 34 | with: 35 | java-version: ${{matrix.java_version}} 36 | distribution: 'adopt' 37 | architecture: x64 38 | cache: gradle 39 | 40 | - name: Compile 41 | run: ./gradlew assemble 42 | 43 | - name: Tests 44 | run: ./gradlew check 45 | env: 46 | GRADLE_OPTS: '-Dorg.gradle.daemon=false' 47 | 48 | - name: Publish tests report 49 | if: failure() 50 | uses: actions/upload-artifact@v3 51 | with: 52 | name: test-reports-jdk-${{ matrix.java_version }} 53 | path: | 54 | ./plugins/nf-validation/build/reports/tests/test/** 55 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | name: Lint code 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | pre-commit: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-python@v3 12 | - uses: pre-commit/action@v3.0.0 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Docs / other 2 | .cache/ 3 | .DS_Store 4 | 5 | # Ignore Gradle project-specific cache directory 6 | .gradle 7 | .idea 8 | .nextflow 9 | .nextflow.log* 10 | .nextflow.pid 11 | 12 | # Ignore Gradle build output directory 13 | build 14 | work 15 | out 16 | site 17 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # Config for pre-commit: https://pre-commit.com/ 2 | --- 3 | minimum_pre_commit_version: "2.9.2" 4 | repos: 5 | - repo: meta 6 | hooks: 7 | - id: identity 8 | - id: check-hooks-apply 9 | 10 | - repo: https://github.com/pre-commit/mirrors-prettier 11 | rev: "v2.7.1" 12 | hooks: 13 | - id: prettier 14 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore everything 2 | /* 3 | 4 | # Except docs and markdown files 5 | !docs/ 6 | !*.md 7 | !*.yml 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "useTabs": false 4 | } 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # nextflow-io/nf-validation: Changelog 2 | 3 | # Version 1.1.4 4 | 5 | ## Improvements 6 | 7 | - No longer does false validation on Azure and GCP cloud storage paths ([#171](https://github.com/nextflow-io/nf-validation/pull/171)) 8 | 9 | ## Vulnerability fix 10 | 11 | - Updated the org.json package to version `20240303` ([#172](https://github.com/nextflow-io/nf-validation/pull/172)) 12 | 13 | # Version 1.1.3 - Asahikawa 14 | 15 | ## Improvements 16 | 17 | - Added support for double quotes (`"`) in CSV and TSV samplesheets ([#134](https://github.com/nextflow-io/nf-validation/pull/134)) 18 | 19 | # Version 1.1.2 - Wakayama 20 | 21 | ## Bug fixes 22 | 23 | - Fixed an issue with inputs using `file-path-pattern` where only one file was found (`Path` casting to `ArrayList` error) ([#132](https://github.com/nextflow-io/nf-validation/pull/132)) 24 | 25 | # Version 1.1.1 - Shoyu 26 | 27 | ## Bug fixes 28 | 29 | - Fixed an issue where samplesheet with a lot of null values would take forever to validate ([#120](https://github.com/nextflow-io/nf-validation/pull/120)) => Thanks @awgymer for fixing this! 30 | - Now YAML files are actually validated instead of skipped ([#124](https://github.com/nextflow-io/nf-validation/pull/120)) 31 | 32 | # Version 1.1.0 - Miso 33 | 34 | ## Features 35 | 36 | - Add support for samplesheets with no header ([#115](https://github.com/nextflow-io/nf-validation/pull/115)) 37 | 38 | ## Bug fixes 39 | 40 | - Floats and doubles should now be created when using the `number` type in the schema ([#113](https://github.com/nextflow-io/nf-validation/pull/113/)) 41 | - When `0` is used as a default value in the schema, a `0` will now be used as the value in the `.fromSamplesheet()` channel instead of `null` ([#114](https://github.com/nextflow-io/nf-validation/pull/114)) 42 | 43 | ## New features 44 | 45 | - Added `file-path-pattern` format to check every file fetched using a glob pattern. Using a glob is now also possible in the samplesheet and will create a list of all files found using that glob pattern. ([#118](https://github.com/nextflow-io/nf-validation/pull/118)) 46 | 47 | # Version 1.0.0 - Tonkotsu 48 | 49 | The nf-validation plugin is now in production use across many pipelines and has (we hope) now reached a point of relative stability. The bump to major version v1.0.0 signifies that it is suitable for use in production pipelines. 50 | 51 | This version also introduces a small breaking change of syntax when providing optional arguments to the functions. You can now provide optional arguments such as the nextflow parameters schema path as: 52 | `validateParameters(parameters_schema: 'my_file.json')` 53 | 54 | (previous syntax used positional arguments instead). 55 | 56 | ## Bug fixes 57 | 58 | - The path to a custom parameters schema must be provided through a map '`parameters_schema: 'my_file.json'`' in `validateParameters()` and `paramsSummaryMap()` ([#108](https://github.com/nextflow-io/nf-validation/pull/108)) 59 | 60 | # Version 0.3.4 61 | 62 | This version introduced a bug which made all pipeline runs using the function `validateParameters()` without providing any arguments fail. 63 | 64 | This bug causes Nextflow to exit with an error on launch for most pipelines. It should not be used. It was [removed](https://github.com/nextflow-io/plugins/pull/40) from the Nextflow Plugin registry to avoid breaking people's runs. 65 | 66 | ### Bug fixes 67 | 68 | - Do not check S3 URL paths with `PathValidator` `FilePathValidator` and `DirectoryPathValidator` ([#106](https://github.com/nextflow-io/nf-validation/pull/106)) 69 | - Make monochrome_logs an option in `paramsSummaryLog()`, `paramsSummaryMap()` and `paramsHelp()` instead of a global parameter ([#101](https://github.com/nextflow-io/nf-validation/pull/101)) 70 | 71 | # Version 0.3.3 72 | 73 | ### Bug fixes 74 | 75 | - Do not check if S3 URL paths exists to avoid AWS errors, and add a new parameter `validationS3PathCheck` ([#104](https://github.com/nextflow-io/nf-validation/pull/104)) 76 | 77 | # Version 0.3.2 78 | 79 | ### Bug fixes 80 | 81 | - Add parameters defined on the top level of the schema and within the definitions section as expected params ([#79](https://github.com/nextflow-io/nf-validation/pull/79)) 82 | - Fix error when a parameter is not present in the schema and evaluates to false ([#89](https://github.com/nextflow-io/nf-validation/pull/89)) 83 | - Changed the `schema_filename` option of `fromSamplesheet` to `parameters_schema` to make this option more clear to the user ([#91](https://github.com/nextflow-io/nf-validation/pull/91)) 84 | 85 | ## Version 0.3.1 86 | 87 | ### Bug fixes 88 | 89 | - Don't check if path exists if param is not true ([#74](https://github.com/nextflow-io/nf-validation/pull/74)) 90 | - Don't validate a file if the parameter evaluates to false ([#75](https://github.com/nextflow-io/nf-validation/pull/75)) 91 | 92 | ## Version 0.3.0 93 | 94 | ### New features 95 | 96 | - Check that a sample sheet doesn't have duplicated entries by default. Can be disabled with `--validationSkipDuplicateCheck` ([#72](https://github.com/nextflow-io/nf-validation/pull/72)) 97 | 98 | ### Bug fixes 99 | 100 | - Only validate a path if it is not null ([#50](https://github.com/nextflow-io/nf-validation/pull/50)) 101 | - Only validate a file with a schema if the file path is provided ([#51](https://github.com/nextflow-io/nf-validation/pull/51)) 102 | - Handle errors when sample sheet not provided or doesn't have a schema ([#56](https://github.com/nextflow-io/nf-validation/pull/56)) 103 | - Silently ignore samplesheet fields that are not defined in samplesheet schema ([#59](https://github.com/nextflow-io/nf-validation/pull/59)) 104 | - Correctly handle double-quoted fields containing commas in csv files by `.fromSamplesheet()` ([#63](https://github.com/nextflow-io/nf-validation/pull/63)) 105 | - Print param name when path does not exist ([#65](https://github.com/nextflow-io/nf-validation/pull/65)) 106 | - Fix file or directory does not exist error not printed when it was the only error in a samplesheet ([#65](https://github.com/nextflow-io/nf-validation/pull/65)) 107 | - Do not return parameter in summary if it has no default in the schema and is set to 'false' ([#66](https://github.com/nextflow-io/nf-validation/pull/66)) 108 | - Skip the validation of a file if the path is an empty string and improve error message when the path is invalid ([#69](https://github.com/nextflow-io/nf-validation/pull/69)) 109 | 110 | ### Deprecated 111 | 112 | - The meta map of input channels is not an ImmutableMap anymore ([#68](https://github.com/nextflow-io/nf-validation/pull/68)). Reason: [Issue #52](https://github.com/nextflow-io/nf-validation/issues/52) 113 | 114 | ## Version 0.2.1 115 | 116 | ### Bug fixes 117 | 118 | - Fixed a bug where `immutable_meta` option in `fromSamplesheet()` wasn't working when using `validateParameters()` first. (@nvnieuwk) 119 | 120 | ## Version 0.2.0 121 | 122 | ### New features 123 | 124 | - Added a new [documentation site](https://nextflow-io.github.io/nf-validation/). (@ewels and @mashehu) 125 | - Removed the `file-path-exists`, `directory-path-exists` and `path-exists` and added a [`exists`](https://nextflow-io.github.io/nf-validation/nextflow_schema/nextflow_schema_specification/#exists) parameter to the schema. (@mirpedrol) 126 | - New [`errorMessage`](https://nextflow-io.github.io/nf-validation/nextflow_schema/nextflow_schema_specification/#errormessage) parameter for the schema which can be used to create custom error messages. (@mirpedrol) 127 | - Samplesheet validation now happens in `validateParameters()` using the schema specified by the `schema` parameter in the parameters schema. (@mirpedrol) 128 | 129 | ### Improvements 130 | 131 | - The `meta` maps are now immutable by default, see [`ImmutableMap`](https://nextflow-io.github.io/nf-validation/samplesheets/immutable_map/) for more info (@nvnieuwk) 132 | - `validateAndConvertSamplesheet()` has been renamed to `fromSamplesheet()` 133 | - Refactor `--schema_ignore_params` to `--validationSchemaIgnoreParams` 134 | 135 | ### Bug fixes 136 | 137 | - Fixed a bug where an empty meta map would be created when no meta values are in the samplesheet schema. (@nvnieuwk) 138 | 139 | ## Version 0.1.0 140 | 141 | Initial release. 142 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | config ?= compileClasspath 3 | 4 | ifdef module 5 | mm = :${module}: 6 | else 7 | mm = 8 | endif 9 | 10 | clean: 11 | ./gradlew clean 12 | 13 | compile: 14 | ./gradlew compileGroovy 15 | @echo "DONE `date`" 16 | 17 | 18 | check: 19 | ./gradlew check 20 | 21 | 22 | # 23 | # Show dependencies try `make deps config=runtime`, `make deps config=google` 24 | # 25 | deps: 26 | ./gradlew -q ${mm}dependencies --configuration ${config} 27 | 28 | deps-all: 29 | ./gradlew -q dependencyInsight --configuration ${config} --dependency ${module} 30 | 31 | # 32 | # Refresh SNAPSHOTs dependencies 33 | # 34 | refresh: 35 | ./gradlew --refresh-dependencies 36 | 37 | # 38 | # Run all tests or selected ones 39 | # 40 | test: 41 | ifndef class 42 | ./gradlew ${mm}test 43 | else 44 | ./gradlew ${mm}test --tests ${class} 45 | endif 46 | 47 | 48 | 49 | # 50 | # Upload JAR artifacts to Maven Central 51 | # 52 | upload: 53 | ./gradlew upload 54 | 55 | 56 | upload-plugins: 57 | ./gradlew plugins:upload 58 | 59 | publish-index: 60 | ./gradlew plugins:publishIndex -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![nf-validation](docs/images/nf-validation.svg) 2 | 3 | **A Nextflow plugin to work with validation of pipeline parameters and sample sheets.** 4 | 5 | 6 | > [!IMPORTANT] 7 | > # `nf-validation` has now been renamed to `nf-schema`. 8 | > **The `nf-validation` plugin will not receive any future updates.** 9 | > **Please update your pipelines to use [`nf-schema`](https://github.com/nextflow-io/nf-schema) instead.** 10 | > 11 | > See for details. 12 | > 13 | > This change was necessary to prevent older versions of `nf-core` pipelines from with unpinned plugin references from breaking when updating to the latest version of `nf-validation`. 14 | > **Please pin the version of `nf-schema` in your pipeline's `nextflow.config` file:** 15 | > ```nextflow 16 | > plugins { id 'nf-schema@2.0.0' } 17 | > ``` 18 | 19 | ## Introduction 20 | 21 | This [Nextflow plugin](https://www.nextflow.io/docs/latest/plugins.html#plugins) provides a number of functions that can be included into a Nextflow pipeline script to work with parameter and sample sheet schema. Using these functions you can: 22 | 23 | - 📖 Print usage instructions to the terminal (for use with `--help`) 24 | - ✍️ Print log output showing parameters with non-default values 25 | - ✅ Validate supplied parameters against the pipeline schema 26 | - 📋 Validate the contents of supplied sample sheet files 27 | - 🛠️ Create a Nextflow channel with a parsed sample sheet 28 | 29 | Supported sample sheet formats are CSV, TSV and YAML (simple). 30 | 31 | ## Quick Start 32 | 33 | Declare the plugin in your Nextflow pipeline configuration file: 34 | 35 | ```groovy title="nextflow.config" 36 | plugins { 37 | id 'nf-validation' 38 | } 39 | ``` 40 | 41 | This is all that is needed - Nextflow will automatically fetch the plugin code at run time. 42 | 43 | > [!NOTE] 44 | > The snippet above will always try to install the latest version, good to make sure 45 | > that the latest bug fixes are included! However, this can cause difficulties if running 46 | > offline. You can pin a specific release using the syntax `nf-validation@0.3.2` 47 | 48 | You can now include the plugin helper functions into your Nextflow pipeline: 49 | 50 | ```groovy title="main.nf" 51 | include { validateParameters; paramsHelp; paramsSummaryLog; fromSamplesheet } from 'plugin/nf-validation' 52 | 53 | // Print help message, supply typical command line usage for the pipeline 54 | if (params.help) { 55 | log.info paramsHelp("nextflow run my_pipeline --input input_file.csv") 56 | exit 0 57 | } 58 | 59 | // Validate input parameters 60 | validateParameters() 61 | 62 | // Print summary of supplied parameters 63 | log.info paramsSummaryLog(workflow) 64 | 65 | // Create a new channel of metadata from a sample sheet 66 | // NB: `input` corresponds to `params.input` and associated sample sheet schema 67 | ch_input = Channel.fromSamplesheet("input") 68 | ``` 69 | 70 | ## Dependencies 71 | 72 | - Java 11 or later 73 | - 74 | 75 | ## Slack channel 76 | 77 | There is a dedicated [nf-validation Slack channel](https://nfcore.slack.com/archives/C056RQB10LU) in the [Nextflow Slack workspace](nextflow.slack.com). 78 | 79 | ## Credits 80 | 81 | This plugin was written based on code initially written within the nf-core community, 82 | as part of the nf-core pipeline template. 83 | 84 | We would like to thank the key contributors who include (but are not limited to): 85 | 86 | - Júlia Mir Pedrol ([@mirpedrol](https://github.com/mirpedrol)) 87 | - Nicolas Vannieuwkerke ([@nvnieuwk](https://github.com/nvnieuwk)) 88 | - Kevin Menden ([@KevinMenden](https://github.com/KevinMenden)) 89 | - Phil Ewels ([@ewels](https://github.com/ewels)) 90 | -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | plugins { 6 | // Support convention plugins written in Groovy. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build. 7 | id 'groovy-gradle-plugin' 8 | } 9 | 10 | repositories { 11 | // Use the plugin portal to apply community plugins in convention plugins. 12 | gradlePluginPortal() 13 | } 14 | 15 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/io.nextflow.groovy-application-conventions.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | plugins { 6 | // Apply the common convention plugin for shared build configuration between library and application projects. 7 | id 'io.nextflow.groovy-common-conventions' 8 | 9 | // Apply the application plugin to add support for building a CLI application in Java. 10 | id 'application' 11 | } 12 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/io.nextflow.groovy-common-conventions.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | plugins { 6 | // Apply the groovy Plugin to add support for Groovy. 7 | id 'groovy' 8 | } 9 | 10 | repositories { 11 | // Use Maven Central for resolving dependencies. 12 | mavenCentral() 13 | } 14 | 15 | java { 16 | toolchain { 17 | languageVersion = JavaLanguageVersion.of(17) 18 | } 19 | } 20 | 21 | compileJava { 22 | options.release.set(11) 23 | } 24 | 25 | tasks.withType(GroovyCompile) { 26 | sourceCompatibility = '11' 27 | targetCompatibility = '11' 28 | } 29 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/io.nextflow.groovy-library-conventions.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | plugins { 6 | // Apply the common convention plugin for shared build configuration between library and application projects. 7 | id 'io.nextflow.groovy-common-conventions' 8 | // Apply the java-library plugin for API and implementation separation. 9 | id 'java-library' 10 | } 11 | 12 | -------------------------------------------------------------------------------- /docs/background.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Background 3 | description: Get up and running with nf-validation 4 | hide: 5 | - toc 6 | --- 7 | 8 | # Background 9 | 10 | The [Nextflow](https://nextflow.io/) workflow manager is a powerful tool for scientific workflows. 11 | In order for end users to launch a given workflow with different input data and varying settings, pipelines are developed using a special variable type called parameters (`params`). Defaults are hardcoded into scripts and config files but can be overwritten by user config files and command-line flags (see the [Nextflow docs](https://nextflow.io/docs/latest/config.html)). 12 | 13 | In addition to config params, a common best-practice for pipelines is to use a "sample sheet" file containing required input information. For example: a sample identifier, filenames and other sample-level metadata. 14 | 15 | Nextflow itself does not provide functionality to validate config parameters or parsed sample sheets. To bridge this gap, we developed code within the [nf-core community](https://nf-co.re/) to allow pipelines to work with a standard `nextflow_schema.json` file, written using the [JSON Schema](https://json-schema.org/) format. The file allows strict typing of parameter variables and inclusion of validation rules. 16 | 17 | The nf-validation plugin moves this code out of the nf-core template into a stand-alone package, to make it easier to use for the wider Nextflow community. It also incorporates a number of new features, such as native Groovy sample sheet validation. 18 | -------------------------------------------------------------------------------- /docs/contributing/setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contribution instructions 3 | description: How to contribute to nf-validation 4 | --- 5 | 6 | # Getting started with plugin development 7 | 8 | ## Compiling 9 | 10 | To compile and run the tests use the following command: 11 | 12 | ```bash 13 | ./gradlew check 14 | ``` 15 | 16 | ## Launch it with Nextflow 17 | 18 | To test with Nextflow for development purpose: 19 | 20 | Clone the Nextflow repo into a sibling directory 21 | 22 | ```bash 23 | cd .. && git clone https://github.com/nextflow-io/nextflow 24 | cd nextflow && ./gradlew exportClasspath 25 | ``` 26 | 27 | Append to the `settings.gradle` in this project the following line: 28 | 29 | ```bash 30 | includeBuild('../nextflow') 31 | ``` 32 | 33 | Compile the plugin code 34 | 35 | ```bash 36 | ./gradlew compileGroovy 37 | ``` 38 | 39 | Run nextflow with this command: 40 | 41 | ```bash 42 | ./launch.sh run -plugins nf-validation