Skip to content

Refactor: Extract software version collection boilerplate into shared functionΒ #139

Description

@cmkobel

Summary

The pattern for writing software version info to .software_version.txt is copy-pasted across 25+ shell blocks in rule files (sample_annotation.smk, sample_advanced_annotation.smk, batch_advanced_annotation.smk, batch_quality_control.smk, batch_phylogeny.smk, etc.).

A typical instance looks like:

echo -e "tool_name\t$(tool --version)" > "$(dirname {output})/.software_version.txt"

Similarly, the database version collection pattern (echo -e "$(date -Iseconds)\t$(dirname {input.database_representative})"...) appears in ~6 places.

Proposed approach

Extract a shared shell function (or Snakemake wrapper/macro) that takes the tool name, version command, and output path. This would:

  • Reduce duplication across rule files
  • Prevent bugs when one copy is updated but others aren't
  • Make it easier to change the version reporting format globally

Files to touch

  • workflow/rules/sample_annotation.smk (lines ~139, 181–182)
  • workflow/rules/sample_advanced_annotation.smk (lines ~20–21, 56, 107–110, 184–185, 296–299)
  • workflow/rules/batch_advanced_annotation.smk (lines ~15–16, 57–61)
  • workflow/rules/batch_quality_control.smk (lines ~42, 44–45)
  • workflow/rules/batch_phylogeny.smk (lines ~18, 47, 58–61, 81, 115, 150)
  • Plus others β€” grep for .software_version.txt to find all instances

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions