Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: Run Linting
on:
pull_request:
branches: [main, develop, release/*]

# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
NXF_SINGULARITY_CACHEDIR: ${{ github.workspace }}/.singularity
NXF_SINGULARITY_LIBRARYDIR: ${{ github.workspace }}/.singularity
NXF_VER: "25.10.2"
NXF_SYNTAX_PARSER: "v2"

jobs:
###################
# nf-core linting #
###################
nf-core-changes:
name: nf-core-changes
runs-on: ubuntu-latest

outputs:
# https://github.com/dorny/paths-filter?tab=readme-ov-file#custom-processing-of-changed-files
modules: ${{ steps.filter.outputs.modules }}
modules_files: ${{ steps.module_names.outputs.result }}
subworkflows: ${{ steps.filter.outputs.subworkflows }}
subworkflows_files: ${{ steps.subworkflow_names.outputs.result }}
steps:
- name: Clean workspace
run: |
sudo rm -rf ./* || true
sudo rm -rf ./.* || true

- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 2 # To retrieve the preceding commit.

- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
id: filter
with:
filters: |
modules:
- added|modified: 'modules/UMCUGenetics/**'
subworkflows:
- added|modified: 'subworkflows/UMCUGenetics/**'
token: ""
list-files: "json"

- name: Get module name
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
id: module_names
with:
script: |
return [...new Set(${{ steps.filter.outputs.modules_files }}
.filter(x => x.endsWith('main.nf') || x.endsWith('.nf.test.snap'))
.map(path => path
.replace('modules/UMCUGenetics/', '')
.replace(/\/(main\.nf|tests\/.*)$/, '')
)
)];
- name: Get subworkflow name
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
id: subworkflow_names
with:
script: |
return [...new Set(${{ steps.filter.outputs.subworkflows_files }}
.filter(x => x.endsWith('main.nf') || x.endsWith('.nf.test.snap'))
.map(path => path
.replace('subworkflows/UMCUGenetics/', '')
.replace(/\/(main\.nf|tests\/.*)$/, '')
)
)];

- name: debug
run: |
echo ${{ steps.filter.outputs.modules_files }}
echo ${{ steps.module_names.outputs.result }}
echo ${{ steps.filter.outputs.subworkflows_files }}
echo ${{ steps.subworkflow_names.outputs.result }}

nf-core-lint-modules:
runs-on: ubuntu-latest
name: nf-core lint modules
needs: nf-core-changes
if: ${{ needs.nf-core-changes.outputs.modules_files != '[]' }}
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.nf-core-changes.outputs.modules_files || '[]') }}
steps:
- name: Clean workspace
run: |
sudo rm -rf ./* || true
sudo rm -rf ./.* || true
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"

- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: |
${{ runner.os }}-pip

- name: Install pip
run: python -m pip install --upgrade pip

- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: "temurin"
java-version: "17"

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

- name: Install nf-core tools development version
run: python -m pip install --upgrade --force-reinstall git+https://github.com/UMCUGenetics/nf-core-tools.git

- name: Lint module ${{ matrix.module }}
run: nf-core modules lint ${{ matrix.module }}

nf-core-lint-subworkflows:
runs-on: ubuntu-latest
name: nf-core lint subworkflows
needs: nf-core-changes
if: ${{ needs.nf-core-changes.outputs.subworkflows_files != '[]' }}
strategy:
fail-fast: false
matrix:
subworkflow: ${{ fromJson(needs.nf-core-changes.outputs.subworkflows_files || '[]') }}
steps:
- name: Clean workspace
run: |
sudo rm -rf ./* || true
sudo rm -rf ./.* || true
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"

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

- name: Install nf-core tools development version
run: python -m pip install --upgrade --force-reinstall git+https://github.com/UMCUGenetics/nf-core-tools.git

- name: Lint subworkflow ${{ matrix.subworkflow }}
run: nf-core subworkflows lint ${{ matrix.subworkflow }}

confirm-pass-lint:
runs-on: ubuntu-latest
needs: [nf-core-lint-modules, nf-core-lint-subworkflows]
if: always()
steps:
- name: All tests ok
if: ${{ success() || !contains(needs.*.result, 'failure') }}
run: exit 0
- name: One or more tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

- name: debug-print
if: always()
run: |
echo "toJSON(needs) = ${{ toJSON(needs) }}"
echo "toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}"
10 changes: 10 additions & 0 deletions .nf-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
org_path: UMCUGenetics
repository_type: modules
lint:
main_nf:
- when_exist
- test_main_tags
- container_links
module_tests:
- test_main_tags
meta_yml: false
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Modules


## Repository Structure

``` sh
.
├── README.md
├── main.nf
└── modules
└── UMCUGenetics
```

Modules are placed under the `./modules/UMCUGenetics/` folder in the format tool/subtool. For example `./modules/UMCUGenetics/samtools/view/`


## Linting configuration
Note: A fork of the nf-core CLI tools is used to run the linting actions (https://github.com/UMCUGenetics/nf-core-tools.git). This was done to make the linting of modules more customisable. For our purposes not all requirements by nf-core are neccesary.
Linting configuration of this repository is configured in `.nf-core.yml` and is structured similarly to how `nf-core pipeline lint` configuration works (note that the tests in the yaml file are the ones being skipped, all the others are enabled). Usually, it is not neccessary to change this, but to view all available modules linting options:

``` sh
nf-core modules lint --list
```

Install the forked nf-core tools locally:

``` sh
pip install git+https://github.com/UMCUGenetics/nf-core-tools.git
```

### Github actions
Linting is triggered automatically upon creating a pull request through a github actions workflow [.github/workflows/lint.yml]. The actions workflow is adapted from the actions workflow used in the [nf-core/modules](https://github.com/nf-core/modules) repository, with mostly small changes that remove nf-core specific action runners.

### Running linting

Alternatively, linting test can be manually executed:

``` sh
cd ./modules
nf-core modules lint <tool/command>
# Example: nf-core modules lint pgscatalog/combine
```



## Testing configuration
TODO


## Using a module in a nextflow pipeline
Modules in this repository can be added to a pipeline similarly to how nf-core modules are installed.

``` sh
nf-core modules --git-remote https://github.com/UMCUGenetics/Modules install pgscatalog/combine
```
3 changes: 3 additions & 0 deletions main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
* not actually used - just a placeholder
*/
27 changes: 27 additions & 0 deletions modules/UMCUGenetics/pgscatalog/combine/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
process PGSCATALOG_COMBINE {
tag "${meta.id}"

container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://depot.galaxyproject.org/singularity/pgscatalog-utils:1.4.4--pyhdfd78af_0'
: 'biocontainers/pgscatalog-utils:1.4.4--pyhdfd78af_0'}"

input:
tuple val(meta), path(scoring_file)
val assembly_version

output:
tuple val(meta), path("*_normalised.txt.gz"), emit: normalised_model
path "versions.yml", emit: versions

script:
def prefix = task.ext.prefix ?: meta.id
"""
pgscatalog-combine \\
-s ${scoring_file} \\
-t ${assembly_version} \\
-o ${prefix}_normalised.txt.gz


echo "pgscatalog-combine: 1.4.4" > versions.yml
"""
}
27 changes: 27 additions & 0 deletions modules/UMCUGenetics/pgscatalog/combine/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
nextflow_process {
name "Test Process PGScatalog-combine"
script "../main.nf"
process "PGSCATALOG_COMBINE"

tag "modules/local"


test("Test Correct model formatting "){
when{
process{
"""
input[0] = [[id: 'model'],
file("${projectDir}/assets/models/BCAC_313_PRS_GRCh38.txt",
checkifExists: true)]
input[1] = channel.value("GRCh38")
"""
}

then {
assertAll(
{assert process.success},
)
}
}
}
}
42 changes: 42 additions & 0 deletions modules/UMCUGenetics/pgscatalog/match/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
process PGSCATALOG_MATCH {
tag "${meta.id}"

container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://depot.galaxyproject.org/singularity/pgscatalog-utils:1.4.4--pyhdfd78af_0'
: 'biocontainers/pgscatalog-utils:1.4.4--pyhdfd78af_0'}"

input:
tuple val(meta), path(pvar)
tuple val(meta2), path(scoring_file)


output:
tuple val(meta), path("*_summary.csv"), emit: summary
tuple val(meta), path("*.scorefile.gz"), emit: scorefile
tuple val(meta), path("*_log.csv.gz"), emit: log
path "versions.yml", emit: versions

script:
def prefix = task.ext.prefix ?: meta.id
def args = task.ext.args ?: ""
"""
pgscatalog-match \\
${args} \\
--dataset ${prefix} \\
--scorefiles ${scoring_file} \\
--target ${pvar} \\
--outdir ./

echo "pgscatalog-match: 1.4.4" > versions.yml
"""

stub:
def prefix = task.ext.prefix ?: "Cohort"
"""
touch ${prefix}_summary.csv
touch ${prefix}.scorefile.gz
touch ${prefix}_log.csv.gz

echo "pgscatalog-match: 1.4.4" > versions.yml
"""
}
Loading
Loading