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
104
105
106
107
108
109 public Rotamer(double... values) {
110 length = values.length / 2;
111 angles = new double[max(length, 7)];
112 sigmas = new double[max(length, 7)];
113 nucleicAcid3 = null;
114 aminoAcid3 = null;
115 for (int i = 0; i < values.length / 2; i++) {
116 int ii = 2 * i;
117 angles[i] = values[ii];
118 sigmas[i] = values[ii + 1];
119 }
120 chi1 = angles[0];
121 chi2 = angles[1];
122 chi3 = angles[2];
123 chi4 = angles[3];
124 chi5 = angles[4];
125 chi6 = angles[5];
126 chi7 = angles[6];
127 originalState = null;
128 isState = false;
129 isTitrating = false;
130 }
131
132
133
134
135
136
137
138 public Rotamer(AminoAcid3 aminoAcid3, double... values) {
139 this(values);
140 this.aminoAcid3 = aminoAcid3;
141 }
142
143
144
145
146
147
148
149
150 public Rotamer(NucleicAcid3 nucleicAcid3, double... values) {
151 this(values);
152 this.nucleicAcid3 = nucleicAcid3;
153 }
154
155
156
157
158
159
160
161
162 public Rotamer(AminoAcid3 aminoAcid3, TitrationUtils titrationUtils, double... values) {
163 this(aminoAcid3, values);
164 if (titrationUtils != null) {
165 this.isTitrating = true;
166 this.titrationUtils = titrationUtils;
167 } else {
168 this.isTitrating = false;
169 }
170 }
171
172
173
174
175
176
177
178 public Rotamer(ResidueState residueState, double... values) {
179 this(values);
180 isState = true;
181 originalState = residueState;
182 }
183
184
185
186
187
188
189
190 public Rotamer(ResidueState residueState, TitrationUtils titrationUtils, double... values) {
191 this(residueState, values);
192 if (titrationUtils != null) {
193 this.titrationUtils = titrationUtils;
194 isTitrating = true;
195 }
196 }
197
198
199
200
201
202
203
204
205 public Rotamer(AminoAcid3 aminoAcid3, ResidueState residueState, double... values) {
206 this(residueState, values);
207 this.aminoAcid3 = aminoAcid3;
208 }
209
210
211
212
213
214
215
216
217 public Rotamer(AminoAcid3 aminoAcid3, ResidueState residueState, TitrationUtils titrationUtils,
218 double... values) {
219 this(aminoAcid3, residueState, values);
220 if (titrationUtils != null) {
221 this.titrationUtils = titrationUtils;
222 isTitrating = true;
223 }
224 }
225
226
227
228
229
230
231
232
233 public Rotamer(NucleicAcid3 nucleicAcid3, ResidueState residueState, double... values) {
234 this(residueState, values);
235 this.nucleicAcid3 = nucleicAcid3;
236 }
237
238
239
240
241
242
243
244
245 public Rotamer(NucleicAcid3 nucleicAcid3, ResidueState residueState, TitrationUtils titrationUtils,
246 double... values) {
247 this(nucleicAcid3, residueState, values);
248 if (titrationUtils != null) {
249 this.titrationUtils = titrationUtils;
250 isTitrating = true;
251 }
252 }
253
254
255
256
257
258
259 public void updateParameters(Residue residue) {
260 titrationUtils.updateResidueParameters(residue, this);
261 }
262
263
264
265
266
267
268
269 public static Rotamer[] defaultRotamerFactory(Residue residue) {
270 return defaultRotamerFactory(residue, null);
271 }
272
273
274
275
276
277
278
279 public static Rotamer[] defaultRotamerFactory(Residue residue, TitrationUtils titrationUtils) {
280 ResidueState resState = residue.storeState();
281 double[] chi = RotamerLibrary.measureRotamer(residue, false);
282
283 double[] values = new double[chi.length * 2];
284 for (int i = 0; i < chi.length; i++) {
285 int index = i * 2;
286 values[index] = chi[i];
287 values[index + 1] = 0.0;
288 }
289
290 switch (residue.getResidueType()) {
291 case AA:
292
293 if (titrationUtils == null) {
294 Rotamer[] rotamers = new Rotamer[1];
295 rotamers[0] = new Rotamer(residue.getAminoAcid3(), resState, titrationUtils, values);
296 return rotamers;
297 }
298 switch (residue.getAminoAcid3()) {
299 case ASH:
300 Rotamer[] rotamers = new Rotamer[2];
301 rotamers[0] = new Rotamer(AminoAcid3.ASP, resState, titrationUtils, values);
302 rotamers[1] = new Rotamer(AminoAcid3.ASH, resState, titrationUtils, values);
303 return rotamers;
304 case GLH:
305 rotamers = new Rotamer[2];
306 rotamers[0] = new Rotamer(AminoAcid3.GLU, resState, titrationUtils, values);
307 rotamers[1] = new Rotamer(AminoAcid3.GLH, resState, titrationUtils, values);
308 return rotamers;
309 case HIS:
310 rotamers = new Rotamer[3];
311 rotamers[0] = new Rotamer(AminoAcid3.HIS, resState, titrationUtils, values);
312 rotamers[1] = new Rotamer(AminoAcid3.HID, resState, titrationUtils, values);
313 rotamers[2] = new Rotamer(AminoAcid3.HIE, resState, titrationUtils, values);
314 return rotamers;
315 case LYS:
316 rotamers = new Rotamer[2];
317 rotamers[0] = new Rotamer(AminoAcid3.LYS, resState, titrationUtils, values);
318 rotamers[1] = new Rotamer(AminoAcid3.LYD, resState, titrationUtils, values);
319 return rotamers;
320 case CYS:
321 rotamers = new Rotamer[2];
322 rotamers[0] = new Rotamer(AminoAcid3.CYS, resState, titrationUtils, values);
323 rotamers[1] = new Rotamer(AminoAcid3.CYD, resState, titrationUtils, values);
324 return rotamers;
325 default:
326
327 rotamers = new Rotamer[1];
328 rotamers[0] = new Rotamer(residue.getAminoAcid3(), resState, null, values);
329 return rotamers;
330 }
331 case NA:
332
333 Rotamer[] rotamers = new Rotamer[1];
334 rotamers[0] = new Rotamer(residue.getNucleicAcid3(), resState, null, values);
335 return rotamers;
336 case UNK:
337 default:
338
339 rotamers = new Rotamer[1];
340 rotamers[0] = new Rotamer(resState, null, values);
341 return rotamers;
342 }
343 }
344
345
346
347
348
349
350 public String toAngleString() {
351 StringBuilder sb = new StringBuilder();
352 int n = max(4, length);
353 for (int i = 0; i < n; i++) {
354 sb.append(String.format(" %6.1f %4.1f", angles[i], sigmas[i]));
355 }
356 return sb.toString();
357 }
358
359
360 @Override
361 public String toString() {
362 StringBuilder sb = new StringBuilder(getName());
363 int n = max(4, length);
364 for (int i = 0; i < n; i++) {
365 sb.append(String.format(" %6.1f %4.1f", angles[i], sigmas[i]));
366 }
367 return sb.toString();
368 }
369
370 public String getName() {
371 if (aminoAcid3 != null) {
372 return aminoAcid3.toString();
373 } else if (nucleicAcid3 != null) {
374 return nucleicAcid3.toString();
375 } else {
376 return "";
377 }
378 }
379
380 public double getRotamerPhBias() {
381 return titrationUtils.getRotamerPhBias(aminoAcid3);
382 }
383
384 public double[] getAngles() {
385 return angles;
386 }
387
388 }