Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add subworfklow + schema for references #7412

Merged
merged 12 commits into from
Feb 6, 2025
13 changes: 13 additions & 0 deletions subworkflows/nf-core/utils_references/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Disclaimer

This `utils_references/` folder contains for now two functions and a schema.
This is really meant for a POC and should not be installed by anyone except @maxulysse.
But that was the easiest way to share functions and a schema between three different pipelines and still showcase the logic.
This might evolve in the future, possibly towards a proper plugin.

If you do so, please be aware that:

- @maxulysse has hacked the `main.nf` to test the functions and the schema
- This is really meant to evolve in the future and can be deleted at any moment without prior notice.

That being said, if you still want to use it or want to know more about it, please check the `#references` channel on the nf-core slack.
60 changes: 60 additions & 0 deletions subworkflows/nf-core/utils_references/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// DISCLAIMER:
// This subworkflow is just to test the functions and the schema
// It should not be used in any pipeline

// This include statement can also be deleted
include { samplesheetToList } from 'plugin/nf-schema'

workflow UTILS_REFERENCES {
take:
yaml_reference
param_file
param_value
attribute_file
attribute_value
basepath

main:
references = Channel.fromList(samplesheetToList(yaml_reference, "${projectDir}/subworkflows/nf-core/utils_references/schema_references.json"))

// GIVING up writing a test for the functions, so writing a subworkflow to test it
references_file = get_references_file(references, param_file, attribute_file, basepath)
references_value = get_references_value(references, param_value, attribute_value)

emit:
references_file
references_value
}
// You can delete everything before this line (including this line)

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNCTIONS TO EXTRACT REFERENCES FILES OR VALUES FROM THE REFERENCES YAML OR PARAMS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

def get_references_file(references, param, attribute, basepath) {
return references
.map { meta, _readme ->
if (param || meta[attribute]) {
[meta.subMap(['id']), file(param ?: meta[attribute].replace('${params.igenomes_base}', basepath), checkIfExists: true)]
}
else {
null
}
}
.collect()
}

def get_references_value(references, param, attribute) {
return references
.map { meta, _readme ->
if (param || meta[attribute]) {
[meta.subMap(['id']), param ?: meta[attribute]]
}
else {
null
}
}
.collect()
}
14 changes: 14 additions & 0 deletions subworkflows/nf-core/utils_references/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: "utils_references"
description: Functionality for dealing with references that may be useful for any Nextflow pipeline
keywords:
- utility
- pipeline
- references
components: []
input: []
maxulysse marked this conversation as resolved.
Show resolved Hide resolved
output: []
authors:
- "@maxulysse"
maintainers:
- "@maxulysse"
Loading
Loading