Skip to content

SubstitutionModel

Enums for available DNA (including Lie Markov Models) and amino acid models. Strings may be used instead of the enums.

piqtree.model.StandardDnaModel

Bases: SubstitutionModel, Enum

Standard DNA substitution models.

F81 = 'F81' class-attribute instance-attribute

GTR = 'GTR' class-attribute instance-attribute

HKY = 'HKY' class-attribute instance-attribute

HKY85 = 'HKY85' class-attribute instance-attribute

JC = 'JC' class-attribute instance-attribute

JC69 = 'JC69' class-attribute instance-attribute

K2P = 'K2P' class-attribute instance-attribute

K3P = 'K3P' class-attribute instance-attribute

K80 = 'K80' class-attribute instance-attribute

K81 = 'K81' class-attribute instance-attribute

K81u = 'K81u' class-attribute instance-attribute

STRSYM = 'STRSYM' class-attribute instance-attribute

SYM = 'SYM' class-attribute instance-attribute

TIM = 'TIM' class-attribute instance-attribute

TIM2 = 'TIM2' class-attribute instance-attribute

TIM2e = 'TIM2e' class-attribute instance-attribute

TIM3 = 'TIM3' class-attribute instance-attribute

TIM3e = 'TIM3e' class-attribute instance-attribute

TIMe = 'TIMe' class-attribute instance-attribute

TN = 'TN' class-attribute instance-attribute

TN93 = 'TN93' class-attribute instance-attribute

TNe = 'TNe' class-attribute instance-attribute

TPM2 = 'TPM2' class-attribute instance-attribute

TPM2u = 'TPM2u' class-attribute instance-attribute

TPM3 = 'TPM3' class-attribute instance-attribute

TPM3u = 'TPM3u' class-attribute instance-attribute

TVM = 'TVM' class-attribute instance-attribute

TVMe = 'TVMe' class-attribute instance-attribute

UNREST = 'UNREST' class-attribute instance-attribute

base_model property

description property

__call__(model_params=None)

Parameterise the model.

If parameters are not supplied, the model is not parameterised.

PARAMETER DESCRIPTION
model_params

The relative substitution rates, by default None

TYPE: Sequence[float] | None DEFAULT: None

RETURNS DESCRIPTION
StandardDnaModelInstance

The parameterised model.

Source code in src/piqtree/model/_substitution_model.py
def __call__(
    self,
    model_params: Sequence[float] | None = None,
) -> StandardDnaModelInstance:
    """Parameterise the model.

    If parameters are not supplied, the model is not parameterised.

    Parameters
    ----------
    model_params : Sequence[float] | None, optional
        The relative substitution rates, by default None

    Returns
    -------
    StandardDnaModelInstance
        The parameterised model.

    """
    return StandardDnaModelInstance(self, model_params)

get_moltype()

Source code in src/piqtree/model/_substitution_model.py
def get_moltype(self) -> Literal["dna", "protein"]:
    return "dna"

iqtree_str()

Source code in src/piqtree/model/_substitution_model.py
def iqtree_str(self) -> str:
    return self.value

iter_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def iter_available_models() -> Sequence["StandardDnaModel"]:
    return list(StandardDnaModel)

model_type() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def model_type() -> str:
    return "nucleotide"

num_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def num_available_models() -> int:
    return len(StandardDnaModel)

piqtree.model.StandardDnaModelInstance(dna_model, model_params=None) dataclass

Bases: SubstitutionModel

base_model property

description property

dna_model instance-attribute

model_params = None class-attribute instance-attribute

get_moltype()

Source code in src/piqtree/model/_substitution_model.py
def get_moltype(self) -> Literal["dna", "protein"]:
    return "dna"

iqtree_str()

Source code in src/piqtree/model/_substitution_model.py
def iqtree_str(self) -> str:
    params = (
        f"{{{','.join(map(str, self.model_params))}}}" if self.model_params else ""
    )
    return f"{self.dna_model.value}{params}"

iter_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def iter_available_models() -> Sequence["StandardDnaModel"]:
    return StandardDnaModel.iter_available_models()

model_type() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def model_type() -> str:
    return "nucleotide"

num_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def num_available_models() -> int:
    return StandardDnaModel.num_available_models()

piqtree.model.LieModel

Bases: SubstitutionModel, Enum

LIE_10_12 = '10.12' class-attribute instance-attribute

LIE_10_34 = '10.34' class-attribute instance-attribute

LIE_12_12 = '12.12' class-attribute instance-attribute

LIE_1_1 = '1.1' class-attribute instance-attribute

LIE_2_2b = '2.2b' class-attribute instance-attribute

LIE_3_3a = '3.3a' class-attribute instance-attribute

LIE_3_3b = '3.3b' class-attribute instance-attribute

LIE_3_3c = '3.3c' class-attribute instance-attribute

LIE_3_4 = '3.4' class-attribute instance-attribute

LIE_4_4a = '4.4a' class-attribute instance-attribute

LIE_4_4b = '4.4b' class-attribute instance-attribute

LIE_4_5a = '4.5a' class-attribute instance-attribute

LIE_4_5b = '4.5b' class-attribute instance-attribute

LIE_5_11a = '5.11a' class-attribute instance-attribute

LIE_5_11b = '5.11b' class-attribute instance-attribute

LIE_5_11c = '5.11c' class-attribute instance-attribute

LIE_5_16 = '5.16' class-attribute instance-attribute

LIE_5_6a = '5.6a' class-attribute instance-attribute

LIE_5_6b = '5.6b' class-attribute instance-attribute

LIE_5_7a = '5.7a' class-attribute instance-attribute

LIE_5_7b = '5.7b' class-attribute instance-attribute

LIE_5_7c = '5.7c' class-attribute instance-attribute

LIE_6_17a = '6.17a' class-attribute instance-attribute

LIE_6_17b = '6.17b' class-attribute instance-attribute

LIE_6_6 = '6.6' class-attribute instance-attribute

LIE_6_7a = '6.7a' class-attribute instance-attribute

LIE_6_7b = '6.7b' class-attribute instance-attribute

LIE_6_8a = '6.8a' class-attribute instance-attribute

LIE_6_8b = '6.8b' class-attribute instance-attribute

LIE_8_10a = '8.10a' class-attribute instance-attribute

LIE_8_10b = '8.10b' class-attribute instance-attribute

LIE_8_16 = '8.16' class-attribute instance-attribute

LIE_8_17 = '8.17' class-attribute instance-attribute

LIE_8_18 = '8.18' class-attribute instance-attribute

LIE_8_8 = '8.8' class-attribute instance-attribute

LIE_9_20a = '9.20a' class-attribute instance-attribute

LIE_9_20b = '9.20b' class-attribute instance-attribute

base_model property

description property

__call__(pairing=None, model_params=None)

Parameterise the model.

If parameters are not supplied, the model is not parameterised.

PARAMETER DESCRIPTION
pairing

The pairing type. RY: purine-pyrimidine pairing WS: weak-strong pairing MK: aMino-Keto pairing by default None (unparameterised uses RY).

TYPE: Literal['RY', 'WS', 'MK'] | None DEFAULT: None

model_params

The weights of the basis matrices, the weights should be bounded between -0.98 and 0.98 exclusive, by default None.

TYPE: Sequence[float] | None DEFAULT: None

RETURNS DESCRIPTION
LieModelInstance

The parameterised Lie Markov Model.

Source code in src/piqtree/model/_substitution_model.py
def __call__(
    self,
    pairing: lie_model_pairing | None = None,
    model_params: Sequence[float] | None = None,
) -> LieModelInstance:
    """Parameterise the model.

    If parameters are not supplied, the model is not parameterised.

    Parameters
    ----------
    pairing : Literal["RY", "WS", "MK"] | None, optional
        The pairing type.
        RY: purine-pyrimidine pairing
        WS: weak-strong pairing
        MK: aMino-Keto pairing
        by default None (unparameterised uses RY).
    model_params : Sequence[float] | None, optional
        The weights of the basis matrices, the weights should be
        bounded between -0.98 and 0.98 exclusive, by default None.

    Returns
    -------
    LieModelInstance
        The parameterised Lie Markov Model.

    """
    return LieModelInstance(self, pairing, model_params)

get_moltype()

Source code in src/piqtree/model/_substitution_model.py
def get_moltype(self) -> Literal["dna", "protein"]:
    return "dna"

iqtree_str()

Source code in src/piqtree/model/_substitution_model.py
def iqtree_str(self) -> str:
    return self.value

iter_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def iter_available_models() -> Sequence[LieModelInstance]:
    return LieModelInstance.iter_available_models()

model_type() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def model_type() -> str:
    return "nucleotide"

num_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def num_available_models() -> int:
    return LieModelInstance.num_available_models()

piqtree.model.LieModelInstance(lie_model, pairing=None, model_params=None) dataclass

Bases: SubstitutionModel

base_model property

description property

lie_model instance-attribute

model_params = None class-attribute instance-attribute

pairing = None class-attribute instance-attribute

pairing_descriptions = {'RY': 'purine-pyrimidine pairing (default).', 'WS': 'weak-strong pairing.', 'MK': 'aMino-Keto pairing'} class-attribute

valid_pairings = ('RY', 'WS', 'MK') class-attribute

__post_init__()

Source code in src/piqtree/model/_substitution_model.py
def __post_init__(self) -> None:
    if (
        self.pairing is not None
        and self.pairing not in LieModelInstance.valid_pairings
    ):
        msg = f"Invalid Lie Model pairing prefix: '{self.pairing}'"
        raise ValueError(msg)

get_moltype()

Source code in src/piqtree/model/_substitution_model.py
def get_moltype(self) -> Literal["dna", "protein"]:
    return "dna"

iqtree_str()

Source code in src/piqtree/model/_substitution_model.py
def iqtree_str(self) -> str:
    prefix = self.pairing or ""
    params = (
        f"{{{','.join(map(str, self.model_params))}}}" if self.model_params else ""
    )
    return f"{prefix}{self.lie_model.value}{params}"

iter_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def iter_available_models() -> Sequence["LieModelInstance"]:
    return [
        LieModelInstance(lie_model, prefix)
        for prefix in (None, *LieModelInstance.valid_pairings)
        for lie_model in LieModel
    ]

model_type() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def model_type() -> str:
    return "nucleotide"

num_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def num_available_models() -> int:
    return (len(LieModelInstance.valid_pairings) + 1) * len(LieModel)

piqtree.model.AaModel

Bases: SubstitutionModel, Enum

Protein substitution models.

Blosum62 = 'Blosum62' class-attribute instance-attribute

DCMut = 'DCMut' class-attribute instance-attribute

Dayhoff = 'Dayhoff' class-attribute instance-attribute

EAL = 'EAL' class-attribute instance-attribute

ELM = 'ELM' class-attribute instance-attribute

FLAVI = 'FLAVI' class-attribute instance-attribute

FLU = 'FLU' class-attribute instance-attribute

GTR20 = 'GTR20' class-attribute instance-attribute

HIVb = 'HIVb' class-attribute instance-attribute

HIVw = 'HIVw' class-attribute instance-attribute

JTT = 'JTT' class-attribute instance-attribute

JTTDCMut = 'JTTDCMut' class-attribute instance-attribute

LG = 'LG' class-attribute instance-attribute

NQ_bird = 'NQ.bird' class-attribute instance-attribute

NQ_insect = 'NQ.insect' class-attribute instance-attribute

NQ_mammal = 'NQ.mammal' class-attribute instance-attribute

NQ_pfam = 'NQ.pfam' class-attribute instance-attribute

NQ_plant = 'NQ.plant' class-attribute instance-attribute

NQ_yeast = 'NQ.yeast' class-attribute instance-attribute

PMB = 'PMB' class-attribute instance-attribute

Poisson = 'Poisson' class-attribute instance-attribute

Q_bird = 'Q.bird' class-attribute instance-attribute

Q_insect = 'Q.insect' class-attribute instance-attribute

Q_mammal = 'Q.mammal' class-attribute instance-attribute

Q_pfam = 'Q.pfam' class-attribute instance-attribute

Q_plant = 'Q.plant' class-attribute instance-attribute

Q_yeast = 'Q.yeast' class-attribute instance-attribute

VT = 'VT' class-attribute instance-attribute

WAG = 'WAG' class-attribute instance-attribute

base_model property

cpREV = 'cpREV' class-attribute instance-attribute

description property

mtART = 'mtART' class-attribute instance-attribute

mtInv = 'mtInv' class-attribute instance-attribute

mtMAM = 'mtMAM' class-attribute instance-attribute

mtMet = 'mtMet' class-attribute instance-attribute

mtREV = 'mtREV' class-attribute instance-attribute

mtVer = 'mtVer' class-attribute instance-attribute

mtZOA = 'mtZOA' class-attribute instance-attribute

rtREV = 'rtREV' class-attribute instance-attribute

get_moltype()

Source code in src/piqtree/model/_substitution_model.py
def get_moltype(self) -> Literal["dna", "protein"]:
    return "protein"

iqtree_str()

Source code in src/piqtree/model/_substitution_model.py
def iqtree_str(self) -> str:
    return self.value

iter_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def iter_available_models() -> Sequence["AaModel"]:
    return list(AaModel)

model_type() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def model_type() -> str:
    return "protein"

num_available_models() staticmethod

Source code in src/piqtree/model/_substitution_model.py
@staticmethod
def num_available_models() -> int:
    return len(AaModel)

Usage

For usage, see "Use different kinds of substitution models".