seismicrna.filterscan.tests package

Submodules

class seismicrna.filterscan.tests.filterscan_test.ScanTestBase(*args, **kwargs)

Bases: TestCase

Shared simulation infrastructure for the scan tests.

DOMAINS = [('TGACGAACAACGTGTTTGTGAACCATATAGGTAAACGCTGAATGCGTTCGCGCGGAGGGT', ['..(((((((...)))))))..(((......((.(((((.....))))).))......)))', '...(((...(((((((((((.(((.....)))...))).))))))))))).((.....))']), ('TTTGCAGGAAGATGGTCAACTCTACACCTAGTTTTTACCAGTCCACAAGAGTTTGAACTG', ['.(((..(((...((((.((..(((....)))..)).)))).))).))).(((....))).']), ('GTGCCTTAACCTGAGTACGCCCATATCATGGGAGACATTACAACTCAAATTCTAGGTGTG', ['..((((.....(((((...(((((...)))))..........)))))......))))...', '((((.(((...)))))))...((((((.((((..................))))))))))'])]
PROFILE = 'scan'
REF = 'test_ref'
REFS = 'test_refs'
SAMPLE = 'test_sample'
setUp()

Hook method for setting up the test fixture before exercising it.

sim_data(domain_nums: list[int], read_length: int, seed: int)
property sim_dir
tearDown()

Hook method for deconstructing the test fixture after testing it.

class seismicrna.filterscan.tests.filterscan_test.TestBlockScore(methodName='runTest')

Bases: TestCase

_block_score is the BIC-corrected binomial log-likelihood ratio of a block’s own bridge rate against the null rate pi0.

test_block_at_or_below_null_scores_negative()
test_empty_block_is_minus_inf()
test_enrichment_increases_gain()
test_locality_independent_of_other_blocks()
test_matches_hand_computed_llr_minus_bic()
class seismicrna.filterscan.tests.filterscan_test.TestBridgeMask(methodName='runTest')

Bases: TestCase

_bridge_mask marks a pair ELIGIBLE (enough coverage and expected-both, regardless of correlation direction) and, among those, a BRIDGE if it is also exact-hypergeometric-significant (pair_fdr) and depleted by at least min_fold_change relative to independence.

test_below_fold_change_floor_is_eligible_not_bridge()
test_empty_table()
test_low_coverage_excluded_regardless_of_effect()
test_positive_correlation_is_eligible_but_not_bridge()
test_strong_depletion_is_a_bridge()
test_zero_both_mutated_is_an_infinite_fold_change_bridge()
class seismicrna.filterscan.tests.filterscan_test.TestBuildBandedTable(methodName='runTest')

Bases: TestCase

test_band_filter()
test_band_width_zero_applies_no_extra_cap()
test_dedup_keeps_max_n()
test_empty()
class seismicrna.filterscan.tests.filterscan_test.TestCalcBlockPvalueCutoff(methodName='runTest')

Bases: TestCase

_calc_block_pvalue_cutoff returns the BH cutoff over every candidate block; -1 (admit nothing) when no block is significant.

test_admit_nothing_on_pure_background()
test_dense_block_admitted()
class seismicrna.filterscan.tests.filterscan_test.TestCalcDomainsByDpSegmentation(methodName='runTest')

Bases: TestCase

End-to-end DP domain calling on constructed bridge tables.

test_bad_max_domain_length_raises()
test_block_locality_distant_dense_block_does_not_change_call()
test_max_domain_length_bounds_final_domains()
test_out_of_order_ends_raise()
test_over_fragmentation_merge_across_spanned_void()
test_separate_domains_stay_split_without_crossing()
test_two_domains_recovered_and_not_merged()
class seismicrna.filterscan.tests.filterscan_test.TestCalcTiles(methodName='runTest')

Bases: TestCase

setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

test_region_not_divisible()
test_tile_length_larger()
test_tile_min_overlap_25()
test_tile_min_overlap_75()
test_total_tile_length_1()
class seismicrna.filterscan.tests.filterscan_test.TestCutCrossingScores(methodName='runTest')

Bases: TestCase

_cut_crossing_scores counts, per cut, the eligible pairs straddling it and how many are bridges (difference-array sweep).

test_matches_brute_force()
test_zero_crossing_reads_exactly_zero()
class seismicrna.filterscan.tests.filterscan_test.TestDpSegmentBlocks(methodName='runTest')

Bases: TestCase

_dp_segment_blocks finds the globally-optimal admitted partition and honours max_domain_length.

test_finds_dense_block()
test_respects_max_domain_length()
class seismicrna.filterscan.tests.filterscan_test.TestEstimateNullBridgeRate(methodName='runTest')

Bases: TestCase

_estimate_null_bridge_rate estimates pi0 as the out-of-domain bridge rate, floored.

test_floor_applied_when_background_clean()
test_out_of_domain_rate()
class seismicrna.filterscan.tests.filterscan_test.TestExtendDomainsByBridges(methodName='runTest')

Bases: TestCase

_extend_domains_by_bridges grows a domain outward to absorb a thin line of edge bridges, but ignores a lone distant stray bridge.

test_absorbs_thin_line_of_edge_bridges()
test_extension_respects_max_domain_length()
test_ignores_lone_distant_bridge()
class seismicrna.filterscan.tests.filterscan_test.TestFilterScan(*args, **kwargs)

Bases: ScanTestBase

Test that filterscan identifies domains without clustering.

run_filterscan_check(idmut_dirs: list[Path], expect_regions: list[tuple[int, int]], **kwargs)
test_domains012_read120()
test_domains012_read180()
test_domains012_read180_cli()
test_domains012_read60()
test_domains02_read60()
class seismicrna.filterscan.tests.filterscan_test.TestGapUtilities(methodName='runTest')

Bases: TestCase

The gap-handling helpers (_split/_fill/_widen/_label/ _filter).

test_fill_covers_whole_region_when_no_domains()
test_fill_leaves_adjacent_domains_untouched()
test_fill_matches_old_insert_behavior_when_cap_is_non_binding()
test_fill_splits_oversized_interior_gap()
test_fill_splits_oversized_leading_gap()
test_filter_drops_short_domains()
test_label_widened_marks_unchanged_and_grown()
test_split_gap_evenly_divides_exactly()
test_split_gap_evenly_minimum_count_as_equal_as_possible()
test_widen_binding_cap_leaves_interior_leftover()
test_widen_binding_cap_leaves_leading_leftover()
test_widen_matches_old_expand_behavior_when_cap_is_non_binding()
test_widen_then_fill_mops_up_residual_gap()
class seismicrna.filterscan.tests.filterscan_test.TestMergeConnectedBlocks(methodName='runTest')

Bases: TestCase

_merge_connected_blocks joins adjacent blocks whose gap is crossed by enriched bridges at every cut, subject to max_domain_length.

test_faint_uniform_gap_does_not_merge()
test_keeps_split_when_a_cut_is_disconnected()
test_max_domain_length_guard_blocks_merge()
test_merges_when_every_gap_cut_connected()
class seismicrna.filterscan.tests.filterscan_test.TestSplitAuthenticity(*args, **kwargs)

Bases: ScanTestBase

Validate that a genuine domain split is authentic: if two domains are truly independent structural units, clustering them separately should recover – up to EM/sampling noise – the same joint mixture as clustering the merged region. Concretely, the merged region’s cluster count and proportions should match the CARTESIAN PRODUCT of the two domains’ independent clusterings: K_merged == K_A * K_B and the merged proportions should equal the outer product of the two domains’ marginal proportions. This is a general check of the splitting concept (not specific to the insulation-based caller): an authentic boundary is one where the two sides are statistically independent, which is exactly what the cartesian-product prediction tests.

test_merged_region_matches_cartesian_product_of_separate_domains()
class seismicrna.filterscan.tests.filterscan_test.TestTriangleSumBanded(methodName='runTest')

Bases: TestCase

_triangle_sum_banded reads triangle (contained-pair) sums off the banded row-cumulative arrays; the s_min bound matches the unbounded result on the overlapping range.

test_matches_brute_force_contained_counts()
test_s_min_equals_unbounded_on_overlap()
class seismicrna.filterscan.tests.filterscan_test.TestWritePairsWithConfusion(methodName='runTest')

Bases: TestCase

pairs.csv must carry each written pair’s 2x2 confusion-matrix counts, plus the p-value and fold change derived from them.

test_writes_confusion_counts()