Skip to content

Instantly share code, notes, and snippets.

@kgori
Created October 1, 2014 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgori/cb66cab5dfae7e8757c3 to your computer and use it in GitHub Desktop.
Save kgori/cb66cab5dfae7e8757c3 to your computer and use it in GitHub Desktop.
PyCogent model specification for Le and Gascuel LG08 model
import numpy
from cogent.evolve import substitution_model
LG08_freqs = {
'A': 0.079066, 'C': 0.012937,
'D': 0.053052, 'E': 0.071586,
'F': 0.042302, 'G': 0.057337,
'H': 0.022355, 'I': 0.062157,
'K': 0.064600, 'L': 0.099081,
'M': 0.022951, 'N': 0.041977,
'P': 0.044040, 'Q': 0.040767,
'R': 0.055941, 'S': 0.061197,
'T': 0.053287, 'V': 0.069147,
'W': 0.012066, 'Y': 0.034155,
}
LG08_matrix = numpy.array([
[0., 2.489084, 0.395144, 1.038545, 0.253701,
2.066040, 0.358858, 0.149830, 0.536518, 0.395337,
1.124035, 0.276818, 1.177651, 0.969894, 0.425093,
4.727182, 2.139501, 2.547870, 0.180717, 0.218959],
[2.489084, 0., 0.062556, 0.003499, 1.105251,
0.569265, 0.640543, 0.320627, 0.013266, 0.594007,
0.893680, 0.528768, 0.075382, 0.084808, 0.534551,
2.784478, 1.143480, 1.959291, 0.670128, 1.165532],
[0.395144, 0.062556, 0., 5.243870, 0.017416,
0.844926, 0.927114, 0.010690, 0.282959, 0.015076,
0.025548, 5.076149, 0.394456, 0.523386, 0.123954,
1.240275, 0.425860, 0.037967, 0.029890, 0.135107],
[1.038545, 0.003499, 5.243870, 0., 0.018811,
0.348847, 0.423881, 0.044265, 1.807177, 0.069673,
0.173735, 0.541712, 0.419409, 4.128591, 0.363970,
0.611973, 0.604545, 0.245034, 0.077852, 0.120037],
[0.253701, 1.105251, 0.017416, 0.018811, 0.,
0.089586, 0.682139, 1.112727, 0.023918, 2.592692,
1.798853, 0.089525, 0.094464, 0.035855, 0.052722,
0.361819, 0.165001, 0.654683, 2.457121, 7.803902],
[2.066040, 0.569265, 0.844926, 0.348847, 0.089586,
0., 0.311484, 0.008705, 0.296636, 0.044261,
0.139538, 1.437645, 0.196961, 0.267959, 0.390192,
1.739990, 0.129836, 0.076701, 0.268491, 0.054679],
[0.358858, 0.640543, 0.927114, 0.423881, 0.682139,
0.311484, 0., 0.108882, 0.697264, 0.366317,
0.442472, 4.509238, 0.508851, 4.813505, 2.426601,
0.990012, 0.584262, 0.119013, 0.597054, 5.306834],
[0.149830, 0.320627, 0.010690, 0.044265, 1.112727,
0.008705, 0.108882, 0., 0.159069, 4.145067,
4.273607, 0.191503, 0.078281, 0.072854, 0.126991,
0.064105, 1.033739, 10.649107, 0.111660, 0.232523],
[0.536518, 0.013266, 0.282959, 1.807177, 0.023918,
0.296636, 0.697264, 0.159069, 0., 0.137500,
0.656604, 2.145078, 0.390322, 3.234294, 6.326067,
0.748683, 1.136863, 0.185202, 0.049906, 0.131932],
[0.395337, 0.594007, 0.015076, 0.069673, 2.592692,
0.044261, 0.366317, 4.145067, 0.137500, 0.,
6.312358, 0.068427, 0.249060, 0.582457, 0.301848,
0.182287, 0.302936, 1.702745, 0.619632, 0.299648],
[1.124035, 0.893680, 0.025548, 0.173735, 1.798853,
0.139538, 0.442472, 4.273607, 0.656604, 6.312358,
0., 0.371004, 0.099849, 1.672569, 0.484133,
0.346960, 2.020366, 1.898718, 0.696175, 0.481306],
[0.276818, 0.528768, 5.076149, 0.541712, 0.089525,
1.437645, 4.509238, 0.191503, 2.145078, 0.068427,
0.371004, 0., 0.161787, 1.695752, 0.751878,
4.008358, 2.000679, 0.083688, 0.045376, 0.612025],
[1.177651, 0.075382, 0.394456, 0.419409, 0.094464,
0.196961, 0.508851, 0.078281, 0.390322, 0.249060,
0.099849, 0.161787, 0., 0.624294, 0.332533,
1.338132, 0.571468, 0.296501, 0.095131, 0.089613],
[0.969894, 0.084808, 0.523386, 4.128591, 0.035855,
0.267959, 4.813505, 0.072854, 3.234294, 0.582457,
1.672569, 1.695752, 0.624294, 0., 2.807908,
1.223828, 1.080136, 0.210332, 0.236199, 0.257336],
[0.425093, 0.534551, 0.123954, 0.363970, 0.052722,
0.390192, 2.426601, 0.126991, 6.326067, 0.301848,
0.484133, 0.751878, 0.332533, 2.807908, 0.,
0.858151, 0.578987, 0.170887, 0.593607, 0.314440],
[4.727182, 2.784478, 1.240275, 0.611973, 0.361819,
1.739990, 0.990012, 0.064105, 0.748683, 0.182287,
0.346960, 4.008358, 1.338132, 1.223828, 0.858151,
0., 6.472279, 0.098369, 0.248862, 0.400547],
[2.139501, 1.143480, 0.425860, 0.604545, 0.165001,
0.129836, 0.584262, 1.033739, 1.136863, 0.302936,
2.020366, 2.000679, 0.571468, 1.080136, 0.578987,
6.472279, 0., 2.188158, 0.140825, 0.245841],
[2.547870, 1.959291, 0.037967, 0.245034, 0.654683,
0.076701, 0.119013, 10.649107, 0.185202, 1.702745,
1.898718, 0.083688, 0.296501, 0.210332, 0.170887,
0.098369, 2.188158, 0., 0.189510, 0.249313],
[0.180717, 0.670128, 0.029890, 0.077852, 2.457121,
0.268491, 0.597054, 0.111660, 0.049906, 0.619632,
0.696175, 0.045376, 0.095131, 0.236199, 0.593607,
0.248862, 0.140825, 0.189510, 0., 3.151815],
[0.218959, 1.165532, 0.135107, 0.120037, 7.803902,
0.054679, 5.306834, 0.232523, 0.131932, 0.299648,
0.481306, 0.612025, 0.089613, 0.257336, 0.314440,
0.400547, 0.245841, 0.249313, 3.151815, 0.]])
def LG08(**kw):
"""Whelan and Goldman 2001 empirical model for globular proteins.
Whelan S, Goldman N.
A general empirical model of protein evolution derived from multiple protein
families using a maximum-likelihood approach.
Mol Biol Evol. 2001 May;18(5):691-9.
Matrix imported from PAML wag.dat file"""
sm = substitution_model.EmpiricalProteinMatrix(
LG08_matrix,
LG08_freqs,
name='LG08',
**kw)
return sm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment