@@ -204,6 +204,54 @@ verify_pedigree(double recombination_rate, unsigned long seed,
204204 tsk_table_collection_free (& tables );
205205}
206206
207+ static void
208+ verify_pedigree_event_by_event (double recombination_rate , unsigned long seed ,
209+ tsk_size_t num_individuals , tsk_id_t * parents , double * time , tsk_flags_t * is_sample ,
210+ tsk_id_t * population , uint32_t additional_nodes )
211+ {
212+ int ret , status1 , status2 ;
213+ int ploidy = 2 ;
214+ msp_t msp1 , msp2 ;
215+ tsk_table_collection_t tables1 , tables2 ;
216+ gsl_rng * rng1 = safe_rng_alloc ();
217+ gsl_rng * rng2 = safe_rng_alloc ();
218+
219+ ret = build_pedigree_sim (& msp1 , & tables1 , rng1 , 100 , ploidy , num_individuals ,
220+ parents , time , is_sample , population );
221+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
222+ ret = build_pedigree_sim (& msp2 , & tables2 , rng2 , 100 , ploidy , num_individuals ,
223+ parents , time , is_sample , population );
224+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
225+
226+ ret = msp_initialise (& msp1 );
227+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
228+ ret = msp_initialise (& msp2 );
229+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
230+
231+ ret = msp_run (& msp1 , DBL_MAX , UINT32_MAX );
232+ CU_ASSERT_FATAL (ret == MSP_EXIT_MODEL_COMPLETE || ret == MSP_EXIT_COALESCENCE );
233+ status1 = ret ;
234+
235+ ret = MSP_EXIT_MAX_EVENTS ;
236+ while (ret == MSP_EXIT_MAX_EVENTS ) {
237+ ret = msp_run (& msp2 , DBL_MAX , 1 );
238+ CU_ASSERT_FATAL (ret >= 0 );
239+ msp_verify (& msp2 , 0 );
240+ }
241+ CU_ASSERT_FATAL (ret == MSP_EXIT_MODEL_COMPLETE || ret == MSP_EXIT_COALESCENCE );
242+ status2 = ret ;
243+ CU_ASSERT_EQUAL (status1 , status2 );
244+
245+ CU_ASSERT_TRUE (tsk_table_collection_equals (& tables1 , & tables2 , 0 ));
246+
247+ tsk_table_collection_free (& tables1 );
248+ msp_free (& msp1 );
249+ tsk_table_collection_free (& tables2 );
250+ msp_free (& msp2 );
251+ gsl_rng_free (rng1 );
252+ gsl_rng_free (rng2 );
253+ }
254+
207255static void
208256test_trio (void )
209257{
@@ -850,6 +898,29 @@ test_internal_samples(void)
850898
851899 verify_pedigree (0 , 1 , 3 , parents , time , is_sample , NULL , 0 );
852900 verify_pedigree (0.1 , 1 , 3 , parents , time , is_sample , NULL , 0 );
901+
902+ verify_pedigree_event_by_event (0 , 1 , 3 , parents , time , is_sample , NULL , 0 );
903+ verify_pedigree_event_by_event (0.1 , 1 , 3 , parents , time , is_sample , NULL , 0 );
904+ }
905+
906+ static void
907+ test_no_leaf_samples (void )
908+ {
909+ tsk_id_t * parents = deep_n10_parents ;
910+ double * time = deep_n10_time ;
911+ size_t num_inds = sizeof (deep_n10_time ) / sizeof (* deep_n10_time );
912+ tsk_flags_t is_sample [num_inds ];
913+ size_t j ;
914+
915+ for (j = 0 ; j < num_inds ; j ++ ) {
916+ is_sample [j ] = time [j ] == 1 ;
917+ }
918+
919+ verify_pedigree (0 , 1 , num_inds , parents , time , is_sample , NULL , 0 );
920+ verify_pedigree (0.1 , 1 , num_inds , parents , time , is_sample , NULL , 0 );
921+
922+ verify_pedigree_event_by_event (0 , 1 , num_inds , parents , time , is_sample , NULL , 0 );
923+ verify_pedigree_event_by_event (0.1 , 1 , num_inds , parents , time , is_sample , NULL , 0 );
853924}
854925
855926static void
@@ -895,6 +966,7 @@ test_trio_same_pop(void)
895966 tsk_id_t population [] = { 2 , 2 , 2 };
896967
897968 verify_pedigree (0 , 1 , 3 , parents , time , NULL , population , 0 );
969+ verify_pedigree_event_by_event (0 , 1 , 3 , parents , time , NULL , population , 0 );
898970}
899971
900972static void
@@ -906,6 +978,7 @@ test_trio_child_different_pop(void)
906978 tsk_id_t population [] = { 2 , 2 , 1 };
907979
908980 verify_pedigree (0 , 1 , 3 , parents , time , NULL , population , 0 );
981+ verify_pedigree_event_by_event (0 , 1 , 3 , parents , time , NULL , population , 0 );
909982}
910983
911984int
@@ -918,6 +991,7 @@ main(int argc, char **argv)
918991 { "test_sibs" , test_sibs },
919992 { "test_ancient_sample" , test_ancient_sample },
920993 { "test_internal_samples" , test_internal_samples },
994+ { "test_no_leaf_samples" , test_no_leaf_samples },
921995 { "test_large_family" , test_large_family },
922996 { "test_unrelated_n3" , test_unrelated_n3 },
923997 { "test_very_deep_n2" , test_very_deep_n2 },
@@ -933,7 +1007,6 @@ main(int argc, char **argv)
9331007 { "test_replicates_exit_coalescence" , test_replicates_exit_coalescence },
9341008 { "test_errors" , test_errors },
9351009 { "test_combined_with_other_models" , test_combined_with_other_models },
936-
9371010 { "test_trio_same_pop" , test_trio_same_pop },
9381011 { "test_trio_child_different_pop" , test_trio_child_different_pop },
9391012 CU_TEST_INFO_NULL ,
0 commit comments