Skip to content

Commit

Permalink
fix: catch profiles=True and calculate hamming distance appropriatly
Browse files Browse the repository at this point in the history
  • Loading branch information
rneher committed Mar 21, 2024
1 parent 99a3929 commit 8beeba7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion treetime/gtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,11 @@ def _neg_prob(t, seq_pair, multiplicity):
else:
return -1.0*self.prob_t_compressed(seq_pair, multiplicity,t**2, return_log=True)

hamming_distance = np.sum(multiplicity[seq_pair[:,1]!=seq_pair[:,0]])/np.sum(multiplicity)
if profiles:
hamming_distance = 1-np.sum(multiplicity*np.sum(seq_pair[0]*seq_pair[1], axis=1))/np.sum(multiplicity)
else:
hamming_distance = np.sum(multiplicity[seq_pair[:,1]!=seq_pair[:,0]])/np.sum(multiplicity)

try:
from scipy.optimize import minimize_scalar
opt = minimize_scalar(_neg_prob,
Expand Down

0 comments on commit 8beeba7

Please sign in to comment.