Skip to content

Commit

Permalink
Minor refactor and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Sep 1, 2023
1 parent 3cbff90 commit fcda0a8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions python/tests/beagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,15 @@ def compute_backward_probability_matrix(ref_h, query_h, rho, mu):
assert m == len(rho)
assert m == len(mu)
assert 0 <= np.min(rho) and np.max(rho) <= 1
# BEAGLE caps mismatch probabilities at 0.5.
assert 0 <= np.min(mu) and np.max(mu) <= 0.5
bm = np.zeros((m, h), dtype=np.float64)
# Initialise the last column
bm[-1, :] = 1.0 / h
bm[-1, :] = 1.0 / h # Initialise the last column
for i in np.arange(m - 2, -1, -1):
query_a = query_h[i + 1]
for j in np.arange(h):
ref_a = ref_h[i + 1, j]
em_prob = mu[i + 1] if ref_a != query_a else 1.0 - mu[i + 1]
# Note that BEAGLE only keeps the values at one site at a time.
# Note that BEAGLE keeps the values at one site at a time.
bm[i, j] = bm[i + 1, j] * em_prob
sum_site = np.sum(bm[i, :])
scale = (1 - rho[i + 1]) / sum_site
Expand Down

0 comments on commit fcda0a8

Please sign in to comment.