Skip to content

Add cached cd hit est reference collapse step to pathoscope#188

Merged
igboyes merged 11 commits into
virtool:mainfrom
ReeceHoffmann:reecehoffmann/vir-2534-add-cached-cd-hit-est-reference-collapse-step-to-pathoscope
Jul 15, 2026
Merged

Add cached cd hit est reference collapse step to pathoscope#188
igboyes merged 11 commits into
virtool:mainfrom
ReeceHoffmann:reecehoffmann/vir-2534-add-cached-cd-hit-est-reference-collapse-step-to-pathoscope

Conversation

@ReeceHoffmann

@ReeceHoffmann ReeceHoffmann commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds a cached preprocessing step that collapses redundant reference isolates with cd-hit-est before Pathoscope builds its mapping indexes.

  • Runs cd-hit-est at 99% identity for each OTU segment, with concurrency limited by the workflow processor count.
  • Writes the collapsed reference as a workflow SQLite index and preserves its reference metadata.
  • Caches the collapsed index using the source index ID, workflow version, cd-hit-est version, and collapse identity.
  • Builds the default-reference and candidate-isolate FASTAs from the collapsed index.
  • Adds cd-hit-est 4.8.1 to the workflow image.
  • Keeps reference-collapse logic in a dedicated reference.py module.

Collapse behavior

For eligible OTUs, sequences are clustered independently by segment. The collapsed reference:

  • always retains default isolates;
  • retains isolates containing default sequences;
  • retains the first isolate for each unique combination of segment cluster representatives.

OTUs with a single isolate are left unchanged. OTUs whose structure cannot be collapsed safely—such as invalid segment names, duplicate segments, or ambiguous unsegmented isolates are unchanged

- run cd-hit-est per segment with bounded concurrency

- keep each cd-hit-est process single-threaded so proc controls segment-level parallelism
- allow isolates to omit schema segments during reference collapse

- permit empty segment sentinels for unsegmented OTUs
@ReeceHoffmann
ReeceHoffmann marked this pull request as ready for review June 12, 2026 21:32
@ReeceHoffmann
ReeceHoffmann requested a review from igboyes as a code owner June 12, 2026 21:32

@igboyes igboyes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utils.py is turning into a pig and should be modularized.

Comment thread python/workflow_pathoscope/utils.py Outdated
Comment thread fixtures.py
Comment thread workflow.py Outdated
Comment thread workflow.py Outdated
Comment thread workflow.py Outdated
…into reecehoffmann/vir-2534-add-cached-cd-hit-est-reference-collapse-step-to-pathoscope

# Conflicts:
#	tests/test_workflow.py
- move reference collapse helpers out of general workflow utilities

- stop persisting collapse stats as a cache manifest
- preserve OTUs that cannot be safely collapsed and report per-outcome counts
- build explicit OTU fixtures for validation and mixed-result coverage
@ReeceHoffmann
ReeceHoffmann requested a review from igboyes July 15, 2026 19:47
@igboyes
igboyes merged commit 755c58d into virtool:main Jul 15, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.17.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants