-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add subworfklow + schema for references (#7412)
* add subworfklow + schema for references * s3 -> https * no function tests * better function name * restore fake workflow for tests * add DISCLAIMER * better tests * use format: path
- Loading branch information
Showing
6 changed files
with
535 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] | ||
output: [] | ||
authors: | ||
- "@maxulysse" | ||
maintainers: | ||
- "@maxulysse" |
Oops, something went wrong.