Skip to content

Commit 2aa5e27

Browse files
C lib changes for precision->likelihood_threshold
1 parent bd0deed commit 2aa5e27

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Diff for: lib/ancestor_matcher.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ancestor_matcher_print_state(ancestor_matcher_t *self, FILE *out)
103103
int
104104
ancestor_matcher_alloc(ancestor_matcher_t *self,
105105
tree_sequence_builder_t *tree_sequence_builder, double *recombination_rate,
106-
double *mismatch_rate, unsigned int precision, int flags)
106+
double *mismatch_rate, double likelihood_threshold, int flags)
107107
{
108108
int ret = 0;
109109
/* TODO make these input parameters. */
@@ -112,7 +112,7 @@ ancestor_matcher_alloc(ancestor_matcher_t *self,
112112
memset(self, 0, sizeof(ancestor_matcher_t));
113113
/* All allocs for arrays related to nodes are done in expand_nodes */
114114
self->flags = flags;
115-
self->precision = precision;
115+
self->likelihood_threshold = likelihood_threshold;
116116
self->max_nodes = 0;
117117
self->tree_sequence_builder = tree_sequence_builder;
118118
self->num_sites = tree_sequence_builder->num_sites;
@@ -366,7 +366,7 @@ ancestor_matcher_update_site_likelihood_values(ancestor_matcher_t *self,
366366
/* Renormalise the likelihoods. */
367367
for (j = 0; j < num_likelihood_nodes; j++) {
368368
u = L_nodes[j];
369-
L[u] = tsk_round(L[u] / max_L, self->precision);
369+
L[u] = TSK_MAX(L[u] / max_L, self->likelihood_threshold);
370370
}
371371
ancestor_matcher_unset_allelic_state(self, site, allelic_state);
372372
out:

Diff for: lib/tests/tests.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ run_random_data(size_t num_samples, size_t num_sites, int seed,
364364
ret = tree_sequence_builder_alloc(&tsb, num_sites, NULL, 1, 1, 0);
365365
CU_ASSERT_EQUAL_FATAL(ret, 0);
366366
ret = ancestor_matcher_alloc(&ancestor_matcher, &tsb, recombination_rates,
367-
mismatch_rates, 6, TSI_EXTENDED_CHECKS);
367+
mismatch_rates, DBL_MIN, TSI_EXTENDED_CHECKS);
368368
CU_ASSERT_EQUAL_FATAL(ret, 0);
369369

370370
for (j = 0; j < num_sites; j++) {
@@ -536,7 +536,7 @@ test_matching_one_site(void)
536536
CU_ASSERT_EQUAL_FATAL(ret, 0);
537537

538538
ret = ancestor_matcher_alloc(
539-
&ancestor_matcher, &tsb, &recombination_rate, &mismatch_rate, 12, 0);
539+
&ancestor_matcher, &tsb, &recombination_rate, &mismatch_rate, DBL_MIN, 0);
540540
CU_ASSERT_EQUAL_FATAL(ret, 0);
541541

542542
ret = ancestor_matcher_find_path(
@@ -623,7 +623,7 @@ test_matching_one_site_many_alleles(void)
623623
CU_ASSERT_EQUAL_FATAL(ret, 0);
624624

625625
ret = ancestor_matcher_alloc(
626-
&ancestor_matcher, &tsb, &recombination_rate, &mismatch_rate, 12, 0);
626+
&ancestor_matcher, &tsb, &recombination_rate, &mismatch_rate, DBL_MIN, 0);
627627
CU_ASSERT_EQUAL_FATAL(ret, 0);
628628

629629
haplotype = 0;
@@ -682,7 +682,7 @@ test_matching_errors(void)
682682
CU_ASSERT_EQUAL_FATAL(ret, 0);
683683

684684
ret = ancestor_matcher_alloc(
685-
&ancestor_matcher, &tsb, recombination_rate, mismatch_rate, 12, 0);
685+
&ancestor_matcher, &tsb, recombination_rate, mismatch_rate, DBL_MIN, 0);
686686
CU_ASSERT_EQUAL_FATAL(ret, 0);
687687
ret = ancestor_matcher_find_path(
688688
&ancestor_matcher, 0, 2, haplotype, match, &num_edges, &left, &right, &parent);
@@ -692,7 +692,7 @@ test_matching_errors(void)
692692
haplotype[0] = 0;
693693
mismatch_rate[0] = 1;
694694
ret = ancestor_matcher_alloc(
695-
&ancestor_matcher, &tsb, recombination_rate, mismatch_rate, 12, 0);
695+
&ancestor_matcher, &tsb, recombination_rate, mismatch_rate, DBL_MIN, 0);
696696
CU_ASSERT_EQUAL_FATAL(ret, 0);
697697
ret = ancestor_matcher_find_path(
698698
&ancestor_matcher, 0, 2, haplotype, match, &num_edges, &left, &right, &parent);

Diff for: lib/tsinfer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ typedef struct {
164164
size_t num_sites;
165165
size_t max_nodes;
166166
/* Input LS model rates */
167-
unsigned int precision;
167+
double likelihood_threshold;
168168
double *recombination_rate;
169169
double *mismatch_rate;
170170
/* The quintuply linked tree */
@@ -207,7 +207,7 @@ int ancestor_builder_finalise(ancestor_builder_t *self);
207207

208208
int ancestor_matcher_alloc(ancestor_matcher_t *self,
209209
tree_sequence_builder_t *tree_sequence_builder, double *recombination_rate,
210-
double *mismatch_rate, unsigned int precision, int flags);
210+
double *mismatch_rate, double likelihood_threshold, int flags);
211211
int ancestor_matcher_free(ancestor_matcher_t *self);
212212
int ancestor_matcher_find_path(ancestor_matcher_t *self, tsk_id_t start, tsk_id_t end,
213213
allele_t *haplotype, allele_t *matched_haplotype, size_t *num_output_edges,

0 commit comments

Comments
 (0)