Skip to content

Refactor: HOGs store the name of their taxonomic level, not the ete3 node - #127

Open
alpae wants to merge 1 commit into
devfrom
refactor/hog-taxon-names
Open

alpae wants to merge 1 commit into
devfrom
refactor/hog-taxon-names

Conversation

@alpae

@alpae alpae commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Second part of #115: an output-neutral refactor. The fix itself is in #126.

Change

  • HOG only stores the name of its taxonomic level (taxname) instead of a node of the pruned working species tree (_tax_now).
    • The constructor still accepts a node and takes its name.
    • The taxlevel property is removed.
  • to_orthoxml(species_tree, …) now requires the tree in which TaxRange and the scores are computed. The pipeline always passed the full species tree. The fallbacks to the HOG's own node are removed, both in to_orthoxml() and in the root-level wrapper of read_infer_xml_rhog.
  • The score calculation, split_hog, and the HOGs created in singletone_hog_ / merge_subhogs use the name.

Why

  • Every per-level pickle carried a copy of the species tree, and comparing nodes across those copies was the cause of ImpliedLosses score is wrong: species tree nodes are compared by identity #115.
  • HOGs no longer hold ete3 objects, which reduces the surface of the ete4 migration. Ete3 is still used by the species-tree handling (prepare_species_tree, LevelHOGProcessor) and for gene trees.
  • Smaller per-level pickles: for the fungi-30 rootHOG F0848191, 4.58 MB instead of 6.30 MB (−27%). Most of the remaining size is the MSAs carried by the HOGs.

No output change

  • Golden snapshots regenerated in dessimozlab/fastoma:dev: no diff.
  • nf-tests default and options pass locally with unchanged snapshots.
  • Fast pytest suite green (346 passed).
  • New test test_hog_stores_only_the_name_of_its_level: a pickled HOG contains no ete3 objects. It fails with the old code.

Refs #115

🤖 Generated with Claude Code

…node

HOG._tax_now referenced a node of the pruned working species tree, so every
per-level pickle carried a copy of the species tree, and code comparing those
nodes across copies was wrong (see #115). HOGs now only store the level's name
(taxname); the constructor still accepts a node and takes its name. The
taxlevel property is removed.

to_orthoxml() now requires the species tree in which TaxRange and the scores
are computed (the pipeline always passed the full species tree); the fallbacks
to the HOG's own node in to_orthoxml() and in the root-level wrapper of
read_infer_xml_rhog are gone.

No output change: the golden snapshots and the nf-test snapshots are
unchanged. The per-level pickles of the fungi-30 rootHOG F0848191 shrink from
6.30 MB to 4.58 MB. Fewer ete3 objects held by HOGs also reduces the surface of
the ete4 migration.

Refs #115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alpae
alpae requested a balanced review from Copilot November 5, 2026 08:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants