High-level description

This file contains unit tests for the SimpleFitSubcloneSimulator class, which simulates a clonal population that develops one fit subclone. The tests verify the correctness of the simulated phylogenetic tree structure and branch lengths in both deterministic and stochastic scenarios.

Symbols

TestSimpleFitSubcloneSimulator

Description

A unittest.TestCase subclass that contains test methods for the SimpleFitSubcloneSimulator class.

test_deterministic

Description

Tests the SimpleFitSubcloneSimulator with deterministic branch lengths to ensure the generated phylogeny is correct.

Internal Logic

  1. Creates a SimpleFitSubcloneSimulator instance with specific parameters.
  2. Simulates a tree using the simulator.
  3. Asserts that the generated tree has the expected structure:
    • Correct node names
    • Correct edge connections
    • Correct node times

test_stochastic

Description

Tests the SimpleFitSubcloneSimulator with stochastic branch lengths to ensure non-deterministic behavior.

Internal Logic

  1. Sets a random seed for reproducibility.
  2. Defines two functions for generating random branch lengths:
    • branch_length_neutral: Returns an exponentially distributed value with mean 1.0
    • branch_length_fit: Returns an exponentially distributed value with mean 0.5
  3. Creates a SimpleFitSubcloneSimulator instance with the random branch length functions.
  4. Simulates a tree using the simulator.
  5. Extracts branch lengths for non-leaf nodes.
  6. Asserts that all branch lengths are distinct, confirming non-determinism.

Dependencies

DependencyPurpose
numpyUsed for random number generation and array operations
unittestProvides the testing framework
cassiopeia.simulator.SimpleFitSubcloneSimulatorThe class being tested

Notes

  • The tests cover both deterministic and stochastic scenarios, ensuring the simulator works correctly in different conditions.
  • The stochastic test uses a fixed random seed to ensure reproducibility while still testing random behavior.
  • The tests focus on verifying the tree structure, node naming, and branch length generation, which are key aspects of the SimpleFitSubcloneSimulator’s functionality.