Here’s a documentation for the target file test/simulator_tests/ecdna_birth_death_simulator_test.py:

High-level description

This file contains unit tests for the ecDNABirthDeathSimulator class in the Cassiopeia package. It tests various aspects of the simulator, including ecDNA splitting, lineage sampling, tree population, and cosegregation of ecDNA species.

Code Structure

The main class ecDNABirthDeathSimulatorTest inherits from unittest.TestCase and contains several test methods. These methods test different functionalities of the ecDNABirthDeathSimulator class, such as ecDNA splitting, initial sample events, lineage sampling, tree population, and cosegregation.

References

  • cassiopeia.simulator.ecDNABirthDeathSimulator.ecDNABirthDeathSimulator
  • cassiopeia.data.CassiopeiaTree
  • cassiopeia.data.utilities

Symbols

node_name_generator()

Description

A generator function that yields unique node names for the tree.

Outputs

NameTypeDescription
node_namestrA unique node name

extract_tree_statistics(tree)

Description

A helper function for testing simulated trees. It extracts various statistics from the given tree.

Inputs

NameTypeDescription
treeCassiopeiaTreeThe tree to analyze

Outputs

NameTypeDescription
timesList[float]Total lived time for each extant lineage
num_leavesintNumber of extant lineages
correct_degreesboolWhether the tree has the expected node degrees

ecDNABirthDeathSimulatorTest

Description

The main test class containing various test methods for the ecDNABirthDeathSimulator.

Test Methods

  1. test_ecdna_splitting: Tests the ecDNA splitting functionality.
  2. test_initial_sample_event: Tests the initial sample event in the simulation.
  3. test_basic_sample_lineage_events: Checks that sample_lineage_event behaves as expected under edge cases.
  4. test_populate_tree_from_simulation: Tests the population of a tree from simulation results.
  5. test_basic_cosegregation: Tests basic cosegregation of ecDNA species.
  6. test_perfect_cosegregation: Tests perfect cosegregation of ecDNA species.
  7. test_low_capture_efficiency: Tests the simulator with low capture efficiency.

Dependencies

  • unittest
  • heapq
  • typing
  • queue
  • networkx
  • numpy
  • pandas
  • cassiopeia.data.CassiopeiaTree
  • cassiopeia.simulator.ecDNABirthDeathSimulator
  • cassiopeia.data.utilities

Error Handling

The tests use assertions to check for expected behavior and raise unittest.TestCase assertion errors if the behavior doesn’t match the expected outcome.

TODOs

None explicitly mentioned in the code.