Overview
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:
- Tree construction from character matrices
- Handling of missing data and ambiguous states
- Computation of dissimilarity/similarity measures
- Graph construction and manipulation
- Specific algorithm steps (e.g., cherry picking in Neighbor Joining)
- 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:
ccphylo_solver_test.py
: Tests CCPhylo solver implementationsdissimilarity_functions_test.py
: Tests dissimilarity and similarity functionsgreedy_variants_test.py
: Tests variants of the greedy solver algorithmhybrid_solver_test.py
: Tests the hybrid solver combining multiple algorithmsilp_solver_test.py
: Tests the Integer Linear Programming solvermaxcut_test.py
: Tests the MaxCut solverneighborjoining_solver_test.py
: Tests the Neighbor Joining solverpercolation_test.py
: Tests the Percolation solversharedmutationjoiner_test.py
: Tests the Shared Mutation Joining solversnj_solver_test.py
: Tests the Spectral Neighbor Joining solverspectral_test.py
: Tests the Spectral solverupgma_test.py
: Tests the UPGMA solvervanillagreedy_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:
neighborjoining_solver_test.py
: Tests the widely-used Neighbor Joining algorithmilp_solver_test.py
: Tests the Integer Linear Programming solver, which can provide optimal solutions for smaller datasetsdissimilarity_functions_test.py
: Tests critical dissimilarity and similarity functions used across multiple solvershybrid_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:
- unittest: Provides the testing framework
- networkx: Used for graph operations and tree representation
- numpy: Used for numerical operations and array manipulations
- pandas: Used for data manipulation and character matrix representation
- scipy: Used for scientific computing and optimization
- mock: Used for creating mock objects in tests
- 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:
- CCPhylo tests check for the existence of a
config.ini
file and accphylo_path
setting. - 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.