1/********* JTT MODEL OF PROTEIN EVOLUTION ************/
2LoadFunctionLibrary("../empirical.bf");
3LoadFunctionLibrary("../../protein.bf");
4LoadFunctionLibrary("../../parameters.bf");
5LoadFunctionLibrary("../../frequencies.bf");
6LoadFunctionLibrary("../../../UtilityFunctions.bf");
7LoadFunctionLibrary("../../../all-terms.bf");
8
9
10
11/**
12 * @name models.protein.JTT.ModelDescription
13 * @description Create the baseline schema (dictionary) for the JTT model of protein evolution
14 * @returns {Dictionary} model description
15 * @param {String} type
16 */
17function models.protein.JTT.ModelDescription(type) {
18    models.protein.JTT.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type);
19    models.protein.JTT.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.JTT.Rij;
20    models.protein.JTT.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.JTT.frequencies";
21    return models.protein.JTT.ModelDescription.model_definition;
22}
23
24/**
25 * @name models.protein.JTTF.ModelDescription
26 * @description Create the baseline schema (dictionary) for the JTT+F model of protein evolution
27 * @returns {Dictionary} model description
28 * @param {String} type
29 */
30function models.protein.JTTF.ModelDescription(type) {
31    models.protein.JTTF.ModelDescription.model_definition = models.protein.JTT.ModelDescription(type);
32    models.protein.JTTF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein";
33    models.protein.JTTF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1");
34    return models.protein.JTTF.ModelDescription.model_definition;
35}
36
37/**
38 * @name models.protein.JTTML.ModelDescription
39 * @description Create the baseline schema (dictionary) for the JTT+ML model of protein evolution
40 * @returns {Dictionary} model description
41 * @param {String} type
42 */
43function models.protein.JTTML.ModelDescription(type) {
44    models.protein.JTTML.ModelDescription.model_definition = models.protein.JTT.ModelDescription(type);
45    models.protein.JTTML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein";
46    models.protein.JTTML.ModelDescription.model_definition [terms.model.efv_estimate_name]   =  utility.getGlobalValue("terms.frequencies.MLE");
47    return models.protein.JTTML.ModelDescription.model_definition;
48}
49
50/* Define a dictionary of amino-acid exchangeability rates for the JTT model of protein evolution. */
51models.protein.JTT.Rij = {
52'A': {'C': 0.56,
53       'D': 0.81,
54       'E': 1.05,
55       'F': 0.15,
56       'G': 1.79,
57       'H': 0.27,
58       'I': 0.36,
59       'K': 0.35,
60       'L': 0.30,
61       'M': 0.54,
62       'N': 0.54,
63       'P': 1.94,
64       'Q': 0.57,
65       'R': 0.58,
66       'S': 3.78,
67       'T': 4.75,
68       'V': 2.98,
69       'W': 0.09,
70       'Y': 0.11},
71 'C': {'D': 0.10,
72       'E': 0.05,
73       'F': 0.78,
74       'G': 0.59,
75       'H': 0.69,
76       'I': 0.17,
77       'K': 0.07,
78       'L': 0.23,
79       'M': 0.31,
80       'N': 0.34,
81       'P': 0.14,
82       'Q': 0.09,
83       'R': 1.13,
84       'S': 2.23,
85       'T': 0.42,
86       'V': 0.62,
87       'W': 1.15,
88       'Y': 2.09},
89 'D': {'E': 7.67,
90       'F': 0.04,
91       'G': 1.30,
92       'H': 1.12,
93       'I': 0.11,
94       'K': 0.26,
95       'L': 0.07,
96       'M': 0.15,
97       'N': 5.28,
98       'P': 0.15,
99       'Q': 0.49,
100       'R': 0.16,
101       'S': 0.59,
102       'T': 0.38,
103       'V': 0.31,
104       'W': 0.04,
105       'Y': 0.46},
106 'E': {'F': 0.05,
107       'G': 1.19,
108       'H': 0.26,
109       'I': 0.12,
110       'K': 1.81,
111       'L': 0.09,
112       'M': 0.18,
113       'N': 0.58,
114       'P': 0.18,
115       'Q': 3.23,
116       'R': 0.29,
117       'S': 0.30,
118       'T': 0.32,
119       'V': 0.45,
120       'W': 0.10,
121       'Y': 0.07},
122 'F': {'G': 0.05,
123       'H': 0.40,
124       'I': 0.89,
125       'K': 0.04,
126       'L': 2.48,
127       'M': 0.43,
128       'N': 0.10,
129       'P': 0.17,
130       'Q': 0.04,
131       'R': 0.05,
132       'S': 0.92,
133       'T': 0.12,
134       'V': 0.62,
135       'W': 0.53,
136       'Y': 5.36},
137 'G': {'H': 0.23,
138       'I': 0.06,
139       'K': 0.27,
140       'L': 0.06,
141       'M': 0.14,
142       'N': 0.81,
143       'P': 0.24,
144       'Q': 0.26,
145       'R': 1.37,
146       'S': 2.01,
147       'T': 0.33,
148       'V': 0.47,
149       'W': 0.55,
150       'Y': 0.08},
151 'H': {'I': 0.16,
152       'K': 0.45,
153       'L': 0.56,
154       'M': 0.33,
155       'N': 3.91,
156       'P': 1.15,
157       'Q': 5.97,
158       'R': 3.28,
159       'S': 0.73,
160       'T': 0.46,
161       'V': 0.11,
162       'W': 0.08,
163       'Y': 5.73},
164 'I': {'K': 0.21,
165       'L': 2.29,
166       'M': 4.79,
167       'N': 0.47,
168       'P': 0.10,
169       'Q': 0.09,
170       'R': 0.22,
171       'S': 0.40,
172       'T': 2.45,
173       'V': 9.61,
174       'W': 0.09,
175       'Y': 0.32},
176 'K': {'L': 0.14,
177       'M': 0.65,
178       'N': 2.63,
179       'P': 0.21,
180       'Q': 2.92,
181       'R': 6.46,
182       'S': 0.47,
183       'T': 1.03,
184       'V': 0.14,
185       'W': 0.10,
186       'Y': 0.08},
187 'L': {'M': 3.88,
188       'N': 0.12,
189       'P': 1.02,
190       'Q': 0.72,
191       'R': 0.38,
192       'S': 0.59,
193       'T': 0.25,
194       'V': 1.80,
195       'W': 0.52,
196       'Y': 0.24},
197 'M': {'N': 0.30,
198       'P': 0.16,
199       'Q': 0.43,
200       'R': 0.44,
201       'S': 0.29,
202       'T': 2.26,
203       'V': 3.23,
204       'W': 0.24,
205       'Y': 0.18},
206 'N': {'P': 0.15,
207       'Q': 0.86,
208       'R': 0.45,
209       'S': 5.03,
210       'T': 2.32,
211       'V': 0.16,
212       'W': 0.08,
213       'Y': 0.70},
214 'P': {'Q': 1.64,
215       'R': 0.74,
216       'S': 2.85,
217       'T': 1.18,
218       'V': 0.23,
219       'W': 0.06,
220       'Y': 0.10},
221 'Q': {'R': 3.10,
222       'S': 0.53,
223       'T': 0.51,
224       'V': 0.20,
225       'W': 0.18,
226       'Y': 0.24},
227 'R': {'S': 1.01, 'T': 0.64, 'V': 0.17, 'W': 1.26, 'Y': 0.20},
228 'S': {'T': 4.77, 'V': 0.38, 'W': 0.35, 'Y': 0.63},
229 'T': {'V': 1.12, 'W': 0.12, 'Y': 0.21},
230 'V': {'W': 0.25, 'Y': 0.16},
231 'W': {'Y': 0.71},
232 'Y': {}};
233
234
235/**
236 * @name models.protein.JTT.frequencies
237 * @param {Dictionary} Baseline JTT model
238 * @returns {Dictionary} Updated JTT model with empirical frequencies
239 * @description Define the empirical amino acid frequencies associated with the JTT model of protein evolution
240 */
241lfunction models.protein.JTT.frequencies (model, namespace, datafilter) {
242    model[utility.getGlobalValue("terms.efv_estimate")] =
243        {{0.076748}
244        {0.019803}
245        {0.051544}
246        {0.061830}
247        {0.040126}
248        {0.073152}
249        {0.022944}
250        {0.053761}
251        {0.058676}
252        {0.091904}
253        {0.023826}
254        {0.042645}
255        {0.050901}
256        {0.040752}
257        {0.051691}
258        {0.068765}
259        {0.058565}
260        {0.066005}
261        {0.014261}
262        {0.032102}};
263
264    model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined");
265    (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0;
266    return model;
267}
268
269
270