@@ -321,7 +321,7 @@ verify_pair_coalescence_counts(tsk_treeseq_t *ts, tsk_flags_t options)
321
321
tsk_id_t index_tuples [2 * I ];
322
322
tsk_id_t node_bin_map [N ];
323
323
tsk_size_t dim = T * N * I ;
324
- double C1 [dim ];
324
+ double C [dim ];
325
325
tsk_size_t i , j , k ;
326
326
327
327
for (i = 0 ; i < n ; i ++ ) {
@@ -343,51 +343,65 @@ verify_pair_coalescence_counts(tsk_treeseq_t *ts, tsk_flags_t options)
343
343
}
344
344
}
345
345
346
+ /* test various bin assignments */
346
347
for (i = 0 ; i < N ; i ++ ) {
347
- node_bin_map [i ] = (tsk_id_t ) i ;
348
+ node_bin_map [i ] = (( tsk_id_t ) i ) % 8 ;
348
349
}
350
+ ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
351
+ index_tuples , T , breakpoints , 8 , node_bin_map , options , C );
352
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
349
353
354
+ for (i = 0 ; i < N ; i ++ ) {
355
+ node_bin_map [i ] = i < N / 2 ? ((tsk_id_t ) i ) : TSK_NULL ;
356
+ }
357
+ ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
358
+ index_tuples , T , breakpoints , N / 2 , node_bin_map , options , C );
359
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
360
+
361
+ for (i = 0 ; i < N ; i ++ ) {
362
+ node_bin_map [i ] = (tsk_id_t ) i ;
363
+ }
350
364
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
351
- index_tuples , T , breakpoints , N , node_bin_map , options , C1 );
365
+ index_tuples , T , breakpoints , N , node_bin_map , options , C );
352
366
CU_ASSERT_EQUAL_FATAL (ret , 0 );
353
- /* TODO: test against naive pairs per node per tree */
367
+ /* TODO: compare against naive pairs per node per tree */
354
368
355
369
/* cover errors */
356
370
double bad_breakpoints [2 ] = { breakpoints [1 ], 0.0 };
357
371
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
358
- index_tuples , 1 , bad_breakpoints , N , node_bin_map , options , C1 );
372
+ index_tuples , 1 , bad_breakpoints , N , node_bin_map , options , C );
359
373
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_BAD_WINDOWS );
360
374
361
375
index_tuples [0 ] = (tsk_id_t ) P ;
362
376
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
363
- index_tuples , 1 , breakpoints , N , node_bin_map , options , C1 );
377
+ index_tuples , 1 , breakpoints , N , node_bin_map , options , C );
364
378
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_BAD_SAMPLE_SET_INDEX );
365
379
index_tuples [0 ] = 0 ;
366
380
367
381
tsk_size_t tmp = sample_set_sizes [0 ];
368
382
sample_set_sizes [0 ] = 0 ;
369
383
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
370
- index_tuples , 1 , breakpoints , N , node_bin_map , options , C1 );
384
+ index_tuples , 1 , breakpoints , N , node_bin_map , options , C );
371
385
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_EMPTY_SAMPLE_SET );
372
386
sample_set_sizes [0 ] = tmp ;
373
387
374
388
sample_sets [1 ] = 0 ;
375
389
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
376
- index_tuples , 1 , breakpoints , N , node_bin_map , options , C1 );
390
+ index_tuples , 1 , breakpoints , N , node_bin_map , options , C );
377
391
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_DUPLICATE_SAMPLE );
378
392
sample_sets [1 ] = 1 ;
379
393
380
394
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
381
- index_tuples , 1 , breakpoints , N - 1 , node_bin_map , options , C1 );
395
+ index_tuples , 1 , breakpoints , N - 1 , node_bin_map , options , C );
382
396
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_BAD_NODE_BIN_MAP_DIM );
383
397
384
398
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
385
- index_tuples , 1 , breakpoints , 0 , node_bin_map , options , C1 );
399
+ index_tuples , 1 , breakpoints , 0 , node_bin_map , options , C );
386
400
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_BAD_NODE_BIN_MAP_DIM );
387
401
388
402
node_bin_map [0 ] = -2 ;
389
403
ret = tsk_treeseq_pair_coalescence_counts (ts , P , sample_set_sizes , sample_sets , I ,
390
- index_tuples , 1 , breakpoints , N , node_bin_map , options , C1 );
404
+ index_tuples , 1 , breakpoints , N , node_bin_map , options , C );
391
405
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_BAD_NODE_BIN_MAP );
392
406
node_bin_map [0 ] = 0 ;
393
407
}
@@ -2880,8 +2894,6 @@ test_pair_coalescence_counts(void)
2880
2894
tsk_treeseq_t ts ;
2881
2895
tsk_treeseq_from_text (& ts , 100 , nonbinary_ex_nodes , nonbinary_ex_edges , NULL ,
2882
2896
nonbinary_ex_sites , nonbinary_ex_mutations , NULL , NULL , 0 );
2883
- verify_pair_coalescence_counts (& ts , TSK_STAT_NODE );
2884
- verify_pair_coalescence_counts (& ts , TSK_STAT_NODE | TSK_STAT_SPAN_NORMALISE );
2885
2897
verify_pair_coalescence_counts (& ts , 0 );
2886
2898
verify_pair_coalescence_counts (& ts , TSK_STAT_SPAN_NORMALISE );
2887
2899
tsk_treeseq_free (& ts );
0 commit comments