High-level description

This directory contains unit tests for various solver algorithms and utility functions used in the Cassiopeia package for phylogenetic tree reconstruction. The tests cover a wide range of solvers, including Neighbor Joining, ILP, Greedy, Spectral, and UPGMA solvers, as well as dissimilarity functions and other utilities.

What does it do?

The test suite in this directory verifies the correctness and robustness of different phylogenetic tree reconstruction algorithms implemented in Cassiopeia. It tests various aspects of these solvers, including:

  1. Tree construction from character matrices
  2. Handling of missing data and ambiguous states
  3. Computation of dissimilarity/similarity measures
  4. Graph construction and manipulation
  5. Specific algorithm steps (e.g., cherry picking in Neighbor Joining)
  6. Integration with different types of input data and configurations

These tests ensure that the solvers produce accurate phylogenetic trees under various scenarios and input conditions, maintaining the reliability of the Cassiopeia package for lineage reconstruction tasks.

Entry points

The main entry points for this test suite are the individual test files, each focusing on a specific solver or utility:

  1. ccphylo_solver_test.py: Tests CCPhylo solver implementations
  2. dissimilarity_functions_test.py: Tests dissimilarity and similarity functions
  3. greedy_variants_test.py: Tests variants of the greedy solver algorithm
  4. hybrid_solver_test.py: Tests the hybrid solver combining multiple algorithms
  5. ilp_solver_test.py: Tests the Integer Linear Programming solver
  6. maxcut_test.py: Tests the MaxCut solver
  7. neighborjoining_solver_test.py: Tests the Neighbor Joining solver
  8. percolation_test.py: Tests the Percolation solver
  9. sharedmutationjoiner_test.py: Tests the Shared Mutation Joining solver
  10. snj_solver_test.py: Tests the Spectral Neighbor Joining solver
  11. spectral_test.py: Tests the Spectral solver
  12. upgma_test.py: Tests the UPGMA solver
  13. vanillagreedy_test.py: Tests the Vanilla Greedy solver

Each test file contains a main test class that inherits from unittest.TestCase and includes multiple test methods covering different aspects of the respective solver or utility.

Key Files

While all test files are important, some key files that cover core functionality include:

  1. neighborjoining_solver_test.py: Tests the widely-used Neighbor Joining algorithm
  2. ilp_solver_test.py: Tests the Integer Linear Programming solver, which can provide optimal solutions for smaller datasets
  3. dissimilarity_functions_test.py: Tests critical dissimilarity and similarity functions used across multiple solvers
  4. hybrid_solver_test.py: Tests the hybrid solver that combines multiple algorithms, representing a more advanced approach

Dependencies

The test suite relies on several external libraries and frameworks:

  1. unittest: Provides the testing framework
  2. networkx: Used for graph operations and tree representation
  3. numpy: Used for numerical operations and array manipulations
  4. pandas: Used for data manipulation and character matrix representation
  5. scipy: Used for scientific computing and optimization
  6. mock: Used for creating mock objects in tests
  7. gurobipy (optional): Used for ILP solving in some tests

The tests also depend on various modules from the Cassiopeia package itself.

Configuration

Some tests may require specific configurations:

  1. CCPhylo tests check for the existence of a config.ini file and a ccphylo_path setting.
  2. ILP solver tests may be skipped if Gurobi is not installed.

The tests use various helper functions, such as find_triplet_structure, to assist in verifying tree structures and comparing results across different solvers.

In summary, this test suite provides comprehensive coverage of the phylogenetic tree reconstruction algorithms implemented in Cassiopeia, ensuring their correctness and reliability across a wide range of scenarios and input conditions.