diff --git a/bin/conda_versions.py b/bin/conda_versions.py deleted file mode 100644 index 367d4f6..0000000 --- a/bin/conda_versions.py +++ /dev/null @@ -1,49 +0,0 @@ -"""Scrape versions of conda packages.""" - -from collections import namedtuple -import os -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, version_dir=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 version_dir is not None: - for fname in os.listdir(version_dir): - print("Reading versions from file:", fname) - try: - with open(os.path.join(version_dir, fname), 'r') as fh: - for line in fh.readlines(): - name, version = line.strip().split(',') - versions[name] = PackageInfo(name, version, '', '') - except Exception as e: - print(e) - pass - if as_dataframe: - versions = pd.DataFrame.from_records( - list(versions.values()), - columns=PackageInfo._fields) - return versions diff --git a/bin/report.py b/bin/report.py index d3459b2..bd9a915 100755 --- a/bin/report.py +++ b/bin/report.py @@ -2,24 +2,17 @@ """Create report file.""" import argparse +import os from aplanat import annot, bars, hist, lines, report from aplanat.components import bcfstats, nextclade from aplanat.util import Colors from bokeh.layouts import gridplot, layout from bokeh.models import Panel, Range1d, Tabs -import conda_versions import numpy as np import pandas as pd -# software versions reported (from the environment where this script runs) -# TODO: pass all these through using --versions -software_versions = [ - 'np-artic', 'medaka', 'minimap2', 'bcftools', 'nextclade-cli', - 'samtools', 'bcftools'] - - def load_params(path): """Load the parameters csv into a dataframe.""" params_cols = ['Name', 'Value'] @@ -112,7 +105,7 @@ def main(): help="A csv containing the parameter key/values") parser.add_argument( "--versions", - help="CSV containing name,version for additional software versions.") + help="directory contained CSVs containing name,version.") args = parser.parse_args() report_doc = report.WFReport( @@ -363,10 +356,20 @@ def main(): The table below highlights versions of key software used within the analysis. ''') - versions = conda_versions.scrape_data( - as_dataframe=True, include=software_versions, - version_dir=args.versions) - section.table(versions[['Name', 'Version', 'Build']], index=False) + versions = list() + if args.versions is not None: + for fname in os.listdir(args.versions): + print("Reading versions from file:", fname) + try: + with open(os.path.join(args.versions, fname), 'r') as fh: + for line in fh.readlines(): + name, version = line.strip().split(',') + versions.append((name, version)) + except Exception as e: + print(e) + pass + versions = pd.DataFrame(versions, columns=('Name', 'Version')) + section.table(versions, index=False) # Params reporting section = report_doc.add_section() diff --git a/main.nf b/main.nf index a59d966..602486f 100644 --- a/main.nf +++ b/main.nf @@ -149,6 +149,23 @@ process combineGenotypeSummaries { } +process get_versions { + label "artic" + cpus 1 + output: + path "versions.txt" + script: + """ + medaka --version | sed 's/ /,/' >> versions.txt + minimap2 --version | sed 's/^/minimap2,/' >> versions.txt + bcftools --version | head -n 1 | sed 's/ /,/' >> versions.txt + samtools --version | head -n 1 | sed 's/ /,/' >> versions.txt + nextclade --version | sed 's/^/nextclade,/' >> versions.txt + artic --version | sed 's/ /,/' >> versions.txt + """ +} + + process report { label "artic" cpus 1 @@ -294,7 +311,7 @@ workflow pipeline { primers ref_variants main: - software_versions = Channel.empty() + software_versions = get_versions() combined_genotype_summary = null scheme_directory = copySchemeDir(scheme_directory) read_summaries = preArticQC(samples)