Merge branch 'versions' into 'dev'

Add version report

See merge request epi2melabs/workflow-containers/wf-template!12
This commit is contained in:
Chris Wright 2021-04-29 14:52:21 +01:00
commit 0e12112439
3 changed files with 58 additions and 18 deletions

37
bin/conda_versions.py Normal file
View File

@ -0,0 +1,37 @@
"""Scrape versions of conda packages."""
from collections import namedtuple
import subprocess
try:
import pandas as pd
except ImportError:
pass
PackageInfo = namedtuple(
'PackageInfo', ('Name', 'Version', 'Build', 'Channel'))
def scrape_data(as_dataframe=False, include=None):
"""Return versions of conda packages in base environment."""
cmd = """
. ~/conda/etc/profile.d/mamba.sh;
micromamba activate;
micromamba list;
"""
proc = subprocess.run(cmd, shell=True, check=True, capture_output=True)
versions = dict()
for line in proc.stdout.splitlines()[3:]:
items = line.decode().strip().split()
if len(items) == 3:
# sometimes channel isn't listed :/
items.append("")
if include is None or items[0] in include:
versions[items[0]] = PackageInfo(*items)
if as_dataframe:
versions = pd.DataFrame.from_records(
list(versions.values()),
columns=PackageInfo._fields)
return versions

View File

@ -4,7 +4,8 @@
import argparse import argparse
from aplanat.components import fastcat from aplanat.components import fastcat
from aplanat.report import HTMLReport from aplanat.report import WFReport
import conda_versions
def main(): def main():
@ -12,29 +13,31 @@ def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("report", help="Report output file") parser.add_argument("report", help="Report output file")
parser.add_argument("summaries", nargs='+', help="Read summary file.") parser.add_argument("summaries", nargs='+', help="Read summary file.")
parser.add_argument(
"--revision", default='unknown',
help="git branch/tag of the executed workflow")
parser.add_argument(
"--commit", default='unknown',
help="git commit of the executed workflow")
args = parser.parse_args() args = parser.parse_args()
report = HTMLReport( report = WFReport(
"Workflow Template Sequencing report", "Workflow Template Sequencing report", "wf-template",
("Results generated through the wf-template nextflow " revision=args.revision, commit=args.commit)
"workflow by Oxford Nanopore Technologies"))
report.add_section( report.add_section(
section=fastcat.full_report(args.summaries)) section=fastcat.full_report(args.summaries))
report.markdown(''' section = report.add_section()
### About section.markdown('''
### Software versions
**Oxford Nanopore Technologies products are not intended for use for health The table below highlights versions of key software used within the analysis.
assessment or to diagnose, treat, mitigate, cure or prevent any disease or
condition.**
This report was produced using the
[epi2me-labs/wf-template](https://github.com/epi2me-labs/wf-template). The
workflow can be run using `nextflow epi2me-labs/wf-template --help`
---
''') ''')
req = [
'python', 'aplanat', 'pysam', 'fastcat']
versions = conda_versions.scrape_data(
as_dataframe=True, include=req)
section.table(versions[['Name', 'Version', 'Build']], index=False)
# write report # write report
report.write(args.report) report.write(args.report)

View File

@ -5,7 +5,7 @@ channels:
- conda-forge - conda-forge
- defaults - defaults
dependencies: dependencies:
- python==3.6.* - python==3.8.*
- aplanat >=0.3.5 - aplanat >=0.3.5
- pysam - pysam
- fastcat - fastcat