From 112cdb141c3d96840ad0ff0224f4808188c92142 Mon Sep 17 00:00:00 2001 From: Anna Zhukova Date: Tue, 13 Jul 2021 16:58:48 +0200 Subject: [PATCH] Allowing for zero rates in the custom rate matrix --- pastml/acr.py | 15 +++++++-------- pastml/models/rate_matrix.py | 4 +++- setup.py | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pastml/acr.py b/pastml/acr.py index 066e528..0fb4dc7 100755 --- a/pastml/acr.py +++ b/pastml/acr.py @@ -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) @@ -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] @@ -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)) diff --git a/pastml/models/rate_matrix.py b/pastml/models/rate_matrix.py index cf3491f..c45f7eb 100755 --- a/pastml/models/rate_matrix.py +++ b/pastml/models/rate_matrix.py @@ -1,3 +1,5 @@ +import logging + import numpy as np from pastml.models.generator import get_pij_matrix, get_diagonalisation @@ -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('#'): diff --git a/setup.py b/setup.py index c00b72f..4436bb4 100755 --- a/setup.py +++ b/setup.py @@ -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',