1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.potential.bonded;
39
40 import static org.apache.commons.math3.util.FastMath.max;
41
42 import ffx.potential.bonded.AminoAcidUtils.AminoAcid3;
43 import ffx.potential.bonded.NucleicAcidUtils.NucleicAcid3;
44 import ffx.potential.parameters.TitrationUtils;
45
46
47
48
49
50
51
52
53
54
55 public class Rotamer {
56
57
58 public final double chi1;
59 public final double chi2;
60 public final double chi3;
61 public final double chi4;
62
63 public final double chi5;
64 final double chi6;
65 final double chi7;
66
67
68
69
70 public final double[] angles;
71
72
73
74 public final double[] sigmas;
75
76
77
78 public final int length;
79
80
81
82 public ResidueState originalState;
83
84
85
86 public boolean isState;
87
88
89
90 public AminoAcid3 aminoAcid3;
91
92
93
94 public NucleicAcid3 nucleicAcid3;
95
96
97
98 public boolean isTitrating;
99
100
101
102 private TitrationUtils titrationUtils = null;
103 private int rotIndex;
104
105
106
107
108
109
110 public Rotamer(double... values) {
111 length = values.length / 2;
112 angles = new double[max(length, 7)];
113 sigmas = new double[max(length, 7)];
114 nucleicAcid3 = null;
115 aminoAcid3 = null;
116 for (int i = 0; i < values.length / 2; i++) {
117 int ii = 2 * i;
118 angles[i] = values[ii];
119 sigmas[i] = values[ii + 1];
120 }
121 chi1 = angles[0];
122 chi2 = angles[1];
123 chi3 = angles[2];
124 chi4 = angles[3];
125 chi5 = angles[4];
126 chi6 = angles[5];
127 chi7 = angles[6];
128 originalState = null;
129 isState = false;
130 isTitrating = false;
131 }
132
133
134
135
136
137
138
139 public Rotamer(AminoAcid3 aminoAcid3, double... values) {
140 this(values);
141 this.aminoAcid3 = aminoAcid3;
142 }
143
144
145
146
147
148
149
150 public Rotamer(AminoAcid3 aminoAcid3, int rotIndex, double... values) {
151 this(values);
152 this.aminoAcid3 = aminoAcid3;
153 this.rotIndex = rotIndex;
154 }
155
156
157
158
159
160
161
162
163 public Rotamer(NucleicAcid3 nucleicAcid3, double... values) {
164 this(values);
165 this.nucleicAcid3 = nucleicAcid3;
166 }
167
168
169
170
171
172
173
174
175 public Rotamer(AminoAcid3 aminoAcid3, TitrationUtils titrationUtils, double... values) {
176 this(aminoAcid3, values);
177 if (titrationUtils != null) {
178 this.isTitrating = true;
179 this.titrationUtils = titrationUtils;
180 } else {
181 this.isTitrating = false;
182 }
183 }
184
185 public Rotamer(AminoAcid3 aminoAcid3, TitrationUtils titrationUtils, int rotIndex, double... values) {
186 this(aminoAcid3, values);
187 if (titrationUtils != null) {
188 this.isTitrating = true;
189 this.titrationUtils = titrationUtils;
190 this.rotIndex = rotIndex;
191 } else {
192 this.isTitrating = false;
193 }
194 }
195
196
197
198
199
200
201
202 public Rotamer(ResidueState residueState, double... values) {
203 this(values);
204 isState = true;
205 originalState = residueState;
206 }
207
208
209
210
211
212
213
214 public Rotamer(ResidueState residueState, TitrationUtils titrationUtils, double... values) {
215 this(residueState, values);
216 if (titrationUtils != null) {
217 this.titrationUtils = titrationUtils;
218 isTitrating = true;
219 }
220 }
221
222
223
224
225
226
227
228
229 public Rotamer(AminoAcid3 aminoAcid3, ResidueState residueState, double... values) {
230 this(residueState, values);
231 this.aminoAcid3 = aminoAcid3;
232 }
233
234
235
236
237
238
239
240
241 public Rotamer(AminoAcid3 aminoAcid3, ResidueState residueState, TitrationUtils titrationUtils,
242 double... values) {
243 this(aminoAcid3, residueState, values);
244 if (titrationUtils != null) {
245 this.titrationUtils = titrationUtils;
246 isTitrating = true;
247 }
248 }
249
250
251
252
253
254
255
256
257 public Rotamer(NucleicAcid3 nucleicAcid3, ResidueState residueState, double... values) {
258 this(residueState, values);
259 this.nucleicAcid3 = nucleicAcid3;
260 }
261
262
263
264
265
266
267
268
269 public Rotamer(NucleicAcid3 nucleicAcid3, ResidueState residueState, TitrationUtils titrationUtils,
270 double... values) {
271 this(nucleicAcid3, residueState, values);
272 if (titrationUtils != null) {
273 this.titrationUtils = titrationUtils;
274 isTitrating = true;
275 }
276 }
277
278
279
280
281
282
283 public void updateParameters(Residue residue) {
284 titrationUtils.updateResidueParameters(residue, this);
285 }
286
287
288
289
290
291
292
293 public static Rotamer[] defaultRotamerFactory(Residue residue) {
294 return defaultRotamerFactory(residue, null);
295 }
296
297
298
299
300
301
302
303 public static Rotamer[] defaultRotamerFactory(Residue residue, TitrationUtils titrationUtils) {
304 ResidueState resState = residue.storeState();
305 double[] chi = RotamerLibrary.measureRotamer(residue, false);
306
307 double[] values = new double[chi.length * 2];
308 for (int i = 0; i < chi.length; i++) {
309 int index = i * 2;
310 values[index] = chi[i];
311 values[index + 1] = 0.0;
312 }
313
314 switch (residue.getResidueType()) {
315 case AA:
316
317 if (titrationUtils == null) {
318 Rotamer[] rotamers = new Rotamer[1];
319 rotamers[0] = new Rotamer(residue.getAminoAcid3(), resState, titrationUtils, values);
320 return rotamers;
321 }
322 switch (residue.getAminoAcid3()) {
323 case ASH:
324 Rotamer[] rotamers = new Rotamer[2];
325 rotamers[0] = new Rotamer(AminoAcid3.ASP, resState, titrationUtils, values);
326 rotamers[1] = new Rotamer(AminoAcid3.ASH, resState, titrationUtils, values);
327 return rotamers;
328 case GLH:
329 rotamers = new Rotamer[2];
330 rotamers[0] = new Rotamer(AminoAcid3.GLU, resState, titrationUtils, values);
331 rotamers[1] = new Rotamer(AminoAcid3.GLH, resState, titrationUtils, values);
332 return rotamers;
333 case HIS:
334 rotamers = new Rotamer[3];
335 rotamers[0] = new Rotamer(AminoAcid3.HIS, resState, titrationUtils, values);
336 rotamers[1] = new Rotamer(AminoAcid3.HID, resState, titrationUtils, values);
337 rotamers[2] = new Rotamer(AminoAcid3.HIE, resState, titrationUtils, values);
338 return rotamers;
339 case LYS:
340 rotamers = new Rotamer[2];
341 rotamers[0] = new Rotamer(AminoAcid3.LYS, resState, titrationUtils, values);
342 rotamers[1] = new Rotamer(AminoAcid3.LYD, resState, titrationUtils, values);
343 return rotamers;
344 case CYS:
345 rotamers = new Rotamer[2];
346 rotamers[0] = new Rotamer(AminoAcid3.CYS, resState, titrationUtils, values);
347 rotamers[1] = new Rotamer(AminoAcid3.CYD, resState, titrationUtils, values);
348 return rotamers;
349 default:
350
351 rotamers = new Rotamer[1];
352 rotamers[0] = new Rotamer(residue.getAminoAcid3(), resState, null, values);
353 return rotamers;
354 }
355 case NA:
356
357 Rotamer[] rotamers = new Rotamer[1];
358 rotamers[0] = new Rotamer(residue.getNucleicAcid3(), resState, null, values);
359 return rotamers;
360 case UNK:
361 default:
362
363 rotamers = new Rotamer[1];
364 rotamers[0] = new Rotamer(resState, null, values);
365 return rotamers;
366 }
367 }
368
369
370
371
372
373
374 public String toAngleString() {
375 StringBuilder sb = new StringBuilder();
376 int n = max(4, length);
377 for (int i = 0; i < n; i++) {
378 sb.append(String.format(" %6.1f %4.1f", angles[i], sigmas[i]));
379 }
380 return sb.toString();
381 }
382
383
384 @Override
385 public String toString() {
386 StringBuilder sb = new StringBuilder(getName());
387 int n = max(4, length);
388 for (int i = 0; i < n; i++) {
389 sb.append(String.format(" %6.1f %4.1f", angles[i], sigmas[i]));
390 }
391 return sb.toString();
392 }
393
394 public String getName() {
395 if (aminoAcid3 != null) {
396 return aminoAcid3.toString();
397 } else if (nucleicAcid3 != null) {
398 return nucleicAcid3.toString();
399 } else {
400 return "";
401 }
402 }
403
404 public int getRotIndex() {return rotIndex;}
405
406 public double getRotamerPhBias() {
407 return titrationUtils.getRotamerPhBias(aminoAcid3);
408 }
409
410 public double[] getAngles() {
411 return angles;
412 }
413
414 }