> ## Documentation Index
> Fetch the complete documentation index at: https://demo.agenticlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ecdna_birth_death_simulator_test.py

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

| Name       | Type | Description        |
| :--------- | :--- | :----------------- |
| node\_name | str  | A unique node name |

### `extract_tree_statistics(tree)`

#### Description

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

#### Inputs

| Name | Type           | Description         |
| :--- | :------------- | :------------------ |
| tree | CassiopeiaTree | The tree to analyze |

#### Outputs

| Name             | Type         | Description                                    |
| :--------------- | :----------- | :--------------------------------------------- |
| times            | List\[float] | Total lived time for each extant lineage       |
| num\_leaves      | int          | Number of extant lineages                      |
| correct\_degrees | bool         | Whether 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.
