Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read version info from nf-core/demultiplex version file #57

Merged
merged 6 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions bin/get_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import argparse
import os
import json
from pathlib import Path
import yaml


class RunfolderInfo:
Expand Down Expand Up @@ -82,6 +84,14 @@ def get_bcl2fastq_version(self, runfolder):
bcl2fastq_str = f.read()
return bcl2fastq_str.split("v")[1].strip()

def get_software_version(self, runfolder):
with open(Path(runfolder) / "pipeline_info" / "software_versions.yml") as f:
return {
software: version
for software_dict in yaml.safe_load(f).values()
for software, version in software_dict.items()
}

def get_run_parameters(self):
results = OrderedDict()
for key, value in self.run_parameters_tags.items():
Expand Down Expand Up @@ -116,10 +126,26 @@ def get_info(self):
flowcell_type = self.find_flowcell_type_novaseqx()
if flowcell_type:
results.update(flowcell_type)
if os.path.exists(os.path.join(self.runfolder, "bcl2fastq_version")):
results["bcl2fastq version"] = self.get_bcl2fastq_version(self.runfolder)

return results

def get_demultiplexing_info(self):
try:
return {
"Demultiplexing": {
"bcl2fastq": self.get_bcl2fastq_version(self.runfolder)
}
}
except FileNotFoundError:
pass

try:
return {"Demultiplexing": self.get_software_version(self.runfolder)}
except FileNotFoundError:
pass

return {}


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Dumps a metadata yaml for MultiQC")
Expand All @@ -138,7 +164,7 @@ def get_info(self):
bcl2fastq_outdir = args.bcl2fastq_outdir

runfolder_info = RunfolderInfo(runfolder, bcl2fastq_outdir)
results = runfolder_info.get_info()
info = runfolder_info.get_info()

print(
"""
Expand All @@ -150,6 +176,11 @@ def get_info(self):
<dl class="dl-horizontal">
"""
)
for k, v in results.items():
print(" <dt>{}</dt><dd><samp>{}</samp></dd>".format(k, v))
for k, v in info.items():
print(f" <dt>{k}</dt><dd><samp>{v}</samp></dd>")

print(" <dt>Demultiplexing</dt>")
for software, version in runfolder_info.get_demultiplexing_info().items():
print(f" <dd>{software}: <samp>{version}</samp></dd>")

print(" </dl>")
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BCL2FASTQ:
bcl2fastq: 2.20.0.422
CUSTOM_DUMPSOFTWAREVERSIONS:
python: 3.12.0
yaml: 6.0.1
Workflow:
Nextflow: 23.04.3
nf-core/demultiplex: 1.5.0dev
16 changes: 15 additions & 1 deletion tests/unit_tests/test_get_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ def test_bcl2fastq_version(runfolder_info):
assert bcl2fastq_version == "2.20.0.422"


def test_get_software_version(runfolder_info):
software_versions = runfolder_info.get_software_version(
"test_data/210510_M03910_0104_000000000-JHGJL"
)

assert software_versions == {
"bcl2fastq": "2.20.0.422",
"python": "3.12.0",
"yaml": "6.0.1",
"Nextflow": "23.04.3",
Aratz marked this conversation as resolved.
Show resolved Hide resolved
"nf-core/demultiplex": "1.5.0dev",
}


def test_get_run_parameters(runfolder_info):
filtered_run_parameters = runfolder_info.get_run_parameters()
assert len(filtered_run_parameters) == 5
Expand Down Expand Up @@ -95,4 +109,4 @@ def test_get_read_cycles(runfolder_info):

def test_get_info(runfolder_info):
results = runfolder_info.get_info()
assert len(results) == 10
assert len(results) == 9
Loading