treetime/gtr.py
def assign_rates(self, mu=1.0, pi=None, W=None):
        """
        Overwrite the GTR model given the provided data

        Parameters
        ----------

         mu : float
            Substitution rate

         W : nxn matrix
            Substitution matrix

         pi : n vector
            Equilibrium frequencies

        """
        n = len(self.alphabet)
        self.mu = mu

        if pi is not None and len(pi)==n:
            Pi = np.array(pi)
        else:
            if pi is not None and len(pi)!=n:
                self.logger("length of equilibrium frequency vector does not match alphabet length", 4, warn=True)
                self.logger("Ignoring input equilibrium frequencies", 4, warn=True)
            Pi = np.ones(shape=(n,))

        self.Pi = Pi/np.sum(Pi)

        if W is None or W.shape!=(n,n):
            if (W is not None) and W.shape!=(n,n):
                self.logger("Substitution matrix size does not match alphabet size", 4, warn=True)
                self.logger("Ignoring input substitution matrix", 4, warn=True)
            # flow matrix
            W = np.ones((n,n))
            np.fill_diagonal(W, 0.0)
            np.fill_diagonal(W, - W.sum(axis=0))
        else:
            W=np.array(W)

        self.W = 0.5*(W+W.T)
        self._check_fix_Q(fixed_mu=True)
        self._eig()
def assign_rates(self, mu=1.0, pi=None, W=None):
        """
        Overwrite the GTR model given the provided data

        Parameters
        ----------

         mu : float
            Substitution rate

         W : nxn matrix
            Substitution matrix

         pi : n vector
            Equilibrium frequencies

        """
        n = len(self.alphabet)
        self.mu = mu

        if pi is not None and len(pi)==n:
            Pi = np.array(pi)
        else:
            if pi is not None and len(pi)!=n:
                self.logger("length of equilibrium frequency vector does not match alphabet length", 4, warn=True)
                self.logger("Ignoring input equilibrium frequencies", 4, warn=True)
            Pi = np.ones(shape=(n,))

        self.Pi = Pi/np.sum(Pi)

        if W is None or W.shape!=(n,n):
            if (W is not None) and W.shape!=(n,n):
                self.logger("Substitution matrix size does not match alphabet size", 4, warn=True)
                self.logger("Ignoring input substitution matrix", 4, warn=True)
            # flow matrix
            W = np.ones((n,n))
            np.fill_diagonal(W, 0.0)
            np.fill_diagonal(W, - W.sum(axis=0))
        else:
            W=np.array(W)

        self.W = 0.5*(W+W.T)
        self._check_fix_Q(fixed_mu=True)
        self._eig()
def assign_rates ( self , mu = 1.0 , pi = None , W = None ) : n = len ( self . alphabet ) self . mu = mu if pi is not None and len ( pi ) == n : Pi = np . array ( pi ) else : if pi is not None and len ( pi ) != n : self . logger ( "length of equilibrium frequency vector does not match alphabet length" , 4 , warn = True ) self . logger ( "Ignoring input equilibrium frequencies" , 4 , warn = True ) Pi = np . ones ( shape = ( n , ) ) self . Pi = Pi / np . sum ( Pi ) if W is None or W . shape != ( n , n ) : if ( W is not None ) and W . shape != ( n , n ) : self . logger ( "Substitution matrix size does not match alphabet size" , 4 , warn = True ) self . logger ( "Ignoring input substitution matrix" , 4 , warn = True ) # flow matrix W = np . ones ( ( n , n ) ) np . fill_diagonal ( W , 0.0 ) np . fill_diagonal ( W , - W . sum ( axis = 0 ) ) else : W = np . array ( W ) self . W = 0.5 * ( W + W . T ) self . _check_fix_Q ( fixed_mu = True ) self . _eig ( )
Overwrite the GTR model given the provided data

        Parameters
        ----------

         mu : float
            Substitution rate

         W : nxn matrix
            Substitution matrix

         pi : n vector
            Equilibrium frequencies
Overwrite the GTR model given the provided data