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
from aplanat.components import fastcat
from aplanat.report import HTMLReport
from aplanat.report import WFReport
import conda_versions
def main():
@ -12,29 +13,31 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("report", help="Report output 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()
report = HTMLReport(
"Workflow Template Sequencing report",
("Results generated through the wf-template nextflow "
"workflow by Oxford Nanopore Technologies"))
report = WFReport(
"Workflow Template Sequencing report", "wf-template",
revision=args.revision, commit=args.commit)
report.add_section(
section=fastcat.full_report(args.summaries))
report.markdown('''
### About
**Oxford Nanopore Technologies products are not intended for use for health
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`
---
section = report.add_section()
section.markdown('''
### Software versions
The table below highlights versions of key software used within the analysis.
''')
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
report.write(args.report)

View File

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