Skip to content

Commit

Permalink
Merge branch 'revert_report' into 'dev'
Browse files Browse the repository at this point in the history
Fix report breaking

See merge request epi2melabs/workflows/wf-bacterial-genomes!110
  • Loading branch information
Christopher Alder committed Feb 8, 2024
2 parents 479d958 + 3a40c6c commit ac3f345
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.1.1]
### Fixed
- Report generation when `Resfinder` fails

## [v1.1.0]
### Added
- Sample results aggregated into `results.json`
Expand Down
22 changes: 17 additions & 5 deletions bin/workflow_glue/report.py
Expand Up @@ -84,7 +84,7 @@ def get_flye_stats(sample_names, flye_dir, flye_suffix):
return flye_out, samples_with_missing_files


def gather_sample_files(sample_names, denovo_mode, prokka_mode, isolates_mode):
def gather_sample_files(sample_names, denovo_mode, prokka_mode, isolates_mode, logger):
"""Collect files required for the report per sample and make sure they exist."""
sample_files = {}
subdirs_and_suffixes = {
Expand All @@ -108,13 +108,23 @@ def gather_sample_files(sample_names, denovo_mode, prokka_mode, isolates_mode):
file_type in ("total_depth", "fwd_depth", "rev_depth")
or (file_type == "variants" and not denovo_mode)
or (file_type == "prokka" and prokka_mode)
or (file_type in ("resfinder", "mlst") and isolates_mode)
):
if not os.path.exists(file):
raise ValueError(
f"Required file '{file_type}' missing "
f"for sample '{sample_name}'."
)
# these may not be produced as errorStrategy is set to "ignore"
elif (
file_type in ("resfinder", "mlst")
and isolates_mode
):
if not os.path.exists(file):
logger.error(
f"Isolates file for '{file_type}' missing "
f"for sample '{sample_name}' - Check status of analysis."
)
file = None
else:
# this covers the cases when files are not needed (e.g. `variants` when
# doing a de-novo assembly)
Expand Down Expand Up @@ -262,7 +272,7 @@ def get_indel_length_histogram(indel_lengths):
return p


def create_report(args):
def create_report(args, logger):
"""Create and populate Labs report."""
report = labs.LabsReport(
"Bacterial Genomes Summary Report",
Expand Down Expand Up @@ -325,7 +335,9 @@ def create_report(args):

# Gather stats files for each sample (will be used by the various report sections
# below)
sample_files = gather_sample_files(samples, args.denovo, args.prokka, args.isolates)
sample_files = gather_sample_files(
samples, args.denovo, args.prokka, args.isolates, logger
)

with report.add_section("Genome coverage", "Depth"):
html_tags.p(
Expand Down Expand Up @@ -513,7 +525,7 @@ def create_report(args):
def main(args):
"""Run the entry point."""
logger = get_named_logger("Report")
report = create_report(args)
report = create_report(args, logger)
report.write(args.output)
logger.info(f"Report written to {args.output}.")

Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Expand Up @@ -60,7 +60,7 @@ manifest {
description = 'Assembly, variant calling, and annotation of bacterial genomes.'
mainScript = 'main.nf'
nextflowVersion = '>=23.04.2'
version = 'v1.1.0'
version = 'v1.1.1'
}

epi2melabs {
Expand Down

0 comments on commit ac3f345

Please sign in to comment.