@@ -1082,7 +1082,7 @@ run_match(const tsk_treeseq_t *ts, double rho, double mu, const allele_t *h,
10821082 recombination_rate [j ] = rho ;
10831083 }
10841084
1085- ret = matcher_indexes_alloc (& mi , ts -> tables , 0 );
1085+ ret = matcher_indexes_alloc (& mi , ts -> tables , NULL , 0 );
10861086 CU_ASSERT_EQUAL_FATAL (ret , 0 );
10871087 /* matcher_indexes_print_state(&mi, stdout); */
10881088 ret = ancestor_matcher2_alloc (& am , & mi , recombination_rate , mutation_rate , 14 , 0 );
@@ -1441,6 +1441,44 @@ test_matching_deep_chain_ts(void)
14411441 tsk_treeseq_free (& ts );
14421442}
14431443
1444+ static void
1445+ test_matching_triallelic_ts (void )
1446+ {
1447+ /*
1448+ * Test that num_alleles > 2 is accepted.
1449+ * Use the star topology but tell the matcher that site 0 has 3 alleles.
1450+ * Query with allele 2 at site 0 should not trigger BAD_HAPLOTYPE_ALLELE.
1451+ */
1452+ tsk_treeseq_t ts ;
1453+ ancestor_matcher2_t am ;
1454+ matcher_indexes_t mi ;
1455+ allele_t match [3 ];
1456+ tsk_id_t left [3 ], right [3 ], parent [3 ];
1457+ tsk_size_t path_length ;
1458+ tsk_size_t num_alleles [] = { 3 , 2 , 2 };
1459+ double rho [] = { 1e-9 , 1e-9 , 1e-9 };
1460+ double mu [] = { 1e-20 , 1e-20 , 1e-20 };
1461+ int ret ;
1462+
1463+ build_star_ts (& ts );
1464+
1465+ ret = matcher_indexes_alloc (& mi , ts .tables , num_alleles , 0 );
1466+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
1467+ ret = ancestor_matcher2_alloc (& am , & mi , rho , mu , 14 , 0 );
1468+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
1469+
1470+ /* Query [2,0,0]: allele 2 at site 0 needs num_alleles >= 3 */
1471+ allele_t h [] = { 2 , 0 , 0 };
1472+ ret = ancestor_matcher2_find_path (
1473+ & am , 0 , 3 , h , match , & path_length , left , right , parent );
1474+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
1475+ CU_ASSERT_EQUAL (path_length , 1 );
1476+
1477+ ancestor_matcher2_free (& am );
1478+ matcher_indexes_free (& mi );
1479+ tsk_treeseq_free (& ts );
1480+ }
1481+
14441482static void
14451483test_strerror (void )
14461484{
@@ -1563,6 +1601,7 @@ main(int argc, char **argv)
15631601 { "test_matching_binary_ts" , test_matching_binary_ts },
15641602 { "test_matching_two_tree_ts" , test_matching_two_tree_ts },
15651603 { "test_matching_deep_chain_ts" , test_matching_deep_chain_ts },
1604+ { "test_matching_triallelic_ts" , test_matching_triallelic_ts },
15661605
15671606 { "test_strerror" , test_strerror },
15681607
0 commit comments