-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use newest software version handler
- Loading branch information
Showing
7 changed files
with
226 additions
and
56 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
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
18 changes: 18 additions & 0 deletions
18
modules/nf-core/custom/dumpsoftwareversions/custom-dumpsoftwareversions.diff
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,18 @@ | ||
Changes in module 'nf-core/custom/dumpsoftwareversions' | ||
--- modules/nf-core/custom/dumpsoftwareversions/main.nf | ||
+++ modules/nf-core/custom/dumpsoftwareversions/main.nf | ||
@@ -2,10 +2,10 @@ | ||
label 'process_single' | ||
|
||
// Requires `pyyaml` which does not have a dedicated container but is in the MultiQC container | ||
- conda "bioconda::multiqc=1.15" | ||
+ conda (params.enable_conda ? "bioconda::multiqc=1.15" : null) | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/multiqc:1.15--pyhdfd78af_0' : | ||
- 'biocontainers/multiqc:1.15--pyhdfd78af_0' }" | ||
+ 'quay.io/biocontainers/multiqc:1.15--pyhdfd78af_0' }" | ||
|
||
input: | ||
path versions | ||
|
||
************************************************************ |
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,24 @@ | ||
process CUSTOM_DUMPSOFTWAREVERSIONS { | ||
label 'process_single' | ||
|
||
// Requires `pyyaml` which does not have a dedicated container but is in the MultiQC container | ||
conda (params.enable_conda ? "bioconda::multiqc=1.15" : null) | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/multiqc:1.15--pyhdfd78af_0' : | ||
'quay.io/biocontainers/multiqc:1.15--pyhdfd78af_0' }" | ||
|
||
input: | ||
path versions | ||
|
||
output: | ||
path "software_versions.yml" , emit: yml | ||
path "software_versions_mqc.yml", emit: mqc_yml | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def args = task.ext.args ?: '' | ||
template 'dumpsoftwareversions.py' | ||
} |
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,36 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json | ||
name: custom_dumpsoftwareversions | ||
description: Custom module used to dump software versions within the nf-core pipeline template | ||
keywords: | ||
- custom | ||
- dump | ||
- version | ||
tools: | ||
- custom: | ||
description: Custom module used to dump software versions within the nf-core pipeline template | ||
homepage: https://github.com/nf-core/tools | ||
documentation: https://github.com/nf-core/tools | ||
licence: ["MIT"] | ||
input: | ||
- versions: | ||
type: file | ||
description: YML file containing software versions | ||
pattern: "*.yml" | ||
|
||
output: | ||
- yml: | ||
type: file | ||
description: Standard YML file containing software versions | ||
pattern: "software_versions.yml" | ||
- mqc_yml: | ||
type: file | ||
description: MultiQC custom content YML file containing software versions | ||
pattern: "software_versions_mqc.yml" | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
authors: | ||
- "@drpatelh" | ||
- "@grst" |
101 changes: 101 additions & 0 deletions
101
modules/nf-core/custom/dumpsoftwareversions/templates/dumpsoftwareversions.py
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,101 @@ | ||
#!/usr/bin/env python | ||
|
||
|
||
"""Provide functions to merge multiple versions.yml files.""" | ||
|
||
|
||
import yaml | ||
import platform | ||
from textwrap import dedent | ||
|
||
|
||
def _make_versions_html(versions): | ||
"""Generate a tabular HTML output of all versions for MultiQC.""" | ||
html = [ | ||
dedent( | ||
"""\\ | ||
<style> | ||
#nf-core-versions tbody:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} | ||
</style> | ||
<table class="table" style="width:100%" id="nf-core-versions"> | ||
<thead> | ||
<tr> | ||
<th> Process Name </th> | ||
<th> Software </th> | ||
<th> Version </th> | ||
</tr> | ||
</thead> | ||
""" | ||
) | ||
] | ||
for process, tmp_versions in sorted(versions.items()): | ||
html.append("<tbody>") | ||
for i, (tool, version) in enumerate(sorted(tmp_versions.items())): | ||
html.append( | ||
dedent( | ||
f"""\\ | ||
<tr> | ||
<td><samp>{process if (i == 0) else ''}</samp></td> | ||
<td><samp>{tool}</samp></td> | ||
<td><samp>{version}</samp></td> | ||
</tr> | ||
""" | ||
) | ||
) | ||
html.append("</tbody>") | ||
html.append("</table>") | ||
return "\\n".join(html) | ||
|
||
|
||
def main(): | ||
"""Load all version files and generate merged output.""" | ||
versions_this_module = {} | ||
versions_this_module["${task.process}"] = { | ||
"python": platform.python_version(), | ||
"yaml": yaml.__version__, | ||
} | ||
|
||
with open("$versions") as f: | ||
versions_by_process = yaml.load(f, Loader=yaml.BaseLoader) | versions_this_module | ||
|
||
# aggregate versions by the module name (derived from fully-qualified process name) | ||
versions_by_module = {} | ||
for process, process_versions in versions_by_process.items(): | ||
module = process.split(":")[-1] | ||
try: | ||
if versions_by_module[module] != process_versions: | ||
raise AssertionError( | ||
"We assume that software versions are the same between all modules. " | ||
"If you see this error-message it means you discovered an edge-case " | ||
"and should open an issue in nf-core/tools. " | ||
) | ||
except KeyError: | ||
versions_by_module[module] = process_versions | ||
|
||
versions_by_module["Workflow"] = { | ||
"Nextflow": "$workflow.nextflow.version", | ||
"$workflow.manifest.name": "$workflow.manifest.version", | ||
} | ||
|
||
versions_mqc = { | ||
"id": "software_versions", | ||
"section_name": "${workflow.manifest.name} Software Versions", | ||
"section_href": "https://github.com/${workflow.manifest.name}", | ||
"plot_type": "html", | ||
"description": "are collected at run time from the software output.", | ||
"data": _make_versions_html(versions_by_module), | ||
} | ||
|
||
with open("software_versions.yml", "w") as f: | ||
yaml.dump(versions_by_module, f, default_flow_style=False) | ||
with open("software_versions_mqc.yml", "w") as f: | ||
yaml.dump(versions_mqc, f, default_flow_style=False) | ||
|
||
with open("versions.yml", "w") as f: | ||
yaml.dump(versions_this_module, f, default_flow_style=False) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.