Skip to content

Small internal bugs in HOG class, UnionFind, batching and orthoXML helpers #122

Open

Description

@alpae

Bugs in internal helpers that don't (yet) affect normal pipeline output, but are traps for upcoming changes, e.g. the fixes for #113 and the ete4 migration.

  • Representative(rep, elements) mutates rep: the copy constructor shares the _subelements / _species sets of rep and then extends them with |= (_hog_class.py:249-259). Representatives of the previous level silently grow.
  • HOG.find_representative calls the non-existent Representative.get_members (_hog_class.py:383): looking up a member that is not itself a representative raises AttributeError.
  • HOG.__init__ default representatives=Optional[List[Representative]] is a typing object, not None (_hog_class.py:280).
  • UnionFind.remove of a set's representative breaks find() for the other members (KeyError, zoo/unionfind.py:78). There are two copies of the class (zoo/unionfind.py, _utils_roothog.py:35).
  • batch_roothogs: files with the same name in different subfolders overwrite each other in a batch (shutil.copy, batch_roothogs.py:45). Not reachable with the current flat rootHOG folder, but nothing guards against it.
  • pairwise relations: an orthologGroup without children raises TypeError in set.union() (zoo/hog/transform.py:52).
  • prepare_species_tree for a single-species rootHOG returns the root with one child instead of the species leaf (get_common_ancestor({'A'}), _utils_subhog.py:283). That such rootHOGs produce no group is intended; the tree shape is only an internal oddity.
  • copy_tree discards the result of features.union(...) (_infer_subhog.py:752), so no features are copied. It works only because ete3 treats an empty set differently from an empty list in write(features=...).

Tests (strict xfail on PR #112)

  • tests/test_hog_class.py::test_representative_with_elements_does_not_mutate_source
  • tests/test_hog_class.py::test_find_representative_of_non_representative_member
  • tests/test_unionfind.py::test_remove_root (both copies)
  • tests/test_batch_roothogs.py::test_same_basename_in_subfolders_kept
  • tests/test_pairwise_relations.py::TestOrthoxmlRelations::test_empty_group_has_no_pairs
  • tests/test_species_tree_prep.py::test_prepare_species_tree_single_species

Activity

  1. added
    bugSomething isn't working
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions