Skip to content

Commit

Permalink
Allowing for zero rates in the custom rate matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
annazhukova committed Jul 13, 2021
1 parent 93b6207 commit 112cdb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 7 additions & 8 deletions pastml/acr.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from pastml.visualisation.itol_manager import generate_itol_annotations
from pastml.visualisation.tree_compressor import REASONABLE_NUMBER_OF_TIPS

PASTML_VERSION = '1.9.33'
PASTML_VERSION = '1.9.34'

warnings.filterwarnings("ignore", append=True)

Expand Down Expand Up @@ -289,10 +289,10 @@ def get_states(method, model, column):
if tau is None and tau_p is not None:
tau = tau_p
if freqs is not None and model not in {F81, HKY, CUSTOM_RATES}:
logging.warning('Some frequencies were specified in the parameter file, '
'but the selected model ({}) ignores them. '
'Use F81 (or HKY for nucleotide characters only) '
'for taking user-specified frequencies into account.'.format(model))
logger.warning('Some frequencies were specified in the parameter file, '
'but the selected model ({}) ignores them. '
'Use F81 (or HKY for nucleotide characters only) '
'for taking user-specified frequencies into account.'.format(model))
optimise_sf = not sf or reoptimise
if not sf:
sf = 1. / tree_stats[0]
Expand Down Expand Up @@ -342,10 +342,9 @@ def get_states(method, model, column):
else:
frequencies = np.ones(n, dtype=np.float64) / n
character2settings[character] = [prediction_method, model, states,
[frequencies, kappa, sf, tau, rate_matrix], \
[frequencies, kappa, sf, tau, rate_matrix],
[optimise_frequencies, optimise_kappa, optimise_sf, optimise_tau,
frequency_smoothing], \
observed_frequencies]
frequency_smoothing], observed_frequencies]
else:
raise ValueError('Method {} is unknown, should be one of ML ({}), one of MP ({}) or {}'
.format(prediction_method, ', '.join(ML_METHODS), ', '.join(MP_METHODS), COPY))
Expand Down
4 changes: 3 additions & 1 deletion pastml/models/rate_matrix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

import numpy as np

from pastml.models.generator import get_pij_matrix, get_diagonalisation
Expand Down Expand Up @@ -34,7 +36,7 @@ def load_custom_rates(infile):
np.fill_diagonal(rate_matrix, 0)
n = len(rate_matrix)
if np.count_nonzero(rate_matrix) != n * (n - 1):
raise ValueError('The rate matrix must not contain zero rates (apart from the diagonal).')
logging.getLogger('pastml').warning('The rate matrix contains zero rates (apart from the diagonal).')
with open(infile, 'r') as f:
states = f.readlines()[0]
if not states.startswith('#'):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Python Modules',
],
version='1.9.33',
version='1.9.34',
description='Ancestral character reconstruction and visualisation for rooted phylogenetic trees.',
author='Anna Zhukova',
author_email='anna.zhukova@pasteur.fr',
Expand Down

0 comments on commit 112cdb1

Please sign in to comment.