|
29 | 29 | #include <stdlib.h> |
30 | 30 | #include <float.h> |
31 | 31 |
|
32 | | -static tsk_size_t |
33 | | -get_max_site_mutations(tsk_treeseq_t *ts) |
34 | | -{ |
35 | | - int ret; |
36 | | - tsk_id_t j; |
37 | | - tsk_size_t max_mutations = 0; |
38 | | - tsk_site_t site; |
39 | | - |
40 | | - for (j = 0; j < (tsk_id_t) tsk_treeseq_get_num_sites(ts); j++) { |
41 | | - ret = tsk_treeseq_get_site(ts, j, &site); |
42 | | - CU_ASSERT_EQUAL_FATAL(ret, 0); |
43 | | - max_mutations = TSK_MAX(max_mutations, site.mutations_length); |
44 | | - } |
45 | | - return max_mutations; |
46 | | -} |
47 | | - |
48 | 32 | static bool |
49 | 33 | multi_mutations_exist(tsk_treeseq_t *ts, tsk_id_t start, tsk_id_t end) |
50 | 34 | { |
@@ -227,36 +211,6 @@ verify_ld(tsk_treeseq_t *ts) |
227 | 211 | free(num_site_mutations); |
228 | 212 | } |
229 | 213 |
|
230 | | -static void |
231 | | -verify_pairwise_diversity(tsk_treeseq_t *ts) |
232 | | -{ |
233 | | - int ret; |
234 | | - size_t num_samples = tsk_treeseq_get_num_samples(ts); |
235 | | - tsk_id_t *samples; |
236 | | - uint32_t j; |
237 | | - double pi; |
238 | | - tsk_size_t max_site_mutations = get_max_site_mutations(ts); |
239 | | - |
240 | | - ret = tsk_treeseq_get_pairwise_diversity(ts, NULL, 0, &pi); |
241 | | - CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_PARAM_VALUE); |
242 | | - ret = tsk_treeseq_get_pairwise_diversity(ts, NULL, 1, &pi); |
243 | | - CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_PARAM_VALUE); |
244 | | - ret = tsk_treeseq_get_pairwise_diversity(ts, NULL, num_samples + 1, &pi); |
245 | | - CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_PARAM_VALUE); |
246 | | - |
247 | | - samples = tsk_treeseq_get_samples(ts); |
248 | | - |
249 | | - for (j = 2; j < num_samples; j++) { |
250 | | - ret = tsk_treeseq_get_pairwise_diversity(ts, samples, j, &pi); |
251 | | - if (max_site_mutations <= 1) { |
252 | | - CU_ASSERT_EQUAL_FATAL(ret, 0); |
253 | | - CU_ASSERT_TRUE_FATAL(pi >= 0); |
254 | | - } else { |
255 | | - CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_ONLY_INFINITE_SITES); |
256 | | - } |
257 | | - } |
258 | | -} |
259 | | - |
260 | 214 | /* FIXME: this test is weak and should check the return value somehow. |
261 | 215 | * We should also have simplest and single tree tests along with separate |
262 | 216 | * tests for the error conditions. This should be done as part of the general |
@@ -1023,17 +977,6 @@ test_single_tree_ld(void) |
1023 | 977 | tsk_treeseq_free(&ts); |
1024 | 978 | } |
1025 | 979 |
|
1026 | | -static void |
1027 | | -test_single_tree_pairwise_diversity(void) |
1028 | | -{ |
1029 | | - tsk_treeseq_t ts; |
1030 | | - |
1031 | | - tsk_treeseq_from_text(&ts, 1, single_tree_ex_nodes, single_tree_ex_edges, |
1032 | | - NULL, single_tree_ex_sites, single_tree_ex_mutations, NULL, NULL); |
1033 | | - verify_pairwise_diversity(&ts); |
1034 | | - tsk_treeseq_free(&ts); |
1035 | | -} |
1036 | | - |
1037 | 980 | static void |
1038 | 981 | test_single_tree_mean_descendants(void) |
1039 | 982 | { |
@@ -1095,17 +1038,6 @@ test_paper_ex_ld(void) |
1095 | 1038 | tsk_treeseq_free(&ts); |
1096 | 1039 | } |
1097 | 1040 |
|
1098 | | -static void |
1099 | | -test_paper_ex_pairwise_diversity(void) |
1100 | | -{ |
1101 | | - tsk_treeseq_t ts; |
1102 | | - |
1103 | | - tsk_treeseq_from_text(&ts, 10, paper_ex_nodes, paper_ex_edges, |
1104 | | - NULL, paper_ex_sites, paper_ex_mutations, paper_ex_individuals, NULL); |
1105 | | - verify_pairwise_diversity(&ts); |
1106 | | - tsk_treeseq_free(&ts); |
1107 | | -} |
1108 | | - |
1109 | 1041 | static void |
1110 | 1042 | test_paper_ex_mean_descendants(void) |
1111 | 1043 | { |
@@ -1173,26 +1105,23 @@ test_paper_ex_diversity(void) |
1173 | 1105 | tsk_treeseq_t ts; |
1174 | 1106 | tsk_id_t samples[] = {0, 1, 2, 3}; |
1175 | 1107 | tsk_size_t sample_set_sizes = 4; |
1176 | | - double pi1, pi2; |
| 1108 | + double pi; |
1177 | 1109 | int ret; |
1178 | 1110 |
|
1179 | 1111 | tsk_treeseq_from_text(&ts, 10, paper_ex_nodes, paper_ex_edges, |
1180 | 1112 | NULL, paper_ex_sites, paper_ex_mutations, paper_ex_individuals, NULL); |
1181 | 1113 |
|
1182 | 1114 | ret = tsk_treeseq_diversity(&ts, 1, &sample_set_sizes, samples, 0, NULL, |
1183 | | - &pi1, TSK_STAT_SITE); |
| 1115 | + &pi, TSK_STAT_SITE); |
1184 | 1116 | CU_ASSERT_EQUAL_FATAL(ret, 0); |
1185 | | - /* This function will probably be removed, but it's a handy test for now */ |
1186 | | - ret = tsk_treeseq_get_pairwise_diversity(&ts, samples, 4, &pi2); |
1187 | | - CU_ASSERT_EQUAL_FATAL(ret, 0); |
1188 | | - CU_ASSERT_DOUBLE_EQUAL_FATAL(pi1, pi2, 1e-6); |
| 1117 | + CU_ASSERT_DOUBLE_EQUAL_FATAL(pi, 1.5, 1e-6); |
1189 | 1118 |
|
1190 | 1119 | /* A sample set size of 1 leads to NaN */ |
1191 | 1120 | sample_set_sizes = 1; |
1192 | 1121 | ret = tsk_treeseq_diversity(&ts, 1, &sample_set_sizes, samples, 0, NULL, |
1193 | | - &pi1, TSK_STAT_SITE); |
| 1122 | + &pi, TSK_STAT_SITE); |
1194 | 1123 | CU_ASSERT_EQUAL_FATAL(ret, 0); |
1195 | | - CU_ASSERT(isnan((float) pi1)); |
| 1124 | + CU_ASSERT(isnan((float) pi)); |
1196 | 1125 |
|
1197 | 1126 | tsk_treeseq_free(&ts); |
1198 | 1127 | } |
@@ -1681,17 +1610,6 @@ test_nonbinary_ex_ld(void) |
1681 | 1610 | tsk_treeseq_free(&ts); |
1682 | 1611 | } |
1683 | 1612 |
|
1684 | | -static void |
1685 | | -test_nonbinary_ex_pairwise_diversity(void) |
1686 | | -{ |
1687 | | - tsk_treeseq_t ts; |
1688 | | - |
1689 | | - tsk_treeseq_from_text(&ts, 100, nonbinary_ex_nodes, nonbinary_ex_edges, |
1690 | | - NULL, nonbinary_ex_sites, nonbinary_ex_mutations, NULL, NULL); |
1691 | | - verify_pairwise_diversity(&ts); |
1692 | | - tsk_treeseq_free(&ts); |
1693 | | -} |
1694 | | - |
1695 | 1613 | static void |
1696 | 1614 | test_nonbinary_ex_mean_descendants(void) |
1697 | 1615 | { |
@@ -1756,15 +1674,13 @@ main(int argc, char **argv) |
1756 | 1674 | {"test_empty_ts_afs", test_empty_ts_afs}, |
1757 | 1675 |
|
1758 | 1676 | {"test_single_tree_ld", test_single_tree_ld}, |
1759 | | - {"test_single_tree_pairwise_diversity", test_single_tree_pairwise_diversity}, |
1760 | 1677 | {"test_single_tree_mean_descendants", test_single_tree_mean_descendants}, |
1761 | 1678 | {"test_single_tree_genealogical_nearest_neighbours", |
1762 | 1679 | test_single_tree_genealogical_nearest_neighbours}, |
1763 | 1680 | {"test_single_tree_general_stat", test_single_tree_general_stat}, |
1764 | 1681 | {"test_single_tree_general_stat_errors", test_single_tree_general_stat_errors}, |
1765 | 1682 |
|
1766 | 1683 | {"test_paper_ex_ld", test_paper_ex_ld}, |
1767 | | - {"test_paper_ex_pairwise_diversity", test_paper_ex_pairwise_diversity}, |
1768 | 1684 | {"test_paper_ex_mean_descendants", test_paper_ex_mean_descendants}, |
1769 | 1685 | {"test_paper_ex_genealogical_nearest_neighbours", |
1770 | 1686 | test_paper_ex_genealogical_nearest_neighbours}, |
@@ -1798,7 +1714,6 @@ main(int argc, char **argv) |
1798 | 1714 | {"test_paper_ex_afs", test_paper_ex_afs}, |
1799 | 1715 |
|
1800 | 1716 | {"test_nonbinary_ex_ld", test_nonbinary_ex_ld}, |
1801 | | - {"test_nonbinary_ex_pairwise_diversity", test_nonbinary_ex_pairwise_diversity}, |
1802 | 1717 | {"test_nonbinary_ex_mean_descendants", test_nonbinary_ex_mean_descendants}, |
1803 | 1718 | {"test_nonbinary_ex_genealogical_nearest_neighbours", |
1804 | 1719 | test_nonbinary_ex_genealogical_nearest_neighbours}, |
|
0 commit comments