View Javadoc
1   // ******************************************************************************
2   //
3   // Title:       Force Field X.
4   // Description: Force Field X - Software for Molecular Biophysics.
5   // Copyright:   Copyright (c) Michael J. Schnieders 2001-2021.
6   //
7   // This file is part of Force Field X.
8   //
9   // Force Field X is free software; you can redistribute it and/or modify it
10  // under the terms of the GNU General Public License version 3 as published by
11  // the Free Software Foundation.
12  //
13  // Force Field X is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  // details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA 02111-1307 USA
21  //
22  // Linking this library statically or dynamically with other modules is making a
23  // combined work based on this library. Thus, the terms and conditions of the
24  // GNU General Public License cover the whole combination.
25  //
26  // As a special exception, the copyright holders of this library give you
27  // permission to link this library with independent modules to produce an
28  // executable, regardless of the license terms of these independent modules, and
29  // to copy and distribute the resulting executable under terms of your choice,
30  // provided that you also meet, for each linked independent module, the terms
31  // and conditions of the license of that module. An independent module is a
32  // module which is not derived from or based on this library. If you modify this
33  // library, you may extend this exception to your version of the library, but
34  // you are not obligated to do so. If you do not wish to do so, delete this
35  // exception statement from your version.
36  //
37  // ******************************************************************************
38  package ffx.potential.utils;
39  
40  import static ffx.potential.bonded.BondedUtils.determineIntxyz;
41  import static java.lang.System.arraycopy;
42  
43  import ffx.potential.MolecularAssembly;
44  import ffx.potential.bonded.AminoAcidUtils;
45  import ffx.potential.bonded.AminoAcidUtils.AminoAcid3;
46  import ffx.potential.bonded.Angle;
47  import ffx.potential.bonded.Atom;
48  import ffx.potential.bonded.Bond;
49  import ffx.potential.bonded.Polymer;
50  import ffx.potential.bonded.Residue;
51  import java.util.ArrayList;
52  import java.util.List;
53  import java.util.Random;
54  import java.util.logging.Logger;
55  
56  /**
57   * Loop class.
58   *
59   * @author Mallory R. Tollefson
60   * @since 1.0
61   */
62  public class Loop {
63  
64    private static final Logger logger = Logger.getLogger(Loop.class.getName());
65    public final LoopClosure loopClosure;
66    private final MolecularAssembly molecularAssembly;
67    private final Random random = new Random();
68    int maxSolution = 16;
69    double[][] rN = new double[3][3];
70    double[][] rA = new double[3][3];
71    double[][] rC = new double[3][3];
72    private double[][] altCoords;
73    private boolean useAltCoords = false;
74  
75    /**
76     * Constructor for Loop.
77     *
78     * @param molecularAssembly a {@link ffx.potential.MolecularAssembly} object.
79     * @param firstResidue a int.
80     * @param endResidue a int.
81     */
82    public Loop(MolecularAssembly molecularAssembly, int firstResidue, int endResidue) {
83      loopClosure = new LoopClosure();
84      this.molecularAssembly = molecularAssembly;
85      generateLoops(firstResidue, endResidue);
86    }
87  
88    /**
89     * Constructor for Loop.
90     *
91     * @param molecularAssembly a {@link ffx.potential.MolecularAssembly} object.
92     */
93    public Loop(MolecularAssembly molecularAssembly) {
94      loopClosure = new LoopClosure();
95      this.molecularAssembly = molecularAssembly;
96      this.altCoords = new double[molecularAssembly.getAtomArray().length][3];
97    }
98  
99    /**
100    * generateLoops.
101    *
102    * @param firstResidue a int.
103    * @param endResidue a int.
104    * @param coordinates an array of {@link double} objects.
105    * @return a {@link java.util.List} object.
106    */
107   public List<double[]> generateLoops(int firstResidue, int endResidue, double[] coordinates) {
108     setAltCoordinates(coordinates);
109     return generateLoops(firstResidue, endResidue);
110   }
111 
112   /**
113    * generateLoops.
114    *
115    * @param firstResidue a int.
116    * @param endResidue a int.
117    * @return a {@link java.util.List} object.
118    */
119   public List<double[]> generateLoops(int firstResidue, int endResidue) {
120     List<Atom> backBoneAtoms = molecularAssembly.getBackBoneAtoms();
121 
122     boolean bool1 = true;
123     int i = 0;
124     List<double[]> solutions = new ArrayList<>();
125     logger.info(String.format(" First residue:   %d\n", firstResidue));
126     logger.info(String.format(" Ending residue:  %d\n", endResidue));
127     while (bool1) {
128       Atom atom = backBoneAtoms.get(i);
129       int resID = atom.getResidueNumber();
130       if (resID > endResidue) {
131         // terminates the collection of atom coordinates
132         bool1 = false;
133       }
134 
135       if (resID < firstResidue) {
136         i++;
137       } else if (resID >= firstResidue && resID <= endResidue) {
138         int ir = resID - firstResidue;
139         String atmname = atom.getAtomType().name;
140         String ca = "CA";
141         String c = "C";
142         String n = "N";
143         // coordinateArray temporarily holds the coordinates of a
144         //      specific atom from the pdb file
145         double[] initArray;
146         if (useAltCoords) {
147           initArray = altCoords[atom.getIndex() - 1];
148         } else {
149           initArray = atom.getXYZ(null);
150         }
151         if (atmname.contentEquals(n)) {
152           // Backbone nitrogen coordinates are stored in rN[]
153           rN[ir][0] = initArray[0];
154           rN[ir][1] = initArray[1];
155           rN[ir][2] = initArray[2];
156         } else if (atmname.contentEquals(ca)) {
157           // Backbone alpha carbon coordinates are stored in rA[]
158           rA[ir][0] = initArray[0];
159           rA[ir][1] = initArray[1];
160           rA[ir][2] = initArray[2];
161         } else if (atmname.contentEquals(c)) {
162           // Backbone carbon coordinates are stored in rC[]
163           rC[ir][0] = initArray[0];
164           rC[ir][1] = initArray[1];
165           rC[ir][2] = initArray[2];
166         }
167         i++;
168       }
169     }
170 
171     /** Method that solves the 16th degree, 3 peptide polynomial. */
172     double[][][] rSolnN = new double[maxSolution][3][3];
173     double[][][] rSolnA = new double[maxSolution][3][3];
174     double[][][] rSolnC = new double[maxSolution][3][3];
175     int[] nSoln = new int[1];
176 
177     loopClosure.solve3PepPoly(rN[0], rA[0], rA[2], rC[2], rSolnN, rSolnA, rSolnC, nSoln);
178 
179     StringBuilder sb = new StringBuilder();
180     sb.append(String.format(" First residue:                %d\n", firstResidue));
181     sb.append(String.format(" Ending residue:               %d\n", endResidue));
182     sb.append(String.format(" Number of solutions:          %d\n", nSoln[0]));
183     logger.info(sb.toString());
184 
185     for (int k = 0; k < nSoln[0]; k++) {
186       double[] coordsArray;
187       coordsArray = getSolutionCoordinates(k, rSolnN, rSolnA, rSolnC, firstResidue, endResidue);
188       solutions.add(coordsArray);
189     }
190 
191     return solutions;
192   }
193 
194   /**
195    * getRA.
196    *
197    * @return an array of {@link double} objects.
198    */
199   public double[][] getRA() {
200     return rA;
201   }
202 
203   /**
204    * getRC.
205    *
206    * @return an array of {@link double} objects.
207    */
208   public double[][] getRC() {
209     return rC;
210   }
211 
212   /**
213    * getRN.
214    *
215    * @return an array of {@link double} objects.
216    */
217   public double[][] getRN() {
218     return rN;
219   }
220 
221   /**
222    * useAltCoordinates.
223    *
224    * @param bool a boolean.
225    */
226   public void useAltCoordinates(boolean bool) {
227     this.useAltCoords = bool;
228   }
229 
230   private double[] getSolutionCoordinates(
231       int k,
232       double[][][] rSolnN,
233       double[][][] rSolnA,
234       double[][][] rSolnC,
235       int startResidue,
236       int endResidue) {
237     for (int i = 0; i < 3; i++) {
238       for (int j = 0; j < 3; j++) {
239         rN[i][j] = rSolnN[k][i][j];
240         rA[i][j] = rSolnA[k][i][j];
241         rC[i][j] = rSolnC[k][i][j];
242       }
243     }
244 
245     Polymer[] newChain = molecularAssembly.getChains();
246     List<Atom> backBoneAtoms;
247 
248     Atom[] atomArray = molecularAssembly.getAtomArray();
249     double[][] coordsArray = new double[atomArray.length][3];
250     if (useAltCoords) {
251       arraycopy(this.altCoords, 0, coordsArray, 0, coordsArray.length);
252     } else {
253       for (int i = 0; i < atomArray.length; i++) {
254         Atom a = atomArray[i];
255         coordsArray[i][0] = a.getX();
256         coordsArray[i][1] = a.getY();
257         coordsArray[i][2] = a.getZ();
258       }
259     }
260 
261     // Loop through residues to build backbone C,N,CA
262     for (int i = startResidue; i <= endResidue; i++) {
263       Residue newResidue = newChain[0].getResidue(i);
264       Residue backResidue = newChain[0].getResidue(i - 1);
265       backBoneAtoms = newResidue.getBackboneAtoms();
266       Atom C = null;
267       Atom N = null;
268       Atom CA = null;
269       double[] c = new double[3];
270       double[] ca = new double[3];
271       double[] n = new double[3];
272       double[] bc = new double[3];
273       double[] determinedXYZ = new double[3];
274 
275       for (Atom backBoneAtom : backBoneAtoms) {
276         //    backBoneAtom.setBuilt(true);
277         int backBoneIndex = backBoneAtom.getIndex() - 1;
278 
279         switch (backBoneAtom.getAtomType().name) {
280           case "C":
281             C = backBoneAtom;
282             coordsArray[backBoneIndex][0] = rC[i - startResidue][0];
283             coordsArray[backBoneIndex][1] = rC[i - startResidue][1];
284             coordsArray[backBoneIndex][2] = rC[i - startResidue][2];
285             break;
286           case "N":
287             N = backBoneAtom;
288             coordsArray[backBoneIndex][0] = rN[i - startResidue][0];
289             coordsArray[backBoneIndex][1] = rN[i - startResidue][1];
290             coordsArray[backBoneIndex][2] = rN[i - startResidue][2];
291             break;
292           case "CA":
293             CA = backBoneAtom;
294             coordsArray[backBoneIndex][0] = rA[i - startResidue][0];
295             coordsArray[backBoneIndex][1] = rA[i - startResidue][1];
296             coordsArray[backBoneIndex][2] = rA[i - startResidue][2];
297             break;
298           default:
299             break;
300         }
301       }
302     }
303 
304     // Loop through again to build Hydrogens and side-chains with current C,N,CA coordinates
305     for (int i = startResidue + 1; i < endResidue - 1; i++) {
306       Residue newResidue = newChain[0].getResidue(i);
307       Residue backResidue = newChain[0].getResidue(i - 1);
308       Residue forwardResidue = newChain[0].getResidue(i + 1);
309       backBoneAtoms = newResidue.getBackboneAtoms();
310 
311       double[] c = new double[3];
312       double[] ca = new double[3];
313       double[] n = new double[3];
314       double[] bc = new double[3];
315       double[] fn = new double[3];
316       double[] determinedXYZ = new double[3];
317 
318       // Obtaining coordinates for sidechains
319       Atom C = (Atom) newResidue.getAtomNode("C");
320       arraycopy(coordsArray[C.getIndex() - 1], 0, c, 0, 3);
321       Atom CA = (Atom) newResidue.getAtomNode("CA");
322       arraycopy(coordsArray[CA.getIndex() - 1], 0, ca, 0, 3);
323       Atom N = (Atom) newResidue.getAtomNode("N");
324       arraycopy(coordsArray[N.getIndex() - 1], 0, n, 0, 3);
325       Atom BC = (Atom) backResidue.getAtomNode("C");
326       arraycopy(coordsArray[BC.getIndex() - 1], 0, bc, 0, 3);
327       Atom FN = (Atom) forwardResidue.getAtomNode("N");
328       arraycopy(coordsArray[FN.getIndex() - 1], 0, fn, 0, 3);
329       /*
330       for (Atom backBoneAtom : backBoneAtoms) {
331       //    backBoneAtom.setBuilt(true);
332           logger.info(String.format("getAtomType().name "+backBoneAtom.getAtomType().name));
333           switch (backBoneAtom.getAtomType().name) {
334                   case "H":
335                                       logger.info(String.format("H getAtomType().name "+backBoneAtom.getAtomType().name));
336                       determinedXYZ = determineIntxyz(ca, 1.0, n, 109.5, c, 109.5, -1);
337                       coordsArray = fillCoordsArray(backBoneAtom,coordsArray, determinedXYZ);
338                       break;
339                   case "HA":
340                                       logger.info(String.format("HA getAtomType().name "+backBoneAtom.getAtomType().name));
341                       determinedXYZ = determineIntxyz(n, 1.0, bc, 119.0, ca, 119.0, 1);
342                       coordsArray = fillCoordsArray(backBoneAtom,coordsArray, determinedXYZ);
343                       break;
344                   case "O":
345                                       logger.info(String.format("O getAtomType().name "+backBoneAtom.getAtomType().name));
346                       determinedXYZ = determineIntxyz(c, 1.2255, ca, 122.4, n, 180, 0);
347                       coordsArray = fillCoordsArray(backBoneAtom,coordsArray, determinedXYZ);
348                       break;
349                   default:
350                       break;
351           }
352       }
353               */
354       Atom H = (Atom) newResidue.getAtomNode("H");
355       double[] h = coordsArray[H.getIndex() - 1];
356       arraycopy(determineIntxyz(n, 1.0, bc, 119.0, ca, 119.0, 1), 0, h, 0, 3); // H
357       coordsArray = fillCoordsArray(H, coordsArray, h);
358 
359       Atom O = (Atom) newResidue.getAtomNode("O");
360       double[] o = coordsArray[O.getIndex() - 1];
361       arraycopy(determineIntxyz(c, 1.2255, ca, 122.4, fn, 180, 0), 0, o, 0, 3); // O
362       coordsArray = fillCoordsArray(O, coordsArray, o);
363 
364       AminoAcid3 name = AminoAcidUtils.AminoAcid3.valueOf(newResidue.getName());
365 
366       if (name != AminoAcidUtils.AminoAcid3.GLY) {
367         Atom HA = (Atom) newResidue.getAtomNode("HA");
368         double[] ha = coordsArray[HA.getIndex() - 1];
369         arraycopy(determineIntxyz(ca, 1.0, n, 109.5, c, 109.5, -1), 0, ha, 0, 3); // HA
370         coordsArray = fillCoordsArray(HA, coordsArray, ha);
371       }
372 
373       double rotScale = random.nextDouble();
374       switch (name) {
375         case GLY:
376           {
377             Atom HA2 = (Atom) newResidue.getAtomNode("HA2");
378             double[] ha2 = coordsArray[HA2.getIndex() - 1];
379 
380             Atom HA3 = (Atom) newResidue.getAtomNode("HA3");
381             double[] ha3 = coordsArray[HA3.getIndex() - 1];
382 
383             arraycopy(determineIntxyz(ca, 1.00, n, 109.5, c, 109.5, 0), 0, ha2, 0, 3); // HA2
384             coordsArray = fillCoordsArray(HA2, coordsArray, ha2);
385 
386             arraycopy(determineIntxyz(ca, 1.00, n, 109.5, ha2, 109.5, -1), 0, ha3, 0, 3); // HA3
387             coordsArray = fillCoordsArray(HA3, coordsArray, ha3);
388 
389             break;
390           }
391         case ALA:
392           {
393             Atom CB = (Atom) newResidue.getAtomNode("CB");
394             double[] cb = coordsArray[CB.getIndex() - 1];
395             Atom HB1 = (Atom) newResidue.getAtomNode("HB1");
396             double[] hb1 = coordsArray[HB1.getIndex() - 1];
397             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
398             double[] hb2 = coordsArray[HB2.getIndex() - 1];
399             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
400             double[] hb3 = coordsArray[HB3.getIndex() - 1];
401 
402             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3); // CB
403             coordsArray = fillCoordsArray(CB, coordsArray, cb);
404 
405             arraycopy(determineIntxyz(cb, 1.11, ca, 109.5, n, 180.0, 0), 0, hb1, 0, 3); // HB1
406             coordsArray = fillCoordsArray(HB1, coordsArray, hb1);
407 
408             arraycopy(determineIntxyz(cb, 1.11, ca, 109.5, hb1, 109.4, 1), 0, hb2, 0, 3); // HB2
409             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
410 
411             arraycopy(determineIntxyz(cb, 1.11, ca, 109.5, hb1, 109.4, -1), 0, hb3, 0, 3); // HB3
412             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
413 
414             break;
415           }
416         case VAL:
417           {
418             Atom CB = (Atom) newResidue.getAtomNode("CB");
419             double[] cb = coordsArray[CB.getIndex() - 1];
420             Atom CG1 = (Atom) newResidue.getAtomNode("CG1");
421             double[] cg1 = coordsArray[CG1.getIndex() - 1];
422             Atom CG2 = (Atom) newResidue.getAtomNode("CG2");
423             double[] cg2 = coordsArray[CG2.getIndex() - 1];
424             Atom HB = (Atom) newResidue.getAtomNode("HB");
425             double[] hb = coordsArray[HB.getIndex() - 1];
426             Atom HG11 = (Atom) newResidue.getAtomNode("HG11");
427             double[] hg11 = coordsArray[HG11.getIndex() - 1];
428             Atom HG12 = (Atom) newResidue.getAtomNode("HG12");
429             double[] hg12 = coordsArray[HG12.getIndex() - 1];
430             Atom HG13 = (Atom) newResidue.getAtomNode("HG13");
431             double[] hg13 = coordsArray[HG13.getIndex() - 1];
432             Atom HG21 = (Atom) newResidue.getAtomNode("HG21");
433             double[] hg21 = coordsArray[HG21.getIndex() - 1];
434             Atom HG22 = (Atom) newResidue.getAtomNode("HG22");
435             double[] hg22 = coordsArray[HG22.getIndex() - 1];
436             Atom HG23 = (Atom) newResidue.getAtomNode("HG23");
437             double[] hg23 = coordsArray[HG23.getIndex() - 1];
438             Bond CG_CB = CB.getBond(CG1);
439             Bond HB_CB = CB.getBond(HB);
440             Bond HG_CG = HG11.getBond(CG1);
441             double dCG_CB = CG_CB.bondType.distance;
442             double dHB_CB = HB_CB.bondType.distance;
443             double dHG_CG = HG_CG.bondType.distance;
444             Angle CG_CB_CA = CG1.getAngle(CB, CA);
445             Angle HB_CB_CA = HB.getAngle(CB, CA);
446             Angle HG_CG_CB = HG11.getAngle(CG1, CB);
447             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
448             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
449             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
450 
451             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
452             coordsArray = fillCoordsArray(CB, coordsArray, cb);
453 
454             arraycopy(
455                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
456                 0,
457                 cg1,
458                 0,
459                 3); // CG1
460             coordsArray = fillCoordsArray(CG1, coordsArray, cg1);
461 
462             arraycopy(
463                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, cg1, 109.5, -1), 0, cg2, 0, 3); // CG2
464             coordsArray = fillCoordsArray(CG2, coordsArray, cg2);
465 
466             arraycopy(determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg1, 109.4, 1), 0, hb, 0, 3); // HB
467             coordsArray = fillCoordsArray(HB, coordsArray, hb);
468 
469             arraycopy(
470                 determineIntxyz(cg1, dHG_CG, cb, dHG_CG_CB, ca, 180.0, 0), 0, hg11, 0, 3); // HG11
471             coordsArray = fillCoordsArray(HG11, coordsArray, hg11);
472 
473             arraycopy(
474                 determineIntxyz(cg1, dHG_CG, cb, dHG_CG_CB, hg11, 109.4, 1), 0, hg12, 0, 3); // HG12
475             coordsArray = fillCoordsArray(HG12, coordsArray, hg12);
476 
477             arraycopy(
478                 determineIntxyz(cg1, dHG_CG, cb, dHG_CG_CB, hg11, 109.4, -1),
479                 0,
480                 hg13,
481                 0,
482                 3); // HG13
483             coordsArray = fillCoordsArray(HG13, coordsArray, hg13);
484 
485             arraycopy(
486                 determineIntxyz(cg2, dHG_CG, cb, dHG_CG_CB, ca, 180.0, 0), 0, hg21, 0, 3); // HG21
487             coordsArray = fillCoordsArray(HG21, coordsArray, hg21);
488 
489             arraycopy(
490                 determineIntxyz(cg2, dHG_CG, cb, dHG_CG_CB, hg21, 109.4, 1), 0, hg22, 0, 3); // HG22
491             coordsArray = fillCoordsArray(HG22, coordsArray, hg22);
492 
493             arraycopy(
494                 determineIntxyz(cg2, dHG_CG, cb, dHG_CG_CB, hg21, 109.4, -1),
495                 0,
496                 hg23,
497                 0,
498                 3); // HG23
499             coordsArray = fillCoordsArray(HG23, coordsArray, hg23);
500 
501             break;
502           }
503         case LEU:
504           {
505             Atom CB = (Atom) newResidue.getAtomNode("CB");
506             double[] cb = coordsArray[CB.getIndex() - 1];
507             Atom CG = (Atom) newResidue.getAtomNode("CG");
508             double[] cg = coordsArray[CG.getIndex() - 1];
509             Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
510             double[] cd1 = coordsArray[CD1.getIndex() - 1];
511             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
512             double[] cd2 = coordsArray[CD2.getIndex() - 1];
513             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
514             double[] hb2 = coordsArray[HB2.getIndex() - 1];
515             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
516             double[] hb3 = coordsArray[HB3.getIndex() - 1];
517             Atom HG = (Atom) newResidue.getAtomNode("HG");
518             double[] hg = coordsArray[HG.getIndex() - 1];
519             Atom HD11 = (Atom) newResidue.getAtomNode("HD11");
520             double[] hd11 = coordsArray[HD11.getIndex() - 1];
521             Atom HD12 = (Atom) newResidue.getAtomNode("HD12");
522             double[] hd12 = coordsArray[HD12.getIndex() - 1];
523             Atom HD13 = (Atom) newResidue.getAtomNode("HD13");
524             double[] hd13 = coordsArray[HD13.getIndex() - 1];
525             Atom HD21 = (Atom) newResidue.getAtomNode("HD21");
526             double[] hd21 = coordsArray[HD21.getIndex() - 1];
527             Atom HD22 = (Atom) newResidue.getAtomNode("HD22");
528             double[] hd22 = coordsArray[HD22.getIndex() - 1];
529             Atom HD23 = (Atom) newResidue.getAtomNode("HD23");
530             double[] hd23 = coordsArray[HD23.getIndex() - 1];
531             Bond CG_CB = CG.getBond(CB);
532             Bond CD_CG = CD1.getBond(CG);
533             Bond HB_CB = HB2.getBond(CB);
534             Bond HG_CG = HG.getBond(CG);
535             Bond HD_CD = HD11.getBond(CD1);
536             double dCG_CB = CG_CB.bondType.distance;
537             double dCD_CG = CD_CG.bondType.distance;
538             double dHB_CB = HB_CB.bondType.distance;
539             double dHG_CG = HG_CG.bondType.distance;
540             double dHD_CD = HD_CD.bondType.distance;
541             Angle CG_CB_CA = CG.getAngle(CB, CA);
542             Angle CD_CG_CB = CD1.getAngle(CG, CB);
543             Angle HB_CB_CA = HB2.getAngle(CB, CA);
544             Angle HG_CG_CB = HG.getAngle(CG, CB);
545             Angle HD_CD_CG = HD11.getAngle(CD1, CG);
546             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
547             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
548             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
549             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
550             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
551             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
552             coordsArray = fillCoordsArray(CB, coordsArray, cb);
553 
554             arraycopy(
555                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
556                 0,
557                 cg,
558                 0,
559                 3); // CG
560             coordsArray = fillCoordsArray(CG, coordsArray, cg);
561 
562             arraycopy(
563                 determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd1, 0, 3); // CD1
564             coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
565 
566             arraycopy(
567                 determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 109.5, -1), 0, cd2, 0, 3); // CD2
568             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
569 
570             arraycopy(
571                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
572             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
573 
574             arraycopy(
575                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
576             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
577 
578             arraycopy(determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd1, 109.4, 1), 0, hg, 0, 3); // HG
579             coordsArray = fillCoordsArray(HG, coordsArray, hg);
580 
581             arraycopy(
582                 determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, cb, 180.0, 0), 0, hd11, 0, 3); // HD11
583             coordsArray = fillCoordsArray(HD11, coordsArray, hd11);
584 
585             arraycopy(
586                 determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, hd11, 109.4, 1), 0, hd12, 0, 3); // HD12
587             coordsArray = fillCoordsArray(HD12, coordsArray, hd12);
588 
589             arraycopy(
590                 determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, hd11, 109.4, -1),
591                 0,
592                 hd13,
593                 0,
594                 3); // HD13
595             coordsArray = fillCoordsArray(HD13, coordsArray, hd13);
596 
597             arraycopy(
598                 determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, cb, 180.0, 0), 0, hd21, 0, 3); // HD21
599             coordsArray = fillCoordsArray(HD21, coordsArray, hd21);
600 
601             arraycopy(
602                 determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, hd21, 109.4, 1), 0, hd22, 0, 3); // HD22
603             coordsArray = fillCoordsArray(HD22, coordsArray, hd22);
604 
605             arraycopy(
606                 determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, hd21, 109.4, -1),
607                 0,
608                 hd23,
609                 0,
610                 3); // HD23
611             coordsArray = fillCoordsArray(HD23, coordsArray, hd23);
612             break;
613           }
614         case ILE:
615           {
616             Atom CB = (Atom) newResidue.getAtomNode("CB");
617             double[] cb = coordsArray[CB.getIndex() - 1];
618             Atom CG1 = (Atom) newResidue.getAtomNode("CG1");
619             double[] cg1 = coordsArray[CG1.getIndex() - 1];
620             Atom CG2 = (Atom) newResidue.getAtomNode("CG2");
621             double[] cg2 = coordsArray[CG2.getIndex() - 1];
622             Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
623             double[] cd1 = coordsArray[CD1.getIndex() - 1];
624             Atom HB = (Atom) newResidue.getAtomNode("HB");
625             double[] hb = coordsArray[HB.getIndex() - 1];
626             Atom HG12 = (Atom) newResidue.getAtomNode("HG12");
627             double[] hg12 = coordsArray[HG12.getIndex() - 1];
628             Atom HG13 = (Atom) newResidue.getAtomNode("HG13");
629             double[] hg13 = coordsArray[HG13.getIndex() - 1];
630             Atom HG21 = (Atom) newResidue.getAtomNode("HG21");
631             double[] hg21 = coordsArray[HG21.getIndex() - 1];
632             Atom HG22 = (Atom) newResidue.getAtomNode("HG22");
633             double[] hg22 = coordsArray[HG22.getIndex() - 1];
634             Atom HG23 = (Atom) newResidue.getAtomNode("HG23");
635             double[] hg23 = coordsArray[HG23.getIndex() - 1];
636             Atom HD11 = (Atom) newResidue.getAtomNode("HD11");
637             double[] hd11 = coordsArray[HD11.getIndex() - 1];
638             Atom HD12 = (Atom) newResidue.getAtomNode("HD12");
639             double[] hd12 = coordsArray[HD12.getIndex() - 1];
640             Atom HD13 = (Atom) newResidue.getAtomNode("HD13");
641             double[] hd13 = coordsArray[HD13.getIndex() - 1];
642             Bond CG1_CB = CG1.getBond(CB);
643             Bond CG2_CB = CG2.getBond(CB);
644             Bond CD1_CG1 = CD1.getBond(CG1);
645             Bond HB_CB = HB.getBond(CB);
646             Bond HG1_CG = HG12.getBond(CG1);
647             Bond HG2_CG = HG22.getBond(CG2);
648             Bond HD_CD = HD12.getBond(CD1);
649             double dCG1_CB = CG1_CB.bondType.distance;
650             double dCG2_CB = CG2_CB.bondType.distance;
651             double dCD1_CG1 = CD1_CG1.bondType.distance;
652             double dHB_CB = HB_CB.bondType.distance;
653             double dHG1_CG = HG1_CG.bondType.distance;
654             double dHG2_CG = HG2_CG.bondType.distance;
655             double dHD_CD = HD_CD.bondType.distance;
656             Angle CG1_CB_CA = CG1.getAngle(CB, CA);
657             Angle CG2_CB_CA = CG2.getAngle(CB, CA);
658             Angle CD1_CG1_CB = CD1.getAngle(CG1, CB);
659             Angle HB_CB_CA = HB.getAngle(CB, CA);
660             Angle HG1_CG_CB = HG12.getAngle(CG1, CB);
661             Angle HG2_CG_CB = HG21.getAngle(CG2, CB);
662             Angle HD_CD1_CG1 = HD11.getAngle(CD1, CG1);
663             double dCG1_CB_CA = CG1_CB_CA.angleType.angle[CG1_CB_CA.nh];
664             double dCG2_CB_CA = CG2_CB_CA.angleType.angle[CG2_CB_CA.nh];
665             double dCD1_CG1_CB = CD1_CG1_CB.angleType.angle[CD1_CG1_CB.nh];
666             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
667             double dHG1_CG_CB = HG1_CG_CB.angleType.angle[HG1_CG_CB.nh];
668             double dHG2_CG_CB = HG2_CG_CB.angleType.angle[HG2_CG_CB.nh];
669             double dHD_CD1_CG1 = HD_CD1_CG1.angleType.angle[HD_CD1_CG1.nh];
670             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
671             coordsArray = fillCoordsArray(CB, coordsArray, cb);
672 
673             arraycopy(
674                 determineIntxyz(cb, dCG1_CB, ca, dCG1_CB_CA, n, rotScale * 180.0, 0),
675                 0,
676                 cg1,
677                 0,
678                 3); // CG1
679             coordsArray = fillCoordsArray(CG1, coordsArray, cg1);
680 
681             arraycopy(
682                 determineIntxyz(cb, dCG2_CB, ca, dCG2_CB_CA, cg1, 109.5, 1), 0, cg2, 0, 3); // CG2
683             coordsArray = fillCoordsArray(CG2, coordsArray, cg2);
684 
685             arraycopy(
686                 determineIntxyz(cg1, dCD1_CG1, cb, dCD1_CG1_CB, ca, 180, 0), 0, cd1, 0, 3); // CD1
687             coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
688 
689             arraycopy(determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg2, 109.4, 1), 0, hb, 0, 3); // HB
690             coordsArray = fillCoordsArray(HB, coordsArray, hb);
691 
692             arraycopy(
693                 determineIntxyz(cg1, dHG1_CG, cb, dHG1_CG_CB, cd1, 109.4, 1),
694                 0,
695                 hg12,
696                 0,
697                 3); // HG12
698             coordsArray = fillCoordsArray(HG12, coordsArray, hg12);
699 
700             arraycopy(
701                 determineIntxyz(cg1, dHG1_CG, cb, dHG1_CG_CB, cd1, 109.4, -1),
702                 0,
703                 hg13,
704                 0,
705                 3); // HG13
706             coordsArray = fillCoordsArray(HG13, coordsArray, hg13);
707 
708             arraycopy(
709                 determineIntxyz(cg2, dHG2_CG, cb, dHG2_CG_CB, cg1, 180.0, 0),
710                 0,
711                 hg21,
712                 0,
713                 3); // HG21
714             coordsArray = fillCoordsArray(HG21, coordsArray, hg21);
715 
716             arraycopy(
717                 determineIntxyz(cg2, dHG2_CG, cb, dHG2_CG_CB, hg21, 109.0, 1),
718                 0,
719                 hg22,
720                 0,
721                 3); // HG22
722             coordsArray = fillCoordsArray(HG22, coordsArray, hg22);
723 
724             arraycopy(
725                 determineIntxyz(cg2, dHG2_CG, cb, dHG2_CG_CB, hg21, 109.0, -1),
726                 0,
727                 hg23,
728                 0,
729                 3); // HG23
730             coordsArray = fillCoordsArray(HG23, coordsArray, hg23);
731 
732             arraycopy(
733                 determineIntxyz(cd1, dHD_CD, cg1, dHD_CD1_CG1, cb, 180.0, 0),
734                 0,
735                 hd11,
736                 0,
737                 3); // HD11
738             coordsArray = fillCoordsArray(HD11, coordsArray, hd11);
739 
740             arraycopy(
741                 determineIntxyz(cd1, dHD_CD, cg1, dHD_CD1_CG1, hd11, 109.0, 1),
742                 0,
743                 hd12,
744                 0,
745                 3); // HD12
746             coordsArray = fillCoordsArray(HD12, coordsArray, hd12);
747 
748             arraycopy(
749                 determineIntxyz(cd1, dHD_CD, cg1, dHD_CD1_CG1, hd11, 109.0, -1),
750                 0,
751                 hd13,
752                 0,
753                 3); // HD13
754             coordsArray = fillCoordsArray(HD13, coordsArray, hd13);
755             break;
756           }
757         case SER:
758           {
759             Atom CB = (Atom) newResidue.getAtomNode("CB");
760             double[] cb = coordsArray[CB.getIndex() - 1];
761             Atom OG = (Atom) newResidue.getAtomNode("OG");
762             double[] og = coordsArray[OG.getIndex() - 1];
763             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
764             double[] hb2 = coordsArray[HB2.getIndex() - 1];
765             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
766             double[] hb3 = coordsArray[HB3.getIndex() - 1];
767             Atom HG = (Atom) newResidue.getAtomNode("HG");
768             double[] hg = coordsArray[HG.getIndex() - 1];
769             Bond OG_CB = OG.getBond(CB);
770             Bond HB_CB = HB2.getBond(CB);
771             Bond HG_OG = HG.getBond(OG);
772             double dOG_CB = OG_CB.bondType.distance;
773             double dHB_CB = HB_CB.bondType.distance;
774             double dHG_OG = HG_OG.bondType.distance;
775             Angle OG_CB_CA = OG.getAngle(CB, CA);
776             Angle HB_CB_CA = HB2.getAngle(CB, CA);
777             Angle HG_OG_CB = HG.getAngle(OG, CB);
778             double dOG_CB_CA = OG_CB_CA.angleType.angle[OG_CB_CA.nh];
779             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
780             double dHG_OG_CB = HG_OG_CB.angleType.angle[HG_OG_CB.nh];
781             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
782             coordsArray = fillCoordsArray(CB, coordsArray, cb);
783 
784             arraycopy(
785                 determineIntxyz(cb, dOG_CB, ca, dOG_CB_CA, n, rotScale * 180.0, 0),
786                 0,
787                 og,
788                 0,
789                 3); // OG
790             coordsArray = fillCoordsArray(OG, coordsArray, og);
791 
792             arraycopy(
793                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, og, 106.7, 1), 0, hb2, 0, 3); // HB2
794             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
795 
796             arraycopy(
797                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, og, 106.7, -1), 0, hb3, 0, 3); // HB3
798             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
799 
800             arraycopy(determineIntxyz(og, dHG_OG, cb, dHG_OG_CB, ca, 180.0, 0), 0, hg, 0, 3); // HG
801             coordsArray = fillCoordsArray(HG, coordsArray, hg);
802             break;
803           }
804         case THR:
805           {
806             Atom CB = (Atom) newResidue.getAtomNode("CB");
807             double[] cb = coordsArray[CB.getIndex() - 1];
808             Atom OG1 = (Atom) newResidue.getAtomNode("OG1");
809             double[] og1 = coordsArray[OG1.getIndex() - 1];
810             Atom CG2 = (Atom) newResidue.getAtomNode("CG2");
811             double[] cg2 = coordsArray[CG2.getIndex() - 1];
812             Atom HB = (Atom) newResidue.getAtomNode("HB");
813             double[] hb = coordsArray[HB.getIndex() - 1];
814             Atom HG1 = (Atom) newResidue.getAtomNode("HG1");
815             double[] hg1 = coordsArray[HG1.getIndex() - 1];
816             Atom HG21 = (Atom) newResidue.getAtomNode("HG21");
817             double[] hg21 = coordsArray[HG21.getIndex() - 1];
818             Atom HG22 = (Atom) newResidue.getAtomNode("HG22");
819             double[] hg22 = coordsArray[HG22.getIndex() - 1];
820             Atom HG23 = (Atom) newResidue.getAtomNode("HG23");
821             double[] hg23 = coordsArray[HG23.getIndex() - 1];
822             Bond OG1_CB = OG1.getBond(CB);
823             Bond CG2_CB = CG2.getBond(CB);
824             Bond HB_CB = HB.getBond(CB);
825             Bond HG1_OG1 = HG1.getBond(OG1);
826             Bond HG2_CG2 = HG21.getBond(CG2);
827             double dOG1_CB = OG1_CB.bondType.distance;
828             double dCG2_CB = CG2_CB.bondType.distance;
829             double dHB_CB = HB_CB.bondType.distance;
830             double dHG1_OG1 = HG1_OG1.bondType.distance;
831             double dHG2_CG2 = HG2_CG2.bondType.distance;
832             Angle OG1_CB_CA = OG1.getAngle(CB, CA);
833             Angle CG2_CB_CA = CG2.getAngle(CB, CA);
834             Angle HB_CB_CA = HB.getAngle(CB, CA);
835             Angle HG1_OG1_CB = HG1.getAngle(OG1, CB);
836             Angle HG2_CG2_CB = HG21.getAngle(CG2, CB);
837             double dOG1_CB_CA = OG1_CB_CA.angleType.angle[OG1_CB_CA.nh];
838             double dCG2_CB_CA = CG2_CB_CA.angleType.angle[CG2_CB_CA.nh];
839             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
840             double dHG1_OG1_CB = HG1_OG1_CB.angleType.angle[HG1_OG1_CB.nh];
841             double dHG2_CG2_CB = HG2_CG2_CB.angleType.angle[HG2_CG2_CB.nh];
842             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
843             coordsArray = fillCoordsArray(CB, coordsArray, cb);
844 
845             arraycopy(
846                 determineIntxyz(cb, dOG1_CB, ca, dOG1_CB_CA, n, rotScale * 180.0, 0),
847                 0,
848                 og1,
849                 0,
850                 3); // OG1
851             coordsArray = fillCoordsArray(OG1, coordsArray, og1);
852 
853             arraycopy(
854                 determineIntxyz(cb, dCG2_CB, ca, dCG2_CB_CA, og1, 107.7, 1), 0, cg2, 0, 3); // CG2
855             coordsArray = fillCoordsArray(CG2, coordsArray, cg2);
856 
857             arraycopy(
858                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, og1, 106.7, -1), 0, hb, 0, 3); // HB
859             coordsArray = fillCoordsArray(HB, coordsArray, hb);
860 
861             arraycopy(
862                 determineIntxyz(og1, dHG1_OG1, cb, dHG1_OG1_CB, ca, 180.0, 0), 0, hg1, 0, 3); // HG1
863             coordsArray = fillCoordsArray(HG1, coordsArray, hg1);
864 
865             arraycopy(
866                 determineIntxyz(cg2, dHG2_CG2, cb, dHG2_CG2_CB, ca, 180.0, 0),
867                 0,
868                 hg21,
869                 0,
870                 3); // HG21
871             coordsArray = fillCoordsArray(HG21, coordsArray, hg21);
872 
873             arraycopy(
874                 determineIntxyz(cg2, dHG2_CG2, cb, dHG2_CG2_CB, hg21, 109.0, 1),
875                 0,
876                 hg22,
877                 0,
878                 3); // HG22
879             coordsArray = fillCoordsArray(HG22, coordsArray, hg22);
880 
881             arraycopy(
882                 determineIntxyz(cg2, dHG2_CG2, cb, dHG2_CG2_CB, hg21, 109.0, -1),
883                 0,
884                 hg23,
885                 0,
886                 3); // HG23
887             coordsArray = fillCoordsArray(HG23, coordsArray, hg23);
888             break;
889           }
890         case CYS:
891         case CYX:
892           {
893             Atom CB = (Atom) newResidue.getAtomNode("CB");
894             double[] cb = coordsArray[CB.getIndex() - 1];
895             Atom SG = (Atom) newResidue.getAtomNode("SG");
896             double[] sg = coordsArray[SG.getIndex() - 1];
897             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
898             double[] hb2 = coordsArray[HB2.getIndex() - 1];
899             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
900             double[] hb3 = coordsArray[HB3.getIndex() - 1];
901             Atom HG = (Atom) newResidue.getAtomNode("HG");
902             double[] hg = coordsArray[HG.getIndex() - 1];
903             Bond SG_CB = SG.getBond(CB);
904             Bond HB_CB = HB2.getBond(CB);
905             Bond HG_SG = HG.getBond(SG);
906             double dSG_CB = SG_CB.bondType.distance;
907             double dHB_CB = HB_CB.bondType.distance;
908             double dHG_SG = HG_SG.bondType.distance;
909             Angle SG_CB_CA = SG.getAngle(CB, CA);
910             Angle HB_CB_CA = HB2.getAngle(CB, CA);
911             Angle HG_SG_CB = HG.getAngle(SG, CB);
912             double dSG_CB_CA = SG_CB_CA.angleType.angle[SG_CB_CA.nh];
913             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
914             double dHG_SG_CB = HG_SG_CB.angleType.angle[HG_SG_CB.nh];
915             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
916             coordsArray = fillCoordsArray(CB, coordsArray, cb);
917 
918             arraycopy(
919                 determineIntxyz(cb, dSG_CB, ca, dSG_CB_CA, n, rotScale * 180.0, 0),
920                 0,
921                 sg,
922                 0,
923                 3); // SG
924             coordsArray = fillCoordsArray(SG, coordsArray, sg);
925 
926             arraycopy(
927                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, 1), 0, hb2, 0, 3); // HB2
928             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
929 
930             arraycopy(
931                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, -1), 0, hb3, 0, 3); // HB3
932             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
933 
934             arraycopy(determineIntxyz(sg, dHG_SG, cb, dHG_SG_CB, ca, 180.0, 0), 0, hg, 0, 3); // HG
935             coordsArray = fillCoordsArray(HG, coordsArray, hg);
936             break;
937           }
938         case CYD:
939           {
940             Atom CB = (Atom) newResidue.getAtomNode("CB");
941             double[] cb = coordsArray[CB.getIndex() - 1];
942             Atom SG = (Atom) newResidue.getAtomNode("SG");
943             double[] sg = coordsArray[SG.getIndex() - 1];
944             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
945             double[] hb2 = coordsArray[HB2.getIndex() - 1];
946             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
947             double[] hb3 = coordsArray[HB3.getIndex() - 1];
948             Bond SG_CB = SG.getBond(CB);
949             Bond HB_CB = HB2.getBond(CB);
950             double dSG_CB = SG_CB.bondType.distance;
951             double dHB_CB = HB_CB.bondType.distance;
952             Angle SG_CB_CA = SG.getAngle(CB, CA);
953             Angle HB_CB_CA = HB2.getAngle(CB, CA);
954             double dSG_CB_CA = SG_CB_CA.angleType.angle[SG_CB_CA.nh];
955             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
956             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
957             coordsArray = fillCoordsArray(CB, coordsArray, cb);
958 
959             arraycopy(
960                 determineIntxyz(cb, dSG_CB, ca, dSG_CB_CA, n, rotScale * 180.0, 0),
961                 0,
962                 sg,
963                 0,
964                 3); // SG
965             coordsArray = fillCoordsArray(SG, coordsArray, sg);
966 
967             arraycopy(
968                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, 1), 0, hb2, 0, 3); // HB2
969             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
970 
971             arraycopy(
972                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, -1), 0, hb3, 0, 3); // HB3
973             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
974             break;
975           }
976         case PHE:
977           {
978             Atom CB = (Atom) newResidue.getAtomNode("CB");
979             double[] cb = coordsArray[CB.getIndex() - 1];
980             Atom CG = (Atom) newResidue.getAtomNode("CG");
981             double[] cg = coordsArray[CG.getIndex() - 1];
982             Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
983             double[] cd1 = coordsArray[CD1.getIndex() - 1];
984             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
985             double[] cd2 = coordsArray[CD2.getIndex() - 1];
986             Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
987             double[] ce1 = coordsArray[CE1.getIndex() - 1];
988             Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
989             double[] ce2 = coordsArray[CE2.getIndex() - 1];
990             Atom CZ = (Atom) newResidue.getAtomNode("CZ");
991             double[] cz = coordsArray[CZ.getIndex() - 1];
992             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
993             double[] hb2 = coordsArray[HB2.getIndex() - 1];
994             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
995             double[] hb3 = coordsArray[HB3.getIndex() - 1];
996             Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
997             double[] hd1 = coordsArray[HD1.getIndex() - 1];
998             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
999             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1000             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1001             double[] he1 = coordsArray[HE1.getIndex() - 1];
1002             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
1003             double[] he2 = coordsArray[HE2.getIndex() - 1];
1004             Atom HZ = (Atom) newResidue.getAtomNode("HZ");
1005             double[] hz = coordsArray[HZ.getIndex() - 1];
1006             Bond CG_CB = CG.getBond(CB);
1007             Bond CD_CG = CD1.getBond(CG);
1008             Bond CE_CD = CE1.getBond(CD1);
1009             Bond CZ_CE1 = CZ.getBond(CE1);
1010             Bond HB_CB = HB2.getBond(CB);
1011             Bond HD_CD = HD1.getBond(CD1);
1012             Bond HE_CE = HE1.getBond(CE1);
1013             Bond HZ_CZ = HZ.getBond(CZ);
1014             double dCG_CB = CG_CB.bondType.distance;
1015             double dCD_CG = CD_CG.bondType.distance;
1016             double dCE_CD = CE_CD.bondType.distance;
1017             double dCZ_CE1 = CZ_CE1.bondType.distance;
1018             double dHB_CB = HB_CB.bondType.distance;
1019             double dHD_CD = HD_CD.bondType.distance;
1020             double dHE_CE = HE_CE.bondType.distance;
1021             double dHZ_CZ = HZ_CZ.bondType.distance;
1022             Angle CG_CB_CA = CG.getAngle(CB, CA);
1023             Angle CD_CG_CB = CD1.getAngle(CG, CB);
1024             Angle CE_CD_CG = CE1.getAngle(CD1, CG);
1025             Angle CZ_CE1_CD1 = CZ.getAngle(CE1, CD1);
1026             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1027             Angle HD_CD1_CG = HD1.getAngle(CD1, CG);
1028             Angle HE_CE_CD = HE1.getAngle(CE1, CD1);
1029             Angle HZ_CZ_CE1 = HZ.getAngle(CZ, CE1);
1030             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1031             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
1032             double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
1033             double dCZ_CE1_CD1 = CZ_CE1_CD1.angleType.angle[CZ_CE1_CD1.nh];
1034             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1035             double dHD_CD1_CG = HD_CD1_CG.angleType.angle[HD_CD1_CG.nh];
1036             double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
1037             double dHZ_CZ_CE1 = HZ_CZ_CE1.angleType.angle[HZ_CZ_CE1.nh];
1038             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1039             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1040 
1041             arraycopy(
1042                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1043                 0,
1044                 cg,
1045                 0,
1046                 3); // CG
1047             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1048 
1049             arraycopy(
1050                 determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd1, 0, 3); // CD1
1051             coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
1052 
1053             arraycopy(
1054                 determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 120.0, 1), 0, cd2, 0, 3); // CD2
1055             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1056 
1057             arraycopy(determineIntxyz(cd1, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce1, 0, 3); // CE1
1058             coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
1059 
1060             arraycopy(determineIntxyz(cd2, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce2, 0, 3); // CE2
1061             coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
1062 
1063             arraycopy(
1064                 determineIntxyz(ce1, dCZ_CE1, cd1, dCZ_CE1_CD1, cg, 0.0, 0), 0, cz, 0, 3); // CZ
1065             coordsArray = fillCoordsArray(CZ, coordsArray, cz);
1066 
1067             arraycopy(
1068                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1069             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1070 
1071             arraycopy(
1072                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1073             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1074 
1075             arraycopy(
1076                 determineIntxyz(cd1, dHD_CD, cg, dHD_CD1_CG, ce1, 120.0, 1), 0, hd1, 0, 3); // HD1
1077             coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
1078 
1079             arraycopy(
1080                 determineIntxyz(cd2, dHD_CD, cg, dHD_CD1_CG, ce2, 120.0, 1), 0, hd2, 0, 3); // HD2
1081             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1082 
1083             arraycopy(
1084                 determineIntxyz(ce1, dHE_CE, cd1, dHE_CE_CD, cz, 120.0, 1), 0, he1, 0, 3); // HE1
1085             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1086 
1087             arraycopy(
1088                 determineIntxyz(ce2, dHE_CE, cd2, dHE_CE_CD, cz, 120.0, 1), 0, he2, 0, 3); // HE2
1089             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
1090 
1091             arraycopy(
1092                 determineIntxyz(cz, dHZ_CZ, ce1, dHZ_CZ_CE1, ce2, 120.0, 1), 0, hz, 0, 3); // HZ
1093             coordsArray = fillCoordsArray(HZ, coordsArray, hz);
1094             break;
1095           }
1096         case PRO:
1097           {
1098             Atom CB = (Atom) newResidue.getAtomNode("CB");
1099             double[] cb = coordsArray[CB.getIndex() - 1];
1100             Atom CG = (Atom) newResidue.getAtomNode("CG");
1101             double[] cg = coordsArray[CG.getIndex() - 1];
1102             Atom CD = (Atom) newResidue.getAtomNode("CD");
1103             double[] cd = coordsArray[CD.getIndex() - 1];
1104             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1105             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1106             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1107             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1108             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
1109             double[] hg2 = coordsArray[HG2.getIndex() - 1];
1110             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
1111             double[] hg3 = coordsArray[HG3.getIndex() - 1];
1112             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
1113             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1114             Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
1115             double[] hd3 = coordsArray[HD3.getIndex() - 1];
1116             Bond CG_CB = CG.getBond(CB);
1117             Bond CD_CG = CD.getBond(CG);
1118             Bond HB_CB = HB2.getBond(CB);
1119             Bond HG_CG = HG2.getBond(CG);
1120             Bond HD_CD = HD2.getBond(CD);
1121             double dCG_CB = CG_CB.bondType.distance;
1122             double dCD_CG = CD_CG.bondType.distance;
1123             double dHB_CB = HB_CB.bondType.distance;
1124             double dHG_CG = HG_CG.bondType.distance;
1125             double dHD_CD = HD_CD.bondType.distance;
1126             Angle CG_CB_CA = CG.getAngle(CB, CA);
1127             Angle CD_CG_CB = CD.getAngle(CG, CB);
1128             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1129             Angle HG_CG_CB = HG2.getAngle(CG, CB);
1130             Angle HD_CD_CG = HD2.getAngle(CD, CG);
1131             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1132             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
1133             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1134             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
1135             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
1136             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1137             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1138 
1139             arraycopy(
1140                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1141                 0,
1142                 cg,
1143                 0,
1144                 3); // CG
1145             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1146 
1147             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 30.0, 0), 0, cd, 0, 3); // CD
1148             coordsArray = fillCoordsArray(CD, coordsArray, cd);
1149 
1150             arraycopy(
1151                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1152             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1153 
1154             arraycopy(
1155                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1156             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1157 
1158             arraycopy(
1159                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3); // HG2
1160             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
1161 
1162             arraycopy(
1163                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3); // HG3
1164             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
1165 
1166             arraycopy(determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, n, 109.4, 1), 0, hd2, 0, 3); // HD2
1167             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1168 
1169             arraycopy(
1170                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, n, 109.4, -1), 0, hd3, 0, 3); // HD3
1171             coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
1172             break;
1173           }
1174         case TYR:
1175           {
1176             Atom CB = (Atom) newResidue.getAtomNode("CB");
1177             double[] cb = coordsArray[CB.getIndex() - 1];
1178             Atom CG = (Atom) newResidue.getAtomNode("CG");
1179             double[] cg = coordsArray[CG.getIndex() - 1];
1180             Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
1181             double[] cd1 = coordsArray[CD1.getIndex() - 1];
1182             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
1183             double[] cd2 = coordsArray[CD2.getIndex() - 1];
1184             Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
1185             double[] ce1 = coordsArray[CE1.getIndex() - 1];
1186             Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
1187             double[] ce2 = coordsArray[CE2.getIndex() - 1];
1188             Atom CZ = (Atom) newResidue.getAtomNode("CZ");
1189             double[] cz = coordsArray[CZ.getIndex() - 1];
1190             Atom OH = (Atom) newResidue.getAtomNode("OH");
1191             double[] oh = coordsArray[OH.getIndex() - 1];
1192             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1193             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1194             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1195             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1196             Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
1197             double[] hd1 = coordsArray[HD1.getIndex() - 1];
1198             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
1199             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1200             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1201             double[] he1 = coordsArray[HE1.getIndex() - 1];
1202             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
1203             double[] he2 = coordsArray[HE2.getIndex() - 1];
1204             Atom HH = (Atom) newResidue.getAtomNode("HH");
1205             double[] hh = coordsArray[HH.getIndex() - 1];
1206             Bond CB_CA = CB.getBond(CA);
1207             Bond CG_CB = CG.getBond(CB);
1208             Bond CD_CG = CD1.getBond(CG);
1209             Bond CE_CD = CE1.getBond(CD1);
1210             Bond CZ_CE1 = CZ.getBond(CE1);
1211             Bond OH_CZ = OH.getBond(CZ);
1212             Bond HB_CB = HB2.getBond(CB);
1213             Bond HD_CD = HD1.getBond(CD1);
1214             Bond HE_CE = HE1.getBond(CE1);
1215             Bond HH_OH = HH.getBond(OH);
1216             double dCB_CA = CB_CA.bondType.distance;
1217             double dCG_CB = CG_CB.bondType.distance;
1218             double dCD_CG = CD_CG.bondType.distance;
1219             double dCE_CD = CE_CD.bondType.distance;
1220             double dCZ_CE1 = CZ_CE1.bondType.distance;
1221             double dOH_CZ = OH_CZ.bondType.distance;
1222             double dHB_CB = HB_CB.bondType.distance;
1223             double dHD_CD = HD_CD.bondType.distance;
1224             double dHE_CE = HE_CE.bondType.distance;
1225             double dHH_OH = HH_OH.bondType.distance;
1226             Angle CG_CB_CA = CG.getAngle(CB, CA);
1227             Angle CD_CG_CB = CD1.getAngle(CG, CB);
1228             Angle CE_CD_CG = CE1.getAngle(CD1, CG);
1229             Angle CZ_CE1_CD1 = CZ.getAngle(CE1, CD1);
1230             Angle OH_CZ_CE2 = OH.getAngle(CZ, CE2);
1231             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1232             Angle HD_CD_CG = HD1.getAngle(CD1, CG);
1233             Angle HE_CE_CD = HE1.getAngle(CE1, CD1);
1234             Angle HH_OH_CZ = HH.getAngle(OH, CZ);
1235             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1236             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
1237             double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
1238             double dCZ_CE1_CD1 = CZ_CE1_CD1.angleType.angle[CZ_CE1_CD1.nh];
1239             double dOH_CZ_CE2 = OH_CZ_CE2.angleType.angle[OH_CZ_CE2.nh];
1240             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1241             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
1242             double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
1243             double dHH_OH_CZ = HH_OH_CZ.angleType.angle[HH_OH_CZ.nh];
1244             arraycopy(determineIntxyz(ca, dCB_CA, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1245             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1246 
1247             arraycopy(
1248                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1249                 0,
1250                 cg,
1251                 0,
1252                 3); // CG
1253             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1254 
1255             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 90.0, 0), 0, cd1, 0, 3); // CD1
1256             coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
1257 
1258             arraycopy(
1259                 determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 120.0, 1), 0, cd2, 0, 3); // CD2
1260             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1261 
1262             arraycopy(determineIntxyz(cd1, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce1, 0, 3); // CE1
1263             coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
1264 
1265             arraycopy(determineIntxyz(cd2, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce2, 0, 3); // CE2
1266             coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
1267 
1268             arraycopy(
1269                 determineIntxyz(ce1, dCZ_CE1, cd1, dCZ_CE1_CD1, cg, 0.0, 0), 0, cz, 0, 3); // CZ
1270             coordsArray = fillCoordsArray(CZ, coordsArray, cz);
1271 
1272             arraycopy(
1273                 determineIntxyz(cz, dOH_CZ, ce2, dOH_CZ_CE2, ce1, 120.0, 1), 0, oh, 0, 3); // OH
1274             coordsArray = fillCoordsArray(OH, coordsArray, oh);
1275 
1276             arraycopy(
1277                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1278             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1279 
1280             arraycopy(
1281                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1282             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1283 
1284             arraycopy(
1285                 determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, ce1, 120.0, 1), 0, hd1, 0, 3); // HD1
1286             coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
1287 
1288             arraycopy(
1289                 determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, ce2, 120.0, 1), 0, hd2, 0, 3); // HD2
1290             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1291 
1292             arraycopy(
1293                 determineIntxyz(ce1, dHE_CE, cd1, dHE_CE_CD, cz, 120.0, 1), 0, he1, 0, 3); // HE1
1294             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1295 
1296             arraycopy(
1297                 determineIntxyz(ce2, dHE_CE, cd2, dHE_CE_CD, cz, 120.0, 1), 0, he2, 0, 3); // HE2
1298             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
1299 
1300             arraycopy(determineIntxyz(oh, dHH_OH, cz, dHH_OH_CZ, ce2, 0.0, 0), 0, hh, 0, 3); // HH
1301             coordsArray = fillCoordsArray(HH, coordsArray, hh);
1302             break;
1303           }
1304         case TYD:
1305           {
1306             Atom CB = (Atom) newResidue.getAtomNode("CB");
1307             double[] cb = coordsArray[CB.getIndex() - 1];
1308             Atom CG = (Atom) newResidue.getAtomNode("CG");
1309             double[] cg = coordsArray[CG.getIndex() - 1];
1310             Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
1311             double[] cd1 = coordsArray[CD1.getIndex() - 1];
1312             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
1313             double[] cd2 = coordsArray[CD2.getIndex() - 1];
1314             Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
1315             double[] ce1 = coordsArray[CE1.getIndex() - 1];
1316             Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
1317             double[] ce2 = coordsArray[CE2.getIndex() - 1];
1318             Atom CZ = (Atom) newResidue.getAtomNode("CZ");
1319             double[] cz = coordsArray[CZ.getIndex() - 1];
1320             Atom OH = (Atom) newResidue.getAtomNode("OH");
1321             double[] oh = coordsArray[OH.getIndex() - 1];
1322             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1323             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1324             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1325             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1326             Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
1327             double[] hd1 = coordsArray[HD1.getIndex() - 1];
1328             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
1329             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1330             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1331             double[] he1 = coordsArray[HE1.getIndex() - 1];
1332             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
1333             double[] he2 = coordsArray[HE2.getIndex() - 1];
1334             Bond CG_CB = CG.getBond(CB);
1335             Bond CD_CG = CD1.getBond(CG);
1336             Bond CE_CD = CE1.getBond(CD1);
1337             Bond CZ_CE1 = CZ.getBond(CE1);
1338             Bond OH_CZ = OH.getBond(CZ);
1339             Bond HB_CB = HB2.getBond(CB);
1340             Bond HD_CD = HD1.getBond(CD1);
1341             Bond HE_CE = HE1.getBond(CE1);
1342             double dCG_CB = CG_CB.bondType.distance;
1343             double dCD_CG = CD_CG.bondType.distance;
1344             double dCE_CD = CE_CD.bondType.distance;
1345             double dCZ_CE1 = CZ_CE1.bondType.distance;
1346             double dOH_CZ = OH_CZ.bondType.distance;
1347             double dHB_CB = HB_CB.bondType.distance;
1348             double dHD_CD = HD_CD.bondType.distance;
1349             double dHE_CE = HE_CE.bondType.distance;
1350             Angle CG_CB_CA = CG.getAngle(CB, CA);
1351             Angle CD_CG_CB = CD1.getAngle(CG, CB);
1352             Angle CE_CD_CG = CE1.getAngle(CD1, CG);
1353             Angle CZ_CE1_CD1 = CZ.getAngle(CE1, CD1);
1354             Angle OH_CZ_CE2 = OH.getAngle(CZ, CE2);
1355             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1356             Angle HD_CD_CG = HD1.getAngle(CD1, CG);
1357             Angle HE_CE_CD = HE1.getAngle(CE1, CD1);
1358             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1359             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
1360             double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
1361             double dCZ_CE1_CD1 = CZ_CE1_CD1.angleType.angle[CZ_CE1_CD1.nh];
1362             double dOH_CZ_CE2 = OH_CZ_CE2.angleType.angle[OH_CZ_CE2.nh];
1363             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1364             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
1365             double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
1366             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1367             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1368 
1369             arraycopy(
1370                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1371                 0,
1372                 cg,
1373                 0,
1374                 3); // CG
1375             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1376 
1377             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 90.0, 0), 0, cd1, 0, 3); // CD1
1378             coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
1379 
1380             arraycopy(
1381                 determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 120.0, 1), 0, cd2, 0, 3); // CD2
1382             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1383 
1384             arraycopy(determineIntxyz(cd1, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce1, 0, 3); // CE1
1385             coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
1386 
1387             arraycopy(determineIntxyz(cd2, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce2, 0, 3); // CE2
1388             coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
1389 
1390             arraycopy(
1391                 determineIntxyz(ce1, dCZ_CE1, cd1, dCZ_CE1_CD1, cg, 0.0, 0), 0, cz, 0, 3); // CZ
1392             coordsArray = fillCoordsArray(CZ, coordsArray, cz);
1393 
1394             arraycopy(
1395                 determineIntxyz(cz, dOH_CZ, ce2, dOH_CZ_CE2, ce1, 120.0, 1), 0, oh, 0, 3); // OH
1396             coordsArray = fillCoordsArray(OH, coordsArray, oh);
1397 
1398             arraycopy(
1399                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1400             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1401 
1402             arraycopy(
1403                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1404             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1405 
1406             arraycopy(
1407                 determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, ce1, 120.0, 1), 0, hd1, 0, 3); // HD1
1408             coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
1409 
1410             arraycopy(
1411                 determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, ce2, 120.0, 1), 0, hd2, 0, 3); // HD2
1412             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1413 
1414             arraycopy(
1415                 determineIntxyz(ce1, dHE_CE, cd1, dHE_CE_CD, cz, 120.0, 1), 0, he1, 0, 3); // HE1
1416             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1417 
1418             arraycopy(
1419                 determineIntxyz(ce2, dHE_CE, cd2, dHE_CE_CD, cz, 120.0, 1), 0, he2, 0, 3); // HE2
1420             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
1421             break;
1422           }
1423         case TRP:
1424           {
1425             Atom CB = (Atom) newResidue.getAtomNode("CB");
1426             double[] cb = coordsArray[CB.getIndex() - 1];
1427             Atom CG = (Atom) newResidue.getAtomNode("CG");
1428             double[] cg = coordsArray[CG.getIndex() - 1];
1429             Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
1430             double[] cd1 = coordsArray[CD1.getIndex() - 1];
1431             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
1432             double[] cd2 = coordsArray[CD2.getIndex() - 1];
1433             Atom NE1 = (Atom) newResidue.getAtomNode("NE1");
1434             double[] ne1 = coordsArray[NE1.getIndex() - 1];
1435             Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
1436             double[] ce2 = coordsArray[CE2.getIndex() - 1];
1437             Atom CE3 = (Atom) newResidue.getAtomNode("CE3");
1438             double[] ce3 = coordsArray[CE3.getIndex() - 1];
1439             Atom CZ2 = (Atom) newResidue.getAtomNode("CZ2");
1440             double[] cz2 = coordsArray[CZ2.getIndex() - 1];
1441             Atom CZ3 = (Atom) newResidue.getAtomNode("CZ3");
1442             double[] cz3 = coordsArray[CZ3.getIndex() - 1];
1443             Atom CH2 = (Atom) newResidue.getAtomNode("CH2");
1444             double[] ch2 = coordsArray[CH2.getIndex() - 1];
1445             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1446             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1447             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1448             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1449             Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
1450             double[] hd1 = coordsArray[HD1.getIndex() - 1];
1451             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1452             double[] he1 = coordsArray[HE1.getIndex() - 1];
1453             Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
1454             double[] he3 = coordsArray[HE3.getIndex() - 1];
1455             Atom HZ2 = (Atom) newResidue.getAtomNode("HZ2");
1456             double[] hz2 = coordsArray[HZ2.getIndex() - 1];
1457             Atom HZ3 = (Atom) newResidue.getAtomNode("HZ3");
1458             double[] hz3 = coordsArray[HZ3.getIndex() - 1];
1459             Atom HH2 = (Atom) newResidue.getAtomNode("HH2");
1460             double[] hh2 = coordsArray[HH2.getIndex() - 1];
1461             Bond CG_CB = CG.getBond(CB);
1462             Bond CD1_CG = CD1.getBond(CG);
1463             Bond CD2_CG = CD2.getBond(CG);
1464             Bond NE1_CD1 = NE1.getBond(CD1);
1465             Bond CE2_NE1 = CE2.getBond(NE1);
1466             Bond CE3_CD2 = CE3.getBond(CD2);
1467             Bond CZ2_CE2 = CZ2.getBond(CE2);
1468             Bond CZ3_CE3 = CZ3.getBond(CE3);
1469             Bond CH2_CZ2 = CH2.getBond(CZ2);
1470             Bond HB_CB = HB2.getBond(CB);
1471             Bond HD1_CD1 = HD1.getBond(CD1);
1472             Bond HE1_NE1 = HE1.getBond(NE1);
1473             Bond HE3_CE3 = HE3.getBond(CE3);
1474             Bond HZ2_CZ2 = HZ2.getBond(CZ2);
1475             Bond HZ3_CZ3 = HZ3.getBond(CZ3);
1476             Bond HH2_CH2 = HH2.getBond(CH2);
1477             double dCG_CB = CG_CB.bondType.distance;
1478             double dCD1_CG = CD1_CG.bondType.distance;
1479             double dCD2_CG = CD2_CG.bondType.distance;
1480             double dNE1_CD1 = NE1_CD1.bondType.distance;
1481             double dCE2_NE1 = CE2_NE1.bondType.distance;
1482             double dCE3_CD2 = CE3_CD2.bondType.distance;
1483             double dCZ2_CE2 = CZ2_CE2.bondType.distance;
1484             double dCZ3_CE3 = CZ3_CE3.bondType.distance;
1485             double dCH2_CZ2 = CH2_CZ2.bondType.distance;
1486             double dHB_CB = HB_CB.bondType.distance;
1487             double dHD1_CD1 = HD1_CD1.bondType.distance;
1488             double dHE1_NE1 = HE1_NE1.bondType.distance;
1489             double dHE3_CE3 = HE3_CE3.bondType.distance;
1490             double dHZ2_CZ2 = HZ2_CZ2.bondType.distance;
1491             double dHZ3_CZ3 = HZ3_CZ3.bondType.distance;
1492             double dHH2_CH2 = HH2_CH2.bondType.distance;
1493             Angle CG_CB_CA = CG.getAngle(CB, CA);
1494             Angle CD1_CG_CB = CD1.getAngle(CG, CB);
1495             Angle CD2_CG_CB = CD2.getAngle(CG, CB);
1496             Angle NE1_CD1_CG = NE1.getAngle(CD1, CG);
1497             Angle CE2_NE1_CD1 = CE2.getAngle(NE1, CD1);
1498             Angle CE3_CD2_CE2 = CE3.getAngle(CD2, CE2);
1499             Angle CZ2_CE2_CD2 = CZ2.getAngle(CE2, CD2);
1500             Angle CZ3_CE3_CD2 = CZ3.getAngle(CE3, CD2);
1501             Angle CH2_CZ2_CE2 = CH2.getAngle(CZ2, CE2);
1502             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1503             Angle HD1_CD1_CG = HD1.getAngle(CD1, CG);
1504             Angle HE1_NE1_CD1 = HE1.getAngle(NE1, CD1);
1505             Angle HE3_CE3_CD2 = HE3.getAngle(CE3, CD2);
1506             Angle HZ2_CZ2_CE2 = HZ2.getAngle(CZ2, CE2);
1507             Angle HZ3_CZ3_CE3 = HZ3.getAngle(CZ3, CH2);
1508             Angle HH2_CH2_CZ2 = HH2.getAngle(CH2, CZ3);
1509             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1510             double dCD1_CG_CB = CD1_CG_CB.angleType.angle[CD1_CG_CB.nh];
1511             double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
1512             double dNE1_CD1_CG = NE1_CD1_CG.angleType.angle[NE1_CD1_CG.nh];
1513             double dCE2_NE1_CD1 = CE2_NE1_CD1.angleType.angle[CE2_NE1_CD1.nh];
1514             double dCE3_CD2_CE2 = CE3_CD2_CE2.angleType.angle[CE3_CD2_CE2.nh];
1515             double dCZ2_CE2_CD2 = CZ2_CE2_CD2.angleType.angle[CZ2_CE2_CD2.nh];
1516             double dCZ3_CE3_CD2 = CZ3_CE3_CD2.angleType.angle[CZ3_CE3_CD2.nh];
1517             double dCH2_CZ2_CE2 = CH2_CZ2_CE2.angleType.angle[CH2_CZ2_CE2.nh];
1518             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1519             double dHD1_CD1_CG = HD1_CD1_CG.angleType.angle[HD1_CD1_CG.nh];
1520             double dHE1_NE1_CD1 = HE1_NE1_CD1.angleType.angle[HE1_NE1_CD1.nh];
1521             double dHE3_CE3_CD2 = HE3_CE3_CD2.angleType.angle[HE3_CE3_CD2.nh];
1522             double dHZ2_CZ2_CE2 = HZ2_CZ2_CE2.angleType.angle[HZ2_CZ2_CE2.nh];
1523             double dHZ3_CZ3_CE3 = HZ3_CZ3_CE3.angleType.angle[HZ3_CZ3_CE3.nh];
1524             double dHH2_CH2_CZ2 = HH2_CH2_CZ2.angleType.angle[HH2_CH2_CZ2.nh];
1525             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1526             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1527 
1528             arraycopy(
1529                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1530                 0,
1531                 cg,
1532                 0,
1533                 3); // CG
1534             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1535 
1536             arraycopy(
1537                 determineIntxyz(cg, dCD1_CG, cb, dCD1_CG_CB, ca, -90.0, 0), 0, cd1, 0, 3); // CD1
1538             coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
1539 
1540             arraycopy(
1541                 determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, cd1, 108.0, 1), 0, cd2, 0, 3); // CD2
1542             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1543 
1544             arraycopy(
1545                 determineIntxyz(cd1, dNE1_CD1, cg, dNE1_CD1_CG, cd2, 0.0, 0), 0, ne1, 0, 3); // NE1
1546             coordsArray = fillCoordsArray(NE1, coordsArray, ne1);
1547 
1548             arraycopy(
1549                 determineIntxyz(ne1, dCE2_NE1, cd1, dCE2_NE1_CD1, cg, 0.0, 0), 0, ce2, 0, 3); // CE2
1550             coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
1551 
1552             arraycopy(
1553                 determineIntxyz(cd2, dCE3_CD2, ce2, dCE3_CD2_CE2, ne1, 180.0, 0),
1554                 0,
1555                 ce3,
1556                 0,
1557                 3); // CE3
1558             coordsArray = fillCoordsArray(CE3, coordsArray, ce3);
1559 
1560             arraycopy(
1561                 determineIntxyz(ce2, dCZ2_CE2, cd2, dCZ2_CE2_CD2, ce3, 0.0, 0),
1562                 0,
1563                 cz2,
1564                 0,
1565                 3); // CZ2
1566             coordsArray = fillCoordsArray(CZ2, coordsArray, cz2);
1567 
1568             arraycopy(
1569                 determineIntxyz(ce3, dCZ3_CE3, cd2, dCZ3_CE3_CD2, ce2, 0.0, 0),
1570                 0,
1571                 cz3,
1572                 0,
1573                 3); // CZ3
1574             coordsArray = fillCoordsArray(CZ3, coordsArray, cz3);
1575 
1576             arraycopy(
1577                 determineIntxyz(cz2, dCH2_CZ2, ce2, dCH2_CZ2_CE2, cd2, 0.0, 0),
1578                 0,
1579                 ch2,
1580                 0,
1581                 3); // CH2
1582             coordsArray = fillCoordsArray(CH2, coordsArray, ch2);
1583 
1584             arraycopy(
1585                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1586             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1587 
1588             arraycopy(
1589                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1590             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1591 
1592             arraycopy(
1593                 determineIntxyz(cd1, dHD1_CD1, cg, dHD1_CD1_CG, ne1, 126.0, 1),
1594                 0,
1595                 hd1,
1596                 0,
1597                 3); // HD1
1598             coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
1599 
1600             arraycopy(
1601                 determineIntxyz(ne1, dHE1_NE1, cd1, dHE1_NE1_CD1, ce2, 126.0, 1),
1602                 0,
1603                 he1,
1604                 0,
1605                 3); // HE1
1606             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1607 
1608             arraycopy(
1609                 determineIntxyz(ce3, dHE3_CE3, cd2, dHE3_CE3_CD2, cz3, 120.0, 1),
1610                 0,
1611                 he3,
1612                 0,
1613                 3); // HE3
1614             coordsArray = fillCoordsArray(HE3, coordsArray, he3);
1615 
1616             arraycopy(
1617                 determineIntxyz(cz2, dHZ2_CZ2, ce2, dHZ2_CZ2_CE2, ch2, 120.0, 1),
1618                 0,
1619                 hz2,
1620                 0,
1621                 3); // HZ2
1622             coordsArray = fillCoordsArray(HZ2, coordsArray, hz2);
1623 
1624             arraycopy(
1625                 determineIntxyz(cz3, dHZ3_CZ3, ce3, dHZ3_CZ3_CE3, ch2, 120.0, 1),
1626                 0,
1627                 hz3,
1628                 0,
1629                 3); // HZ3
1630             coordsArray = fillCoordsArray(HZ3, coordsArray, hz3);
1631 
1632             arraycopy(
1633                 determineIntxyz(ch2, dHH2_CH2, cz2, dHH2_CH2_CZ2, cz3, 120.0, 1),
1634                 0,
1635                 hh2,
1636                 0,
1637                 3); // HH2
1638             coordsArray = fillCoordsArray(HH2, coordsArray, hh2);
1639             break;
1640           }
1641         case HIS:
1642           {
1643             Atom CB = (Atom) newResidue.getAtomNode("CB");
1644             double[] cb = coordsArray[CB.getIndex() - 1];
1645             Atom CG = (Atom) newResidue.getAtomNode("CG");
1646             double[] cg = coordsArray[CG.getIndex() - 1];
1647             Atom ND1 = (Atom) newResidue.getAtomNode("ND1");
1648             double[] nd1 = coordsArray[ND1.getIndex() - 1];
1649             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
1650             double[] cd2 = coordsArray[CD2.getIndex() - 1];
1651             Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
1652             double[] ce1 = coordsArray[CE1.getIndex() - 1];
1653             Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
1654             double[] ne2 = coordsArray[NE2.getIndex() - 1];
1655             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1656             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1657             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1658             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1659             Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
1660             double[] hd1 = coordsArray[HD1.getIndex() - 1];
1661             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
1662             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1663             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1664             double[] he1 = coordsArray[HE1.getIndex() - 1];
1665             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
1666             double[] he2 = coordsArray[HE2.getIndex() - 1];
1667             Bond CG_CB = CG.getBond(CB);
1668             Bond ND1_CG = ND1.getBond(CG);
1669             Bond CD2_CG = CD2.getBond(CG);
1670             Bond CE1_ND1 = CE1.getBond(ND1);
1671             Bond NE2_CD2 = NE2.getBond(CD2);
1672             Bond HB_CB = HB2.getBond(CB);
1673             Bond HD1_ND1 = HD1.getBond(ND1);
1674             Bond HD2_CD2 = HD2.getBond(CD2);
1675             Bond HE1_CE1 = HE1.getBond(CE1);
1676             Bond HE2_NE2 = HE2.getBond(NE2);
1677             double dCG_CB = CG_CB.bondType.distance;
1678             double dND1_CG = ND1_CG.bondType.distance;
1679             double dCD2_CG = CD2_CG.bondType.distance;
1680             double dCE1_ND1 = CE1_ND1.bondType.distance;
1681             double dNE2_CD2 = NE2_CD2.bondType.distance;
1682             double dHB_CB = HB_CB.bondType.distance;
1683             double dHD1_ND1 = HD1_ND1.bondType.distance;
1684             double dHD2_CD2 = HD2_CD2.bondType.distance;
1685             double dHE1_CE1 = HE1_CE1.bondType.distance;
1686             double dHE2_NE2 = HE2_NE2.bondType.distance;
1687             Angle CG_CB_CA = CG.getAngle(CB, CA);
1688             Angle ND1_CG_CB = ND1.getAngle(CG, CB);
1689             Angle CD2_CG_CB = CD2.getAngle(CG, CB);
1690             Angle CE1_ND1_CG = CE1.getAngle(ND1, CG);
1691             Angle NE2_CD2_CG = NE2.getAngle(CD2, CG);
1692             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1693             Angle HD1_ND1_CG = HD1.getAngle(ND1, CG);
1694             Angle HD2_CD2_CG = HD2.getAngle(CD2, CG);
1695             Angle HE1_CE1_ND1 = HE1.getAngle(CE1, ND1);
1696             Angle HE2_NE2_CD2 = HE2.getAngle(NE2, CD2);
1697             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1698             double dND1_CG_CB = ND1_CG_CB.angleType.angle[ND1_CG_CB.nh];
1699             double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
1700             double dCE1_ND1_CG = CE1_ND1_CG.angleType.angle[CE1_ND1_CG.nh];
1701             double dNE2_CD2_CG = NE2_CD2_CG.angleType.angle[NE2_CD2_CG.nh];
1702             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1703             double dHD1_ND1_CG = HD1_ND1_CG.angleType.angle[HD1_ND1_CG.nh];
1704             double dHD2_CD2_CG = HD2_CD2_CG.angleType.angle[HD2_CD2_CG.nh];
1705             double dHE1_CE1_ND1 = HE1_CE1_ND1.angleType.angle[HE1_CE1_ND1.nh];
1706             double dHE2_NE2_CD2 = HE2_NE2_CD2.angleType.angle[HE2_NE2_CD2.nh];
1707             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1708             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1709 
1710             arraycopy(
1711                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1712                 0,
1713                 cg,
1714                 0,
1715                 3); // CG
1716             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1717 
1718             arraycopy(
1719                 determineIntxyz(cg, dND1_CG, cb, dND1_CG_CB, ca, 180.0, 0), 0, nd1, 0, 3); // ND1
1720             coordsArray = fillCoordsArray(ND1, coordsArray, nd1);
1721 
1722             arraycopy(
1723                 determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, nd1, 108.0, 1), 0, cd2, 0, 3); // CD2
1724             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1725 
1726             arraycopy(
1727                 determineIntxyz(nd1, dCE1_ND1, cg, dCE1_ND1_CG, cd2, 0.0, 0), 0, ce1, 0, 3); // CE1
1728             coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
1729 
1730             arraycopy(
1731                 determineIntxyz(cd2, dNE2_CD2, cg, dNE2_CD2_CG, nd1, 0.0, 0), 0, ne2, 0, 3); // NE2
1732             coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
1733 
1734             arraycopy(
1735                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1736             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1737 
1738             arraycopy(
1739                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1740             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1741 
1742             arraycopy(
1743                 determineIntxyz(nd1, dHD1_ND1, cg, dHD1_ND1_CG, cb, 0.0, 0), 0, hd1, 0, 3); // HD1
1744             coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
1745 
1746             arraycopy(
1747                 determineIntxyz(cd2, dHD2_CD2, cg, dHD2_CD2_CG, ne2, 126.0, 1),
1748                 0,
1749                 hd2,
1750                 0,
1751                 3); // HD2
1752             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1753 
1754             arraycopy(
1755                 determineIntxyz(ce1, dHE1_CE1, nd1, dHE1_CE1_ND1, ne2, 126.0, 1),
1756                 0,
1757                 he1,
1758                 0,
1759                 3); // HE1
1760             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1761 
1762             arraycopy(
1763                 determineIntxyz(ne2, dHE2_NE2, cd2, dHE2_NE2_CD2, ce1, 126.0, 1),
1764                 0,
1765                 he2,
1766                 0,
1767                 3); // HE2
1768             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
1769             break;
1770           }
1771         case HID:
1772           {
1773             Atom CB = (Atom) newResidue.getAtomNode("CB");
1774             double[] cb = coordsArray[CB.getIndex() - 1];
1775             Atom CG = (Atom) newResidue.getAtomNode("CG");
1776             double[] cg = coordsArray[CG.getIndex() - 1];
1777             Atom ND1 = (Atom) newResidue.getAtomNode("ND1");
1778             double[] nd1 = coordsArray[ND1.getIndex() - 1];
1779             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
1780             double[] cd2 = coordsArray[CD2.getIndex() - 1];
1781             Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
1782             double[] ce1 = coordsArray[CE1.getIndex() - 1];
1783             Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
1784             double[] ne2 = coordsArray[NE2.getIndex() - 1];
1785             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1786             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1787             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1788             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1789             Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
1790             double[] hd1 = coordsArray[HD1.getIndex() - 1];
1791             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
1792             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1793             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1794             double[] he1 = coordsArray[HE1.getIndex() - 1];
1795             Bond CG_CB = CG.getBond(CB);
1796             Bond ND1_CG = ND1.getBond(CG);
1797             Bond CD2_CG = CD2.getBond(CG);
1798             Bond CE1_ND1 = CE1.getBond(ND1);
1799             Bond NE2_CD2 = NE2.getBond(CD2);
1800             Bond HB_CB = HB2.getBond(CB);
1801             Bond HD1_ND1 = HD1.getBond(ND1);
1802             Bond HD2_CD2 = HD2.getBond(CD2);
1803             Bond HE1_CE1 = HE1.getBond(CE1);
1804             double dCG_CB = CG_CB.bondType.distance;
1805             double dND1_CG = ND1_CG.bondType.distance;
1806             double dCD2_CG = CD2_CG.bondType.distance;
1807             double dCE1_ND1 = CE1_ND1.bondType.distance;
1808             double dNE2_CD2 = NE2_CD2.bondType.distance;
1809             double dHB_CB = HB_CB.bondType.distance;
1810             double dHD1_ND1 = HD1_ND1.bondType.distance;
1811             double dHD2_CD2 = HD2_CD2.bondType.distance;
1812             double dHE1_CE1 = HE1_CE1.bondType.distance;
1813             Angle CG_CB_CA = CG.getAngle(CB, CA);
1814             Angle ND1_CG_CB = ND1.getAngle(CG, CB);
1815             Angle CD2_CG_CB = CD2.getAngle(CG, CB);
1816             Angle CE1_ND1_CG = CE1.getAngle(ND1, CG);
1817             Angle NE2_CD2_CG = NE2.getAngle(CD2, CG);
1818             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1819             Angle HD1_ND1_CG = HD1.getAngle(ND1, CG);
1820             Angle HD2_CD2_CG = HD2.getAngle(CD2, CG);
1821             Angle HE1_CE1_ND1 = HE1.getAngle(CE1, ND1);
1822             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1823             double dND1_CG_CB = ND1_CG_CB.angleType.angle[ND1_CG_CB.nh];
1824             double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
1825             double dCE1_ND1_CG = CE1_ND1_CG.angleType.angle[CE1_ND1_CG.nh];
1826             double dNE2_CD2_CG = NE2_CD2_CG.angleType.angle[NE2_CD2_CG.nh];
1827             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1828             double dHD1_ND1_CG = HD1_ND1_CG.angleType.angle[HD1_ND1_CG.nh];
1829             double dHD2_CD2_CG = HD2_CD2_CG.angleType.angle[HD2_CD2_CG.nh];
1830             double dHE1_CE1_ND1 = HE1_CE1_ND1.angleType.angle[HE1_CE1_ND1.nh];
1831             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1832             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1833 
1834             arraycopy(
1835                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1836                 0,
1837                 cg,
1838                 0,
1839                 3); // CG
1840             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1841 
1842             arraycopy(
1843                 determineIntxyz(cg, dND1_CG, cb, dND1_CG_CB, ca, 180.0, 0), 0, nd1, 0, 3); // ND1
1844             coordsArray = fillCoordsArray(ND1, coordsArray, nd1);
1845 
1846             arraycopy(
1847                 determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, nd1, 108.0, 1), 0, cd2, 0, 3); // CD2
1848             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1849 
1850             arraycopy(
1851                 determineIntxyz(nd1, dCE1_ND1, cg, dCE1_ND1_CG, cd2, 0.0, 0), 0, ce1, 0, 3); // CE1
1852             coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
1853 
1854             arraycopy(
1855                 determineIntxyz(cd2, dNE2_CD2, cg, dNE2_CD2_CG, nd1, 0.0, 0), 0, ne2, 0, 3); // NE2
1856             coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
1857 
1858             arraycopy(
1859                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1860             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1861 
1862             arraycopy(
1863                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1864             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1865 
1866             arraycopy(
1867                 determineIntxyz(nd1, dHD1_ND1, cg, dHD1_ND1_CG, cb, 0.0, 0), 0, hd1, 0, 3); // HD1
1868             coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
1869 
1870             arraycopy(
1871                 determineIntxyz(cd2, dHD2_CD2, cg, dHD2_CD2_CG, ne2, 126.0, 1),
1872                 0,
1873                 hd2,
1874                 0,
1875                 3); // HD2
1876             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1877 
1878             arraycopy(
1879                 determineIntxyz(ce1, dHE1_CE1, nd1, dHE1_CE1_ND1, ne2, 126.0, 1),
1880                 0,
1881                 he1,
1882                 0,
1883                 3); // HE1
1884             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1885             break;
1886           }
1887         case HIE:
1888           {
1889             Atom CB = (Atom) newResidue.getAtomNode("CB");
1890             double[] cb = coordsArray[CB.getIndex() - 1];
1891             Atom CG = (Atom) newResidue.getAtomNode("CG");
1892             double[] cg = coordsArray[CG.getIndex() - 1];
1893             Atom ND1 = (Atom) newResidue.getAtomNode("ND1");
1894             double[] nd1 = coordsArray[ND1.getIndex() - 1];
1895             Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
1896             double[] cd2 = coordsArray[CD2.getIndex() - 1];
1897             Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
1898             double[] ce1 = coordsArray[CE1.getIndex() - 1];
1899             Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
1900             double[] ne2 = coordsArray[NE2.getIndex() - 1];
1901             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
1902             double[] hb2 = coordsArray[HB2.getIndex() - 1];
1903             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
1904             double[] hb3 = coordsArray[HB3.getIndex() - 1];
1905             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
1906             double[] hd2 = coordsArray[HD2.getIndex() - 1];
1907             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
1908             double[] he1 = coordsArray[HE1.getIndex() - 1];
1909             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
1910             double[] he2 = coordsArray[HE2.getIndex() - 1];
1911             Bond CG_CB = CG.getBond(CB);
1912             Bond ND1_CG = ND1.getBond(CG);
1913             Bond CD2_CG = CD2.getBond(CG);
1914             Bond CE1_ND1 = CE1.getBond(ND1);
1915             Bond NE2_CD2 = NE2.getBond(CD2);
1916             Bond HB_CB = HB2.getBond(CB);
1917             Bond HD2_CD2 = HD2.getBond(CD2);
1918             Bond HE1_CE1 = HE1.getBond(CE1);
1919             Bond HE2_NE2 = HE2.getBond(NE2);
1920             double dCG_CB = CG_CB.bondType.distance;
1921             double dND1_CG = ND1_CG.bondType.distance;
1922             double dCD2_CG = CD2_CG.bondType.distance;
1923             double dCE1_ND1 = CE1_ND1.bondType.distance;
1924             double dNE2_CD2 = NE2_CD2.bondType.distance;
1925             double dHB_CB = HB_CB.bondType.distance;
1926             double dHD2_CD2 = HD2_CD2.bondType.distance;
1927             double dHE1_CE1 = HE1_CE1.bondType.distance;
1928             double dHE2_NE2 = HE2_NE2.bondType.distance;
1929             Angle CG_CB_CA = CG.getAngle(CB, CA);
1930             Angle ND1_CG_CB = ND1.getAngle(CG, CB);
1931             Angle CD2_CG_CB = CD2.getAngle(CG, CB);
1932             Angle CE1_ND1_CG = CE1.getAngle(ND1, CG);
1933             Angle NE2_CD2_CG = NE2.getAngle(CD2, CG);
1934             Angle HB_CB_CA = HB2.getAngle(CB, CA);
1935             Angle HD2_CD2_CG = HD2.getAngle(CD2, CG);
1936             Angle HE1_CE1_ND1 = HE1.getAngle(CE1, ND1);
1937             Angle HE2_NE2_CD2 = HE2.getAngle(NE2, CD2);
1938             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
1939             double dND1_CG_CB = ND1_CG_CB.angleType.angle[ND1_CG_CB.nh];
1940             double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
1941             double dCE1_ND1_CG = CE1_ND1_CG.angleType.angle[CE1_ND1_CG.nh];
1942             double dNE2_CD2_CG = NE2_CD2_CG.angleType.angle[NE2_CD2_CG.nh];
1943             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
1944             double dHD2_CD2_CG = HD2_CD2_CG.angleType.angle[HD2_CD2_CG.nh];
1945             double dHE1_CE1_ND1 = HE1_CE1_ND1.angleType.angle[HE1_CE1_ND1.nh];
1946             double dHE2_NE2_CD2 = HE2_NE2_CD2.angleType.angle[HE2_NE2_CD2.nh];
1947             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
1948             coordsArray = fillCoordsArray(CB, coordsArray, cb);
1949 
1950             arraycopy(
1951                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
1952                 0,
1953                 cg,
1954                 0,
1955                 3); // CG
1956             coordsArray = fillCoordsArray(CG, coordsArray, cg);
1957 
1958             arraycopy(
1959                 determineIntxyz(cg, dND1_CG, cb, dND1_CG_CB, ca, 180.0, 0), 0, nd1, 0, 3); // ND1
1960             coordsArray = fillCoordsArray(ND1, coordsArray, nd1);
1961 
1962             arraycopy(
1963                 determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, nd1, 108.0, 1), 0, cd2, 0, 3); // CD2
1964             coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
1965 
1966             arraycopy(
1967                 determineIntxyz(nd1, dCE1_ND1, cg, dCE1_ND1_CG, cd2, 0.0, 0), 0, ce1, 0, 3); // CE1
1968             coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
1969 
1970             arraycopy(
1971                 determineIntxyz(cd2, dNE2_CD2, cg, dNE2_CD2_CG, nd1, 0.0, 0), 0, ne2, 0, 3); // NE2
1972             coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
1973 
1974             arraycopy(
1975                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
1976             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
1977 
1978             arraycopy(
1979                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
1980             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
1981 
1982             arraycopy(
1983                 determineIntxyz(cd2, dHD2_CD2, cg, dHD2_CD2_CG, ne2, 126.0, 1),
1984                 0,
1985                 hd2,
1986                 0,
1987                 3); // HD2
1988             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
1989 
1990             arraycopy(
1991                 determineIntxyz(ce1, dHE1_CE1, nd1, dHE1_CE1_ND1, ne2, 126.0, 1),
1992                 0,
1993                 he1,
1994                 0,
1995                 3); // HE1
1996             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
1997 
1998             arraycopy(
1999                 determineIntxyz(ne2, dHE2_NE2, cd2, dHE2_NE2_CD2, ce1, 126.0, 1),
2000                 0,
2001                 he2,
2002                 0,
2003                 3); // HE2
2004             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
2005             break;
2006           }
2007         case ASP:
2008           {
2009             Atom CB = (Atom) newResidue.getAtomNode("CB");
2010             double[] cb = coordsArray[CB.getIndex() - 1];
2011             Atom CG = (Atom) newResidue.getAtomNode("CG");
2012             double[] cg = coordsArray[CG.getIndex() - 1];
2013             Atom OD1 = (Atom) newResidue.getAtomNode("OD1");
2014             double[] od1 = coordsArray[OD1.getIndex() - 1];
2015             Atom OD2 = (Atom) newResidue.getAtomNode("OD2");
2016             double[] od2 = coordsArray[OD2.getIndex() - 1];
2017             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2018             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2019             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2020             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2021             Bond CG_CB = CG.getBond(CB);
2022             Bond OD1_CG = OD1.getBond(CG);
2023             Bond OD2_CG = OD2.getBond(CG);
2024             Bond HB_CB = HB2.getBond(CB);
2025             double dCG_CB = CG_CB.bondType.distance;
2026             double dOD1_CG = OD1_CG.bondType.distance;
2027             double dOD2_CG = OD2_CG.bondType.distance;
2028             double dHB_CB = HB_CB.bondType.distance;
2029             Angle CG_CB_CA = CG.getAngle(CB, CA);
2030             Angle OD1_CG_CB = OD1.getAngle(CG, CB);
2031             Angle OD2_CG_CB = OD2.getAngle(CG, CB);
2032             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2033             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2034             double dOD1_CG_CB = OD1_CG_CB.angleType.angle[OD1_CG_CB.nh];
2035             double dOD2_CG_CB = OD2_CG_CB.angleType.angle[OD2_CG_CB.nh];
2036             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2037             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2038             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2039 
2040             arraycopy(
2041                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2042                 0,
2043                 cg,
2044                 0,
2045                 3); // CG
2046             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2047 
2048             arraycopy(
2049                 determineIntxyz(cg, dOD1_CG, cb, dOD1_CG_CB, ca, 0.0, 0), 0, od1, 0, 3); // OD1
2050             coordsArray = fillCoordsArray(OD1, coordsArray, od1);
2051 
2052             arraycopy(
2053                 determineIntxyz(cg, dOD2_CG, cb, dOD2_CG_CB, od1, 126.0, 1), 0, od2, 0, 3); // OD2
2054             coordsArray = fillCoordsArray(OD2, coordsArray, od2);
2055 
2056             arraycopy(
2057                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, 1), 0, hb2, 0, 3); // HB2
2058             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2059 
2060             arraycopy(
2061                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, -1), 0, hb3, 0, 3); // HB3
2062             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2063             break;
2064           }
2065         case ASH:
2066           {
2067             Atom CB = (Atom) newResidue.getAtomNode("CB");
2068             double[] cb = coordsArray[CB.getIndex() - 1];
2069             Atom CG = (Atom) newResidue.getAtomNode("CG");
2070             double[] cg = coordsArray[CG.getIndex() - 1];
2071             Atom OD1 = (Atom) newResidue.getAtomNode("OD1");
2072             double[] od1 = coordsArray[OD1.getIndex() - 1];
2073             Atom OD2 = (Atom) newResidue.getAtomNode("OD2");
2074             double[] od2 = coordsArray[OD2.getIndex() - 1];
2075             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2076             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2077             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2078             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2079             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
2080             double[] hd2 = coordsArray[HD2.getIndex() - 1];
2081             Bond CG_CB = CG.getBond(CB);
2082             Bond OD1_CG = OD1.getBond(CG);
2083             Bond OD2_CG = OD2.getBond(CG);
2084             Bond HB_CB = HB2.getBond(CB);
2085             Bond HD2_OD2 = HD2.getBond(OD2);
2086             double dCG_CB = CG_CB.bondType.distance;
2087             double dOD1_CG = OD1_CG.bondType.distance;
2088             double dOD2_CG = OD2_CG.bondType.distance;
2089             double dHB_CB = HB_CB.bondType.distance;
2090             double dHD2_OD2 = HD2_OD2.bondType.distance;
2091             Angle CG_CB_CA = CG.getAngle(CB, CA);
2092             Angle OD1_CG_CB = OD1.getAngle(CG, CB);
2093             Angle OD2_CG_CB = OD2.getAngle(CG, CB);
2094             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2095             Angle HD2_OD2_CG = HD2.getAngle(OD2, CG);
2096             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2097             double dOD1_CG_CB = OD1_CG_CB.angleType.angle[OD1_CG_CB.nh];
2098             double dOD2_CG_CB = OD2_CG_CB.angleType.angle[OD2_CG_CB.nh];
2099             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2100             double dHD2_OD2_CG = HD2_OD2_CG.angleType.angle[HD2_OD2_CG.nh];
2101             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2102             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2103 
2104             arraycopy(
2105                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2106                 0,
2107                 cg,
2108                 0,
2109                 3); // CG
2110             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2111 
2112             arraycopy(
2113                 determineIntxyz(cg, dOD1_CG, cb, dOD1_CG_CB, ca, 0.0, 0), 0, od1, 0, 3); // OD1
2114             coordsArray = fillCoordsArray(OD1, coordsArray, od1);
2115 
2116             arraycopy(
2117                 determineIntxyz(cg, dOD2_CG, cb, dOD2_CG_CB, od1, 126.0, 1), 0, od2, 0, 3); // OD2
2118             coordsArray = fillCoordsArray(OD2, coordsArray, od2);
2119 
2120             arraycopy(
2121                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, 1), 0, hb2, 0, 3); // HB2
2122             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2123 
2124             arraycopy(
2125                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, -1), 0, hb3, 0, 3); // HB3
2126             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2127 
2128             arraycopy(
2129                 determineIntxyz(od2, dHD2_OD2, cg, dHD2_OD2_CG, od1, 0.0, 0), 0, hd2, 0, 3); // HD2
2130             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
2131             break;
2132           }
2133         case ASN:
2134           {
2135             Atom CB = (Atom) newResidue.getAtomNode("CB");
2136             double[] cb = coordsArray[CB.getIndex() - 1];
2137             Atom CG = (Atom) newResidue.getAtomNode("CG");
2138             double[] cg = coordsArray[CG.getIndex() - 1];
2139             Atom OD1 = (Atom) newResidue.getAtomNode("OD1");
2140             double[] od1 = coordsArray[OD1.getIndex() - 1];
2141             Atom ND2 = (Atom) newResidue.getAtomNode("ND2");
2142             double[] nd2 = coordsArray[ND2.getIndex() - 1];
2143             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2144             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2145             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2146             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2147             Atom HD21 = (Atom) newResidue.getAtomNode("HD21");
2148             double[] hd21 = coordsArray[HD21.getIndex() - 1];
2149             Atom HD22 = (Atom) newResidue.getAtomNode("HD22");
2150             double[] hd22 = coordsArray[HD22.getIndex() - 1];
2151             Bond CG_CB = CG.getBond(CB);
2152             Bond OD1_CG = OD1.getBond(CG);
2153             Bond ND2_CG = ND2.getBond(CG);
2154             Bond HB_CB = HB2.getBond(CB);
2155             Bond HD2_ND2 = HD21.getBond(ND2);
2156             double dCG_CB = CG_CB.bondType.distance;
2157             double dOD1_CG = OD1_CG.bondType.distance;
2158             double dND2_CG = ND2_CG.bondType.distance;
2159             double dHB_CB = HB_CB.bondType.distance;
2160             double dHD2_ND2 = HD2_ND2.bondType.distance;
2161             Angle CG_CB_CA = CG.getAngle(CB, CA);
2162             Angle OD1_CG_CB = OD1.getAngle(CG, CB);
2163             Angle ND2_CG_CB = ND2.getAngle(CG, CB);
2164             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2165             Angle HD2_ND2_CG = HD21.getAngle(ND2, CG);
2166             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2167             double dOD1_CG_CB = OD1_CG_CB.angleType.angle[OD1_CG_CB.nh];
2168             double dND2_CG_CB = ND2_CG_CB.angleType.angle[ND2_CG_CB.nh];
2169             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2170             double dHD2_ND2_CG = HD2_ND2_CG.angleType.angle[HD2_ND2_CG.nh];
2171             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2172             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2173 
2174             arraycopy(
2175                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2176                 0,
2177                 cg,
2178                 0,
2179                 3); // CG
2180             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2181 
2182             arraycopy(
2183                 determineIntxyz(cg, dOD1_CG, cb, dOD1_CG_CB, ca, 0.0, 0), 0, od1, 0, 3); // OD1
2184             coordsArray = fillCoordsArray(OD1, coordsArray, od1);
2185 
2186             arraycopy(
2187                 determineIntxyz(cg, dND2_CG, cb, dND2_CG_CB, od1, 124.0, 1), 0, nd2, 0, 3); // ND2
2188             coordsArray = fillCoordsArray(ND2, coordsArray, nd2);
2189 
2190             arraycopy(
2191                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, 1), 0, hb2, 0, 3); // HB2
2192             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2193 
2194             arraycopy(
2195                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, -1), 0, hb3, 0, 3); // HB3
2196             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2197 
2198             arraycopy(
2199                 determineIntxyz(nd2, dHD2_ND2, cg, dHD2_ND2_CG, cb, 0.0, 0), 0, hd21, 0, 3); // HD21
2200             coordsArray = fillCoordsArray(HD21, coordsArray, hd21);
2201 
2202             arraycopy(
2203                 determineIntxyz(nd2, dHD2_ND2, cg, dHD2_ND2_CG, hd21, 120.0, 1),
2204                 0,
2205                 hd22,
2206                 0,
2207                 3); // HD22
2208             coordsArray = fillCoordsArray(HD22, coordsArray, hd22);
2209             break;
2210           }
2211         case GLU:
2212           {
2213             Atom CB = (Atom) newResidue.getAtomNode("CB");
2214             double[] cb = coordsArray[CB.getIndex() - 1];
2215             Atom CG = (Atom) newResidue.getAtomNode("CG");
2216             double[] cg = coordsArray[CG.getIndex() - 1];
2217             Atom CD = (Atom) newResidue.getAtomNode("CD");
2218             double[] cd = coordsArray[CD.getIndex() - 1];
2219             Atom OE1 = (Atom) newResidue.getAtomNode("OE1");
2220             double[] oe1 = coordsArray[OE1.getIndex() - 1];
2221             Atom OE2 = (Atom) newResidue.getAtomNode("OE2");
2222             double[] oe2 = coordsArray[OE2.getIndex() - 1];
2223             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2224             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2225             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2226             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2227             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2228             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2229             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2230             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2231             Bond CG_CB = CG.getBond(CB);
2232             Bond CD_CG = CD.getBond(CG);
2233             Bond OE1_CD = OE1.getBond(CD);
2234             Bond OE2_CD = OE2.getBond(CD);
2235             Bond HB_CB = HB2.getBond(CB);
2236             Bond HG_CG = HG2.getBond(CG);
2237             double dCG_CB = CG_CB.bondType.distance;
2238             double dCD_CG = CD_CG.bondType.distance;
2239             double dOE1_CD = OE1_CD.bondType.distance;
2240             double dOE2_CD = OE2_CD.bondType.distance;
2241             double dHB_CB = HB_CB.bondType.distance;
2242             double dHG_CG = HG_CG.bondType.distance;
2243             Angle CG_CB_CA = CG.getAngle(CB, CA);
2244             Angle CD_CG_CB = CD.getAngle(CG, CB);
2245             Angle OE1_CD_CG = OE1.getAngle(CD, CG);
2246             Angle OE2_CD_CG = OE2.getAngle(CD, CG);
2247             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2248             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2249             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2250             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
2251             double dOE1_CD_CG = OE1_CD_CG.angleType.angle[OE1_CD_CG.nh];
2252             double dOE2_CD_CG = OE2_CD_CG.angleType.angle[OE2_CD_CG.nh];
2253             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2254             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2255             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2256             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2257 
2258             arraycopy(
2259                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2260                 0,
2261                 cg,
2262                 0,
2263                 3); // CG
2264             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2265 
2266             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3); // CD
2267             coordsArray = fillCoordsArray(CD, coordsArray, cd);
2268 
2269             arraycopy(
2270                 determineIntxyz(cd, dOE1_CD, cg, dOE1_CD_CG, cb, 180.0, 0), 0, oe1, 0, 3); // OE1
2271             coordsArray = fillCoordsArray(OE1, coordsArray, oe1);
2272 
2273             arraycopy(
2274                 determineIntxyz(cd, dOE2_CD, cg, dOE2_CD_CG, oe1, 126.0, 1), 0, oe2, 0, 3); // OE2
2275             coordsArray = fillCoordsArray(OE2, coordsArray, oe2);
2276 
2277             arraycopy(
2278                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2279             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2280 
2281             arraycopy(
2282                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2283             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2284 
2285             arraycopy(
2286                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, 1), 0, hg2, 0, 3); // HG2
2287             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2288 
2289             arraycopy(
2290                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, -1), 0, hg3, 0, 3); // HG3
2291             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2292             break;
2293           }
2294         case GLH:
2295           {
2296             Atom CB = (Atom) newResidue.getAtomNode("CB");
2297             double[] cb = coordsArray[CB.getIndex() - 1];
2298             Atom CG = (Atom) newResidue.getAtomNode("CG");
2299             double[] cg = coordsArray[CG.getIndex() - 1];
2300             Atom CD = (Atom) newResidue.getAtomNode("CD");
2301             double[] cd = coordsArray[CD.getIndex() - 1];
2302             Atom OE1 = (Atom) newResidue.getAtomNode("OE1");
2303             double[] oe1 = coordsArray[OE1.getIndex() - 1];
2304             Atom OE2 = (Atom) newResidue.getAtomNode("OE2");
2305             double[] oe2 = coordsArray[OE2.getIndex() - 1];
2306             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2307             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2308             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2309             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2310             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2311             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2312             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2313             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2314             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
2315             double[] he2 = coordsArray[HE2.getIndex() - 1];
2316             Bond CG_CB = CG.getBond(CB);
2317             Bond CD_CG = CD.getBond(CG);
2318             Bond OE1_CD = OE1.getBond(CD);
2319             Bond OE2_CD = OE2.getBond(CD);
2320             Bond HB_CB = HB2.getBond(CB);
2321             Bond HG_CG = HG2.getBond(CG);
2322             Bond HE2_OE2 = HE2.getBond(OE2);
2323             double dCG_CB = CG_CB.bondType.distance;
2324             double dCD_CG = CD_CG.bondType.distance;
2325             double dOE1_CD = OE1_CD.bondType.distance;
2326             double dOE2_CD = OE2_CD.bondType.distance;
2327             double dHB_CB = HB_CB.bondType.distance;
2328             double dHG_CG = HG_CG.bondType.distance;
2329             double dHE2_OE2 = HE2_OE2.bondType.distance;
2330             Angle CG_CB_CA = CG.getAngle(CB, CA);
2331             Angle CD_CG_CB = CD.getAngle(CG, CB);
2332             Angle OE1_CD_CG = OE1.getAngle(CD, CG);
2333             Angle OE2_CD_CG = OE2.getAngle(CD, CG);
2334             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2335             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2336             Angle HE2_OE2_CD = HE2.getAngle(OE2, CD);
2337             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2338             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
2339             double dOE1_CD_CG = OE1_CD_CG.angleType.angle[OE1_CD_CG.nh];
2340             double dOE2_CD_CG = OE2_CD_CG.angleType.angle[OE2_CD_CG.nh];
2341             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2342             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2343             double dHE2_OE2_CD = HE2_OE2_CD.angleType.angle[HE2_OE2_CD.nh];
2344             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2345             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2346 
2347             arraycopy(
2348                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2349                 0,
2350                 cg,
2351                 0,
2352                 3); // CG
2353             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2354 
2355             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3); // CD
2356             coordsArray = fillCoordsArray(CD, coordsArray, cd);
2357 
2358             arraycopy(
2359                 determineIntxyz(cd, dOE1_CD, cg, dOE1_CD_CG, cb, 180.0, 0), 0, oe1, 0, 3); // OE1
2360             coordsArray = fillCoordsArray(OE1, coordsArray, oe1);
2361 
2362             arraycopy(
2363                 determineIntxyz(cd, dOE2_CD, cg, dOE2_CD_CG, oe1, 126.0, 1), 0, oe2, 0, 3); // OE2
2364             coordsArray = fillCoordsArray(OE2, coordsArray, oe2);
2365 
2366             arraycopy(
2367                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2368             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2369 
2370             arraycopy(
2371                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2372             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2373 
2374             arraycopy(
2375                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, 1), 0, hg2, 0, 3); // HG2
2376             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2377 
2378             arraycopy(
2379                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, -1), 0, hg3, 0, 3); // HG3
2380             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2381 
2382             arraycopy(
2383                 determineIntxyz(oe2, dHE2_OE2, cd, dHE2_OE2_CD, oe1, 0.0, 0), 0, he2, 0, 3); // HE2
2384             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
2385             break;
2386           }
2387         case GLN:
2388           {
2389             Atom CB = (Atom) newResidue.getAtomNode("CB");
2390             double[] cb = coordsArray[CB.getIndex() - 1];
2391             Atom CG = (Atom) newResidue.getAtomNode("CG");
2392             double[] cg = coordsArray[CG.getIndex() - 1];
2393             Atom CD = (Atom) newResidue.getAtomNode("CD");
2394             double[] cd = coordsArray[CD.getIndex() - 1];
2395             Atom OE1 = (Atom) newResidue.getAtomNode("OE1");
2396             double[] oe1 = coordsArray[OE1.getIndex() - 1];
2397             Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
2398             double[] ne2 = coordsArray[NE2.getIndex() - 1];
2399             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2400             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2401             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2402             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2403             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2404             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2405             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2406             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2407             Atom HE21 = (Atom) newResidue.getAtomNode("HE21");
2408             double[] he21 = coordsArray[HE21.getIndex() - 1];
2409             Atom HE22 = (Atom) newResidue.getAtomNode("HE22");
2410             double[] he22 = coordsArray[HE22.getIndex() - 1];
2411             Bond CG_CB = CG.getBond(CB);
2412             Bond CD_CG = CD.getBond(CG);
2413             Bond OE1_CD = OE1.getBond(CD);
2414             Bond NE2_CD = NE2.getBond(CD);
2415             Bond HB_CB = HB2.getBond(CB);
2416             Bond HG_CG = HG2.getBond(CG);
2417             Bond HE2_NE2 = HE21.getBond(NE2);
2418             double dCG_CB = CG_CB.bondType.distance;
2419             double dCD_CG = CD_CG.bondType.distance;
2420             double dOE1_CD = OE1_CD.bondType.distance;
2421             double dNE2_CD = NE2_CD.bondType.distance;
2422             double dHB_CB = HB_CB.bondType.distance;
2423             double dHG_CG = HG_CG.bondType.distance;
2424             double dHE2_NE2 = HE2_NE2.bondType.distance;
2425             Angle CG_CB_CA = CG.getAngle(CB, CA);
2426             Angle CD_CG_CB = CD.getAngle(CG, CB);
2427             Angle OE1_CD_CG = OE1.getAngle(CD, CG);
2428             Angle NE2_CD_CG = NE2.getAngle(CD, CG);
2429             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2430             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2431             Angle HE2_NE2_CD = HE21.getAngle(NE2, CD);
2432             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2433             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
2434             double dOE1_CD_CG = OE1_CD_CG.angleType.angle[OE1_CD_CG.nh];
2435             double dNE2_CD_CG = NE2_CD_CG.angleType.angle[NE2_CD_CG.nh];
2436             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2437             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2438             double dHE2_NE2_CD = HE2_NE2_CD.angleType.angle[HE2_NE2_CD.nh];
2439             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2440             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2441 
2442             arraycopy(
2443                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2444                 0,
2445                 cg,
2446                 0,
2447                 3); // CG
2448             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2449 
2450             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3); // CD
2451             coordsArray = fillCoordsArray(CD, coordsArray, cd);
2452 
2453             arraycopy(
2454                 determineIntxyz(cd, dOE1_CD, cg, dOE1_CD_CG, cb, 180.0, 0), 0, oe1, 0, 3); // OE1
2455             coordsArray = fillCoordsArray(OE1, coordsArray, oe1);
2456 
2457             arraycopy(
2458                 determineIntxyz(cd, dNE2_CD, cg, dNE2_CD_CG, oe1, 124.0, 1), 0, ne2, 0, 3); // NE2
2459             coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
2460 
2461             arraycopy(
2462                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2463             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2464 
2465             arraycopy(
2466                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2467             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2468 
2469             arraycopy(
2470                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, 1), 0, hg2, 0, 3); // HG2
2471             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2472 
2473             arraycopy(
2474                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, -1), 0, hg3, 0, 3); // HG3
2475             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2476 
2477             arraycopy(
2478                 determineIntxyz(ne2, dHE2_NE2, cd, dHE2_NE2_CD, cg, 0.0, 0), 0, he21, 0, 3); // HE21
2479             coordsArray = fillCoordsArray(HE21, coordsArray, he21);
2480 
2481             arraycopy(
2482                 determineIntxyz(ne2, dHE2_NE2, cd, dHE2_NE2_CD, he21, 120.0, 1),
2483                 0,
2484                 he22,
2485                 0,
2486                 3); // HE22
2487             coordsArray = fillCoordsArray(HE22, coordsArray, he22);
2488             break;
2489           }
2490         case MET:
2491           {
2492             Atom CB = (Atom) newResidue.getAtomNode("CB");
2493             double[] cb = coordsArray[CB.getIndex() - 1];
2494             Atom CG = (Atom) newResidue.getAtomNode("CG");
2495             double[] cg = coordsArray[CG.getIndex() - 1];
2496             Atom SD = (Atom) newResidue.getAtomNode("SD");
2497             double[] sd = coordsArray[SD.getIndex() - 1];
2498             Atom CE = (Atom) newResidue.getAtomNode("CE");
2499             double[] ce = coordsArray[CE.getIndex() - 1];
2500             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2501             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2502             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2503             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2504             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2505             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2506             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2507             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2508             Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
2509             double[] he1 = coordsArray[HE1.getIndex() - 1];
2510             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
2511             double[] he2 = coordsArray[HE2.getIndex() - 1];
2512             Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
2513             double[] he3 = coordsArray[HE3.getIndex() - 1];
2514             Bond CG_CB = CG.getBond(CB);
2515             Bond SD_CG = SD.getBond(CG);
2516             Bond CE_SD = CE.getBond(SD);
2517             Bond HB_CB = HB2.getBond(CB);
2518             Bond HG_CG = HG2.getBond(CG);
2519             Bond HE_CE = HE1.getBond(CE);
2520             double dCG_CB = CG_CB.bondType.distance;
2521             double dSD_CG = SD_CG.bondType.distance;
2522             double dCE_SD = CE_SD.bondType.distance;
2523             double dHB_CB = HB_CB.bondType.distance;
2524             double dHG_CG = HG_CG.bondType.distance;
2525             double dHE_CE = HE_CE.bondType.distance;
2526             Angle CG_CB_CA = CG.getAngle(CB, CA);
2527             Angle SD_CG_CB = SD.getAngle(CG, CB);
2528             Angle CE_SD_CG = CE.getAngle(SD, CG);
2529             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2530             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2531             Angle HE_CE_SD = HE1.getAngle(CE, SD);
2532             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2533             double dSD_CG_CB = SD_CG_CB.angleType.angle[SD_CG_CB.nh];
2534             double dCE_SD_CG = CE_SD_CG.angleType.angle[CE_SD_CG.nh];
2535             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2536             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2537             double dHE_CE_SD = HE_CE_SD.angleType.angle[HE_CE_SD.nh];
2538             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2539             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2540 
2541             arraycopy(
2542                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2543                 0,
2544                 cg,
2545                 0,
2546                 3); // CG
2547             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2548 
2549             arraycopy(determineIntxyz(cg, dSD_CG, cb, dSD_CG_CB, ca, 180.0, 0), 0, sd, 0, 3); // SD
2550             coordsArray = fillCoordsArray(SD, coordsArray, sd);
2551 
2552             arraycopy(determineIntxyz(sd, dCE_SD, cg, dCE_SD_CG, cb, 180.0, 0), 0, ce, 0, 3); // CE
2553             coordsArray = fillCoordsArray(CE, coordsArray, ce);
2554 
2555             arraycopy(
2556                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2557             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2558 
2559             arraycopy(
2560                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2561             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2562 
2563             arraycopy(
2564                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, sd, 112.0, 1), 0, hg2, 0, 3); // HG2
2565             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2566 
2567             arraycopy(
2568                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, sd, 112.0, -1), 0, hg3, 0, 3); // HG3
2569             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2570 
2571             arraycopy(
2572                 determineIntxyz(ce, dHE_CE, sd, dHE_CE_SD, cg, 180.0, 0), 0, he1, 0, 3); // HE1
2573             coordsArray = fillCoordsArray(HE1, coordsArray, he1);
2574 
2575             arraycopy(
2576                 determineIntxyz(ce, dHE_CE, sd, dHE_CE_SD, he1, 109.4, 1), 0, he2, 0, 3); // HE2
2577             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
2578 
2579             arraycopy(
2580                 determineIntxyz(ce, dHE_CE, sd, dHE_CE_SD, he1, 109.4, -1), 0, he3, 0, 3); // HE3
2581             coordsArray = fillCoordsArray(HE3, coordsArray, he3);
2582             break;
2583           }
2584         case LYS:
2585           {
2586             Atom CB = (Atom) newResidue.getAtomNode("CB");
2587             double[] cb = coordsArray[CB.getIndex() - 1];
2588             Atom CG = (Atom) newResidue.getAtomNode("CG");
2589             double[] cg = coordsArray[CG.getIndex() - 1];
2590             Atom CD = (Atom) newResidue.getAtomNode("CD");
2591             double[] cd = coordsArray[CD.getIndex() - 1];
2592             Atom CE = (Atom) newResidue.getAtomNode("CE");
2593             double[] ce = coordsArray[CE.getIndex() - 1];
2594             Atom NZ = (Atom) newResidue.getAtomNode("NZ");
2595             double[] nz = coordsArray[NZ.getIndex() - 1];
2596             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2597             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2598             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2599             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2600             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2601             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2602             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2603             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2604             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
2605             double[] hd2 = coordsArray[HD2.getIndex() - 1];
2606             Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
2607             double[] hd3 = coordsArray[HD3.getIndex() - 1];
2608             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
2609             double[] he2 = coordsArray[HE2.getIndex() - 1];
2610             Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
2611             double[] he3 = coordsArray[HE3.getIndex() - 1];
2612             Atom HZ1 = (Atom) newResidue.getAtomNode("HZ1");
2613             double[] hz1 = coordsArray[HZ1.getIndex() - 1];
2614             Atom HZ2 = (Atom) newResidue.getAtomNode("HZ2");
2615             double[] hz2 = coordsArray[HZ2.getIndex() - 1];
2616             Atom HZ3 = (Atom) newResidue.getAtomNode("HZ3");
2617             double[] hz3 = coordsArray[HZ3.getIndex() - 1];
2618             Bond CG_CB = CG.getBond(CB);
2619             Bond CD_CG = CD.getBond(CG);
2620             Bond CE_CD = CE.getBond(CD);
2621             Bond NZ_CE = NZ.getBond(CE);
2622             Bond HB_CB = HB2.getBond(CB);
2623             Bond HG_CG = HG2.getBond(CG);
2624             Bond HD_CD = HD2.getBond(CD);
2625             Bond HE_CE = HE2.getBond(CE);
2626             Bond HZ_NZ = HZ1.getBond(NZ);
2627             double dCG_CB = CG_CB.bondType.distance;
2628             double dCD_CG = CD_CG.bondType.distance;
2629             double dCE_CD = CE_CD.bondType.distance;
2630             double dNZ_CE = NZ_CE.bondType.distance;
2631             double dHB_CB = HB_CB.bondType.distance;
2632             double dHG_CG = HG_CG.bondType.distance;
2633             double dHD_CD = HD_CD.bondType.distance;
2634             double dHE_CE = HE_CE.bondType.distance;
2635             double dHZ_NZ = HZ_NZ.bondType.distance;
2636             Angle CG_CB_CA = CG.getAngle(CB, CA);
2637             Angle CD_CG_CB = CD.getAngle(CG, CB);
2638             Angle CE_CD_CG = CE.getAngle(CD, CG);
2639             Angle NZ_CE_CD = NZ.getAngle(CE, CD);
2640             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2641             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2642             Angle HD_CD_CG = HD2.getAngle(CD, CG);
2643             Angle HE_CE_CD = HE2.getAngle(CE, CD);
2644             Angle HZ_NZ_CE = HZ1.getAngle(NZ, CE);
2645             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2646             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
2647             double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
2648             double dNZ_CE_CD = NZ_CE_CD.angleType.angle[NZ_CE_CD.nh];
2649             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2650             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2651             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
2652             double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
2653             double dHZ_NZ_CE = HZ_NZ_CE.angleType.angle[HZ_NZ_CE.nh];
2654             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2655             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2656 
2657             arraycopy(
2658                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2659                 0,
2660                 cg,
2661                 0,
2662                 3); // CG
2663             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2664 
2665             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3); // CD
2666             coordsArray = fillCoordsArray(CD, coordsArray, cd);
2667 
2668             arraycopy(determineIntxyz(cd, dCE_CD, cg, dCE_CD_CG, cb, 180.0, 0), 0, ce, 0, 3); // CE
2669             coordsArray = fillCoordsArray(CE, coordsArray, ce);
2670 
2671             arraycopy(determineIntxyz(ce, dNZ_CE, cd, dNZ_CE_CD, cg, 180.0, 0), 0, nz, 0, 3); // NZ
2672             coordsArray = fillCoordsArray(NZ, coordsArray, nz);
2673 
2674             arraycopy(
2675                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2676             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2677 
2678             arraycopy(
2679                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2680             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2681 
2682             arraycopy(
2683                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3); // HG2
2684             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2685 
2686             arraycopy(
2687                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3); // HG3
2688             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2689 
2690             arraycopy(
2691                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, 1), 0, hd2, 0, 3); // HD2
2692             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
2693 
2694             arraycopy(
2695                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, -1), 0, hd3, 0, 3); // HD3
2696             coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
2697 
2698             arraycopy(
2699                 determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, 1), 0, he2, 0, 3); // HE2
2700             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
2701 
2702             arraycopy(
2703                 determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, -1), 0, he3, 0, 3); // HE3
2704             coordsArray = fillCoordsArray(HE3, coordsArray, he3);
2705 
2706             arraycopy(
2707                 determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, cd, 180.0, 0), 0, hz1, 0, 3); // HZ1
2708             coordsArray = fillCoordsArray(HZ1, coordsArray, hz1);
2709 
2710             arraycopy(
2711                 determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, hz1, 109.5, 1), 0, hz2, 0, 3); // HZ2
2712             coordsArray = fillCoordsArray(HZ2, coordsArray, hz2);
2713 
2714             arraycopy(
2715                 determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, hz1, 109.5, -1), 0, hz3, 0, 3); // HZ3
2716             coordsArray = fillCoordsArray(HZ3, coordsArray, hz3);
2717             break;
2718           }
2719         case LYD:
2720           {
2721             Atom CB = (Atom) newResidue.getAtomNode("CB");
2722             double[] cb = coordsArray[CB.getIndex() - 1];
2723             Atom CG = (Atom) newResidue.getAtomNode("CG");
2724             double[] cg = coordsArray[CG.getIndex() - 1];
2725             Atom CD = (Atom) newResidue.getAtomNode("CD");
2726             double[] cd = coordsArray[CD.getIndex() - 1];
2727             Atom CE = (Atom) newResidue.getAtomNode("CE");
2728             double[] ce = coordsArray[CE.getIndex() - 1];
2729             Atom NZ = (Atom) newResidue.getAtomNode("NZ");
2730             double[] nz = coordsArray[NZ.getIndex() - 1];
2731             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2732             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2733             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2734             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2735             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2736             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2737             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2738             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2739             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
2740             double[] hd2 = coordsArray[HD2.getIndex() - 1];
2741             Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
2742             double[] hd3 = coordsArray[HD3.getIndex() - 1];
2743             Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
2744             double[] he2 = coordsArray[HE2.getIndex() - 1];
2745             Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
2746             double[] he3 = coordsArray[HE3.getIndex() - 1];
2747             Atom HZ1 = (Atom) newResidue.getAtomNode("HZ1");
2748             double[] hz1 = coordsArray[HZ1.getIndex() - 1];
2749             Atom HZ2 = (Atom) newResidue.getAtomNode("HZ2");
2750             double[] hz2 = coordsArray[HZ2.getIndex() - 1];
2751             Bond CG_CB = CG.getBond(CB);
2752             Bond CD_CG = CD.getBond(CG);
2753             Bond CE_CD = CE.getBond(CD);
2754             Bond NZ_CE = NZ.getBond(CE);
2755             Bond HB_CB = HB2.getBond(CB);
2756             Bond HG_CG = HG2.getBond(CG);
2757             Bond HD_CD = HD2.getBond(CD);
2758             Bond HE_CE = HE2.getBond(CE);
2759             Bond HZ_NZ = HZ1.getBond(NZ);
2760             double dCG_CB = CG_CB.bondType.distance;
2761             double dCD_CG = CD_CG.bondType.distance;
2762             double dCE_CD = CE_CD.bondType.distance;
2763             double dNZ_CE = NZ_CE.bondType.distance;
2764             double dHB_CB = HB_CB.bondType.distance;
2765             double dHG_CG = HG_CG.bondType.distance;
2766             double dHD_CD = HD_CD.bondType.distance;
2767             double dHE_CE = HE_CE.bondType.distance;
2768             double dHZ_NZ = HZ_NZ.bondType.distance;
2769             Angle CG_CB_CA = CG.getAngle(CB, CA);
2770             Angle CD_CG_CB = CD.getAngle(CG, CB);
2771             Angle CE_CD_CG = CE.getAngle(CD, CG);
2772             Angle NZ_CE_CD = NZ.getAngle(CE, CD);
2773             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2774             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2775             Angle HD_CD_CG = HD2.getAngle(CD, CG);
2776             Angle HE_CE_CD = HE2.getAngle(CE, CD);
2777             Angle HZ_NZ_CE = HZ1.getAngle(NZ, CE);
2778             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2779             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
2780             double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
2781             double dNZ_CE_CD = NZ_CE_CD.angleType.angle[NZ_CE_CD.nh];
2782             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2783             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2784             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
2785             double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
2786             double dHZ_NZ_CE = HZ_NZ_CE.angleType.angle[HZ_NZ_CE.nh];
2787             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2788             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2789 
2790             arraycopy(
2791                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2792                 0,
2793                 cg,
2794                 0,
2795                 3); // CG
2796             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2797 
2798             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3); // CD
2799             coordsArray = fillCoordsArray(CD, coordsArray, cd);
2800 
2801             arraycopy(determineIntxyz(cd, dCE_CD, cg, dCE_CD_CG, cb, 180.0, 0), 0, ce, 0, 3); // CE
2802             coordsArray = fillCoordsArray(CE, coordsArray, ce);
2803 
2804             arraycopy(determineIntxyz(ce, dNZ_CE, cd, dNZ_CE_CD, cg, 180.0, 0), 0, nz, 0, 3); // NZ
2805             coordsArray = fillCoordsArray(NZ, coordsArray, nz);
2806 
2807             arraycopy(
2808                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2809             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2810 
2811             arraycopy(
2812                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2813             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2814 
2815             arraycopy(
2816                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3); // HG2
2817             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2818 
2819             arraycopy(
2820                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3); // HG3
2821             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2822 
2823             arraycopy(
2824                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, 1), 0, hd2, 0, 3); // HD2
2825             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
2826 
2827             arraycopy(
2828                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, -1), 0, hd3, 0, 3); // HD3
2829             coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
2830 
2831             arraycopy(
2832                 determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, 1), 0, he2, 0, 3); // HE2
2833             coordsArray = fillCoordsArray(HE2, coordsArray, he2);
2834 
2835             arraycopy(
2836                 determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, -1), 0, he3, 0, 3); // HE3
2837             coordsArray = fillCoordsArray(HE3, coordsArray, he3);
2838 
2839             arraycopy(
2840                 determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, cd, 180.0, 0), 0, hz1, 0, 3); // HZ1
2841             coordsArray = fillCoordsArray(HZ1, coordsArray, hz1);
2842 
2843             arraycopy(
2844                 determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, hz1, 109.5, 1), 0, hz2, 0, 3); // HZ2
2845             coordsArray = fillCoordsArray(HZ2, coordsArray, hz2);
2846             break;
2847           }
2848         case ARG:
2849           {
2850             Atom CB = (Atom) newResidue.getAtomNode("CB");
2851             double[] cb = coordsArray[CB.getIndex() - 1];
2852             Atom CG = (Atom) newResidue.getAtomNode("CG");
2853             double[] cg = coordsArray[CG.getIndex() - 1];
2854             Atom CD = (Atom) newResidue.getAtomNode("CD");
2855             double[] cd = coordsArray[CD.getIndex() - 1];
2856             Atom NE = (Atom) newResidue.getAtomNode("NE");
2857             double[] ne = coordsArray[NE.getIndex() - 1];
2858             Atom CZ = (Atom) newResidue.getAtomNode("CZ");
2859             double[] cz = coordsArray[CZ.getIndex() - 1];
2860             Atom NH1 = (Atom) newResidue.getAtomNode("NH1");
2861             double[] nh1 = coordsArray[NH1.getIndex() - 1];
2862             Atom NH2 = (Atom) newResidue.getAtomNode("NH2");
2863             double[] nh2 = coordsArray[NH2.getIndex() - 1];
2864             Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
2865             double[] hb2 = coordsArray[HB2.getIndex() - 1];
2866             Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
2867             double[] hb3 = coordsArray[HB3.getIndex() - 1];
2868             Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
2869             double[] hg2 = coordsArray[HG2.getIndex() - 1];
2870             Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
2871             double[] hg3 = coordsArray[HG3.getIndex() - 1];
2872             Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
2873             double[] hd2 = coordsArray[HG2.getIndex() - 1];
2874             Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
2875             double[] hd3 = coordsArray[HD3.getIndex() - 1];
2876             Atom HE = (Atom) newResidue.getAtomNode("HE");
2877             double[] he = coordsArray[HE.getIndex() - 1];
2878             Atom HH11 = (Atom) newResidue.getAtomNode("HH11");
2879             double[] hh11 = coordsArray[HH11.getIndex() - 1];
2880             Atom HH12 = (Atom) newResidue.getAtomNode("HH12");
2881             double[] hh12 = coordsArray[HH12.getIndex() - 1];
2882             Atom HH21 = (Atom) newResidue.getAtomNode("HH21");
2883             double[] hh21 = coordsArray[HH21.getIndex() - 1];
2884             Atom HH22 = (Atom) newResidue.getAtomNode("HH22");
2885             double[] hh22 = coordsArray[HH22.getIndex() - 1];
2886             Bond CG_CB = CG.getBond(CB);
2887             Bond CD_CG = CD.getBond(CG);
2888             Bond NE_CD = NE.getBond(CD);
2889             Bond CZ_NE = CZ.getBond(NE);
2890             Bond NH_CZ = NH1.getBond(CZ);
2891             Bond HB_CB = HB2.getBond(CB);
2892             Bond HG_CG = HG2.getBond(CG);
2893             Bond HD_CD = HD2.getBond(CD);
2894             Bond HE_NE = HE.getBond(NE);
2895             Bond HH_NH = HH11.getBond(NH1);
2896             double dCG_CB = CG_CB.bondType.distance;
2897             double dCD_CG = CD_CG.bondType.distance;
2898             double dNE_CD = NE_CD.bondType.distance;
2899             double dCZ_NE = CZ_NE.bondType.distance;
2900             double dNH_CZ = NH_CZ.bondType.distance;
2901             double dHB_CB = HB_CB.bondType.distance;
2902             double dHG_CG = HG_CG.bondType.distance;
2903             double dHD_CD = HD_CD.bondType.distance;
2904             double dHE_NE = HE_NE.bondType.distance;
2905             double dHH_NH = HH_NH.bondType.distance;
2906             Angle CG_CB_CA = CG.getAngle(CB, CA);
2907             Angle CD_CG_CB = CD.getAngle(CG, CB);
2908             Angle NE_CD_CG = NE.getAngle(CD, CG);
2909             Angle CZ_NE_CD = CZ.getAngle(NE, CD);
2910             Angle NH_CZ_NE = NH1.getAngle(CZ, NE);
2911             Angle HB_CB_CA = HB2.getAngle(CB, CA);
2912             Angle HG_CG_CB = HG2.getAngle(CG, CB);
2913             Angle HD_CD_CG = HD2.getAngle(CD, CG);
2914             Angle HE_NE_CD = HE.getAngle(NE, CD);
2915             Angle HH_NH_CZ = HH11.getAngle(NH1, CZ);
2916             double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
2917             double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
2918             double dNE_CD_CG = NE_CD_CG.angleType.angle[NE_CD_CG.nh];
2919             double dCZ_NE_CD = CZ_NE_CD.angleType.angle[CZ_NE_CD.nh];
2920             double dNH_CZ_NE = NH_CZ_NE.angleType.angle[NH_CZ_NE.nh];
2921             double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
2922             double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
2923             double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
2924             double dHE_NE_CD = HE_NE_CD.angleType.angle[HE_NE_CD.nh];
2925             double dHH_NH_CZ = HH_NH_CZ.angleType.angle[HH_NH_CZ.nh];
2926             arraycopy(determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
2927             coordsArray = fillCoordsArray(CB, coordsArray, cb);
2928 
2929             arraycopy(
2930                 determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0),
2931                 0,
2932                 cg,
2933                 0,
2934                 3); // CG
2935             coordsArray = fillCoordsArray(CG, coordsArray, cg);
2936 
2937             arraycopy(determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3); // CD
2938             coordsArray = fillCoordsArray(CD, coordsArray, cd);
2939 
2940             arraycopy(determineIntxyz(cd, dNE_CD, cg, dNE_CD_CG, cb, 180.0, 0), 0, ne, 0, 3); // NE
2941             coordsArray = fillCoordsArray(NE, coordsArray, ne);
2942 
2943             arraycopy(determineIntxyz(ne, dCZ_NE, cd, dCZ_NE_CD, cg, 180.0, 0), 0, cz, 0, 3); // CZ
2944             coordsArray = fillCoordsArray(CZ, coordsArray, cz);
2945 
2946             arraycopy(determineIntxyz(cz, dNH_CZ, ne, dNH_CZ_NE, cd, 180, 0), 0, nh1, 0, 3); // NH1
2947             coordsArray = fillCoordsArray(NH1, coordsArray, nh1);
2948 
2949             arraycopy(
2950                 determineIntxyz(cz, dNH_CZ, ne, dNH_CZ_NE, nh1, 120.0, 1), 0, nh2, 0, 3); // NH2
2951             coordsArray = fillCoordsArray(NH2, coordsArray, nh2);
2952 
2953             arraycopy(
2954                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3); // HB2
2955             coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
2956 
2957             arraycopy(
2958                 determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3); // HB3
2959             coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
2960 
2961             arraycopy(
2962                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3); // HG2
2963             coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
2964 
2965             arraycopy(
2966                 determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3); // HG3
2967             coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
2968 
2969             arraycopy(
2970                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ne, 109.4, 1), 0, hd2, 0, 3); // HD2
2971             coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
2972 
2973             arraycopy(
2974                 determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ne, 109.4, -1), 0, hd3, 0, 3); // HD3
2975             coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
2976 
2977             arraycopy(determineIntxyz(ne, dHE_NE, cd, dHE_NE_CD, cz, 120.0, 1), 0, he, 0, 3); // HE
2978             coordsArray = fillCoordsArray(HE, coordsArray, he);
2979 
2980             arraycopy(
2981                 determineIntxyz(nh1, dHH_NH, cz, dHH_NH_CZ, ne, 180.0, 0), 0, hh11, 0, 3); // HH11
2982             coordsArray = fillCoordsArray(HH11, coordsArray, hh11);
2983 
2984             arraycopy(
2985                 determineIntxyz(nh1, dHH_NH, cz, dHH_NH_CZ, hh11, 120.0, 1), 0, hh12, 0, 3); // HH12
2986             coordsArray = fillCoordsArray(HH12, coordsArray, hh12);
2987 
2988             arraycopy(
2989                 determineIntxyz(nh2, dHH_NH, cz, dHH_NH_CZ, ne, 180.0, 0), 0, hh21, 0, 3); // HH21
2990             coordsArray = fillCoordsArray(HH21, coordsArray, hh21);
2991 
2992             arraycopy(
2993                 determineIntxyz(nh2, dHH_NH, cz, dHH_NH_CZ, hh21, 120.0, 1), 0, hh22, 0, 3); // HH22
2994             coordsArray = fillCoordsArray(HH22, coordsArray, hh22);
2995             break;
2996           }
2997         default:
2998           break;
2999       }
3000     }
3001     double[] coordsArray1D = new double[atomArray.length * 3];
3002     for (int i = 0; i < atomArray.length; i++) {
3003       for (int j = 0; j < 3; j++) {
3004         coordsArray1D[i * 3 + j] = coordsArray[i][j];
3005       }
3006     }
3007     return coordsArray1D;
3008   }
3009 
3010   private void setAltCoordinates(double[] coordinates) {
3011     for (int i = 0; i < coordinates.length / 3; i++) {
3012       for (int j = 0; j < 3; j++) {
3013         this.altCoords[i][j] = coordinates[i * 3 + j];
3014       }
3015     }
3016     useAltCoordinates(true);
3017   }
3018 
3019   private double[][] fillCoordsArray(Atom atom, double[][] coordsArray, double[] determinedXYZ) {
3020     int XYZIndex = atom.getIndex() - 1;
3021     coordsArray[XYZIndex][0] = determinedXYZ[0];
3022     coordsArray[XYZIndex][1] = determinedXYZ[1];
3023     coordsArray[XYZIndex][2] = determinedXYZ[2];
3024     return coordsArray;
3025   }
3026 }