Search in sources :

Example 11 with AminoAcid3

use of ffx.potential.bonded.ResidueEnumerations.AminoAcid3 in project ffx by mjschnie.

the class Loop method getSolutionCoordinates.

private double[] getSolutionCoordinates(int k, double[][][] r_soln_n, double[][][] r_soln_a, double[][][] r_soln_c, int stt_res, int end_res) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            r_n[i][j] = r_soln_n[k][i][j];
            r_a[i][j] = r_soln_a[k][i][j];
            r_c[i][j] = r_soln_c[k][i][j];
        }
    }
    // double sum = 0.0;
    /* For RMSD?
         for (int i = 0; i < 3; i++) {
         for (int j = 0; j < 3; j++) {
         dr[j] = r_soln_n[k][i][j] - r_n[i + 1][j];
         }
         sum += dot(dr, dr);
         for (int j = 0; j < 3; j++) {
         dr[j] = r_soln_a[k][i][j] - r_a[i + 1][j];
         }
         sum += dot(dr, dr);
         for (int j = 0; j < 3; j++) {
         dr[j] = r_soln_c[k][i][j] - r_c[i + 1][j];
         }
         sum += dot(dr, dr);
         }
         */
    Polymer[] newChain = molAss.getChains();
    ArrayList<Atom> backBoneAtoms;
    Atom[] atomArray = molAss.getAtomArray();
    double[][] coordsArray = new double[atomArray.length][3];
    if (useAltCoords) {
        System.arraycopy(this.altCoords, 0, coordsArray, 0, coordsArray.length);
    } else {
        for (int i = 0; i < atomArray.length; i++) {
            Atom a = atomArray[i];
            coordsArray[i][0] = a.getX();
            coordsArray[i][1] = a.getY();
            coordsArray[i][2] = a.getZ();
        }
    }
    // Loop through residues to build backbone C,N,CA
    for (int i = stt_res; i <= end_res; i++) {
        Residue newResidue = newChain[0].getResidue(i);
        Residue backResidue = newChain[0].getResidue(i - 1);
        backBoneAtoms = newResidue.getBackboneAtoms();
        Atom C = null;
        Atom N = null;
        Atom CA = null;
        double[] c = new double[3];
        double[] ca = new double[3];
        double[] n = new double[3];
        double[] bc = new double[3];
        double[] determinedXYZ = new double[3];
        for (Atom backBoneAtom : backBoneAtoms) {
            // backBoneAtom.setBuilt(true);
            int backBoneIndex = backBoneAtom.getIndex() - 1;
            switch(backBoneAtom.getAtomType().name) {
                case "C":
                    C = backBoneAtom;
                    coordsArray[backBoneIndex][0] = r_c[i - stt_res][0];
                    coordsArray[backBoneIndex][1] = r_c[i - stt_res][1];
                    coordsArray[backBoneIndex][2] = r_c[i - stt_res][2];
                    break;
                case "N":
                    N = backBoneAtom;
                    coordsArray[backBoneIndex][0] = r_n[i - stt_res][0];
                    coordsArray[backBoneIndex][1] = r_n[i - stt_res][1];
                    coordsArray[backBoneIndex][2] = r_n[i - stt_res][2];
                    break;
                case "CA":
                    CA = backBoneAtom;
                    coordsArray[backBoneIndex][0] = r_a[i - stt_res][0];
                    coordsArray[backBoneIndex][1] = r_a[i - stt_res][1];
                    coordsArray[backBoneIndex][2] = r_a[i - stt_res][2];
                    break;
                default:
                    break;
            }
        }
    }
    // Loop through again to build Hydrogens and side-chains with current C,N,CA coordinates
    for (int i = stt_res + 1; i < end_res - 1; i++) {
        Residue newResidue = newChain[0].getResidue(i);
        Residue backResidue = newChain[0].getResidue(i - 1);
        Residue forwardResidue = newChain[0].getResidue(i + 1);
        backBoneAtoms = newResidue.getBackboneAtoms();
        double[] c = new double[3];
        double[] ca = new double[3];
        double[] n = new double[3];
        double[] bc = new double[3];
        double[] fn = new double[3];
        double[] determinedXYZ = new double[3];
        // Obtaining coordinates for sidechains
        Atom C = (Atom) newResidue.getAtomNode("C");
        System.arraycopy(coordsArray[C.getIndex() - 1], 0, c, 0, 3);
        Atom CA = (Atom) newResidue.getAtomNode("CA");
        System.arraycopy(coordsArray[CA.getIndex() - 1], 0, ca, 0, 3);
        Atom N = (Atom) newResidue.getAtomNode("N");
        System.arraycopy(coordsArray[N.getIndex() - 1], 0, n, 0, 3);
        Atom BC = (Atom) backResidue.getAtomNode("C");
        System.arraycopy(coordsArray[BC.getIndex() - 1], 0, bc, 0, 3);
        Atom FN = (Atom) forwardResidue.getAtomNode("N");
        System.arraycopy(coordsArray[FN.getIndex() - 1], 0, fn, 0, 3);
        /*
            for (Atom backBoneAtom : backBoneAtoms) {
            //    backBoneAtom.setBuilt(true);
                logger.info(String.format("getAtomType().name "+backBoneAtom.getAtomType().name));
                switch (backBoneAtom.getAtomType().name) {
                        case "H": 
                                            logger.info(String.format("H getAtomType().name "+backBoneAtom.getAtomType().name));
                            determinedXYZ = BondedUtils.determineIntxyz(ca, 1.0, n, 109.5, c, 109.5, -1);
                            coordsArray = fillCoordsArray(backBoneAtom,coordsArray, determinedXYZ); 
                            break;
                        case "HA":
                                            logger.info(String.format("HA getAtomType().name "+backBoneAtom.getAtomType().name));
                            determinedXYZ = BondedUtils.determineIntxyz(n, 1.0, bc, 119.0, ca, 119.0, 1);
                            coordsArray = fillCoordsArray(backBoneAtom,coordsArray, determinedXYZ); 
                            break;
                        case "O":
                                            logger.info(String.format("O getAtomType().name "+backBoneAtom.getAtomType().name));
                            determinedXYZ = BondedUtils.determineIntxyz(c, 1.2255, ca, 122.4, n, 180, 0);
                            coordsArray = fillCoordsArray(backBoneAtom,coordsArray, determinedXYZ); 
                            break;
                        default:
                            break;
                }
            }
                    */
        Atom H = (Atom) newResidue.getAtomNode("H");
        double[] h = coordsArray[H.getIndex() - 1];
        // H
        System.arraycopy(BondedUtils.determineIntxyz(n, 1.0, bc, 119.0, ca, 119.0, 1), 0, h, 0, 3);
        coordsArray = fillCoordsArray(H, coordsArray, h);
        Atom O = (Atom) newResidue.getAtomNode("O");
        double[] o = coordsArray[O.getIndex() - 1];
        // O
        System.arraycopy(BondedUtils.determineIntxyz(c, 1.2255, ca, 122.4, fn, 180, 0), 0, o, 0, 3);
        coordsArray = fillCoordsArray(O, coordsArray, o);
        AminoAcid3 name = AminoAcid3.valueOf(newResidue.getName());
        if (name != AminoAcid3.GLY) {
            Atom HA = (Atom) newResidue.getAtomNode("HA");
            double[] ha = coordsArray[HA.getIndex() - 1];
            // HA
            System.arraycopy(BondedUtils.determineIntxyz(ca, 1.0, n, 109.5, c, 109.5, -1), 0, ha, 0, 3);
            coordsArray = fillCoordsArray(HA, coordsArray, ha);
        }
        double rotScale = rng.nextDouble();
        switch(name) {
            case GLY:
                {
                    Atom HA2 = (Atom) newResidue.getAtomNode("HA2");
                    double[] ha2 = coordsArray[HA2.getIndex() - 1];
                    Atom HA3 = (Atom) newResidue.getAtomNode("HA3");
                    double[] ha3 = coordsArray[HA3.getIndex() - 1];
                    // HA2
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.00, n, 109.5, c, 109.5, 0), 0, ha2, 0, 3);
                    coordsArray = fillCoordsArray(HA2, coordsArray, ha2);
                    // HA3
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.00, n, 109.5, ha2, 109.5, -1), 0, ha3, 0, 3);
                    coordsArray = fillCoordsArray(HA3, coordsArray, ha3);
                    break;
                }
            case ALA:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom HB1 = (Atom) newResidue.getAtomNode("HB1");
                    double[] hb1 = coordsArray[HB1.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    // CB
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // HB1
                    System.arraycopy(BondedUtils.determineIntxyz(cb, 1.11, ca, 109.5, n, 180.0, 0), 0, hb1, 0, 3);
                    coordsArray = fillCoordsArray(HB1, coordsArray, hb1);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, 1.11, ca, 109.5, hb1, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, 1.11, ca, 109.5, hb1, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    break;
                }
            case VAL:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG1 = (Atom) newResidue.getAtomNode("CG1");
                    double[] cg1 = coordsArray[CG1.getIndex() - 1];
                    Atom CG2 = (Atom) newResidue.getAtomNode("CG2");
                    double[] cg2 = coordsArray[CG2.getIndex() - 1];
                    Atom HB = (Atom) newResidue.getAtomNode("HB");
                    double[] hb = coordsArray[HB.getIndex() - 1];
                    Atom HG11 = (Atom) newResidue.getAtomNode("HG11");
                    double[] hg11 = coordsArray[HG11.getIndex() - 1];
                    Atom HG12 = (Atom) newResidue.getAtomNode("HG12");
                    double[] hg12 = coordsArray[HG12.getIndex() - 1];
                    Atom HG13 = (Atom) newResidue.getAtomNode("HG13");
                    double[] hg13 = coordsArray[HG13.getIndex() - 1];
                    Atom HG21 = (Atom) newResidue.getAtomNode("HG21");
                    double[] hg21 = coordsArray[HG21.getIndex() - 1];
                    Atom HG22 = (Atom) newResidue.getAtomNode("HG22");
                    double[] hg22 = coordsArray[HG22.getIndex() - 1];
                    Atom HG23 = (Atom) newResidue.getAtomNode("HG23");
                    double[] hg23 = coordsArray[HG23.getIndex() - 1];
                    Bond CG_CB = CB.getBond(CG1);
                    Bond HB_CB = CB.getBond(HB);
                    Bond HG_CG = HG11.getBond(CG1);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    Angle CG_CB_CA = CG1.getAngle(CB, CA);
                    Angle HB_CB_CA = HB.getAngle(CB, CA);
                    Angle HG_CG_CB = HG11.getAngle(CG1, CB);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG1
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg1, 0, 3);
                    coordsArray = fillCoordsArray(CG1, coordsArray, cg1);
                    // CG2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, cg1, 109.5, -1), 0, cg2, 0, 3);
                    coordsArray = fillCoordsArray(CG2, coordsArray, cg2);
                    // HB
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg1, 109.4, 1), 0, hb, 0, 3);
                    coordsArray = fillCoordsArray(HB, coordsArray, hb);
                    // HG11
                    System.arraycopy(BondedUtils.determineIntxyz(cg1, dHG_CG, cb, dHG_CG_CB, ca, 180.0, 0), 0, hg11, 0, 3);
                    coordsArray = fillCoordsArray(HG11, coordsArray, hg11);
                    // HG12
                    System.arraycopy(BondedUtils.determineIntxyz(cg1, dHG_CG, cb, dHG_CG_CB, hg11, 109.4, 1), 0, hg12, 0, 3);
                    coordsArray = fillCoordsArray(HG12, coordsArray, hg12);
                    // HG13
                    System.arraycopy(BondedUtils.determineIntxyz(cg1, dHG_CG, cb, dHG_CG_CB, hg11, 109.4, -1), 0, hg13, 0, 3);
                    coordsArray = fillCoordsArray(HG13, coordsArray, hg13);
                    // HG21
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG_CG, cb, dHG_CG_CB, ca, 180.0, 0), 0, hg21, 0, 3);
                    coordsArray = fillCoordsArray(HG21, coordsArray, hg21);
                    // HG22
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG_CG, cb, dHG_CG_CB, hg21, 109.4, 1), 0, hg22, 0, 3);
                    coordsArray = fillCoordsArray(HG22, coordsArray, hg22);
                    // HG23
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG_CG, cb, dHG_CG_CB, hg21, 109.4, -1), 0, hg23, 0, 3);
                    coordsArray = fillCoordsArray(HG23, coordsArray, hg23);
                    break;
                }
            case LEU:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
                    double[] cd1 = coordsArray[CD1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG = (Atom) newResidue.getAtomNode("HG");
                    double[] hg = coordsArray[HG.getIndex() - 1];
                    Atom HD11 = (Atom) newResidue.getAtomNode("HD11");
                    double[] hd11 = coordsArray[HD11.getIndex() - 1];
                    Atom HD12 = (Atom) newResidue.getAtomNode("HD12");
                    double[] hd12 = coordsArray[HD12.getIndex() - 1];
                    Atom HD13 = (Atom) newResidue.getAtomNode("HD13");
                    double[] hd13 = coordsArray[HD13.getIndex() - 1];
                    Atom HD21 = (Atom) newResidue.getAtomNode("HD21");
                    double[] hd21 = coordsArray[HD21.getIndex() - 1];
                    Atom HD22 = (Atom) newResidue.getAtomNode("HD22");
                    double[] hd22 = coordsArray[HD22.getIndex() - 1];
                    Atom HD23 = (Atom) newResidue.getAtomNode("HD23");
                    double[] hd23 = coordsArray[HD23.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD1.getBond(CG);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG.getBond(CG);
                    Bond HD_CD = HD11.getBond(CD1);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD1.getAngle(CG, CB);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG.getAngle(CG, CB);
                    Angle HD_CD_CG = HD11.getAngle(CD1, CG);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd1, 0, 3);
                    coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 109.5, -1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd1, 109.4, 1), 0, hg, 0, 3);
                    coordsArray = fillCoordsArray(HG, coordsArray, hg);
                    // HD11
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, cb, 180.0, 0), 0, hd11, 0, 3);
                    coordsArray = fillCoordsArray(HD11, coordsArray, hd11);
                    // HD12
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, hd11, 109.4, 1), 0, hd12, 0, 3);
                    coordsArray = fillCoordsArray(HD12, coordsArray, hd12);
                    // HD13
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, hd11, 109.4, -1), 0, hd13, 0, 3);
                    coordsArray = fillCoordsArray(HD13, coordsArray, hd13);
                    // HD21
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, cb, 180.0, 0), 0, hd21, 0, 3);
                    coordsArray = fillCoordsArray(HD21, coordsArray, hd21);
                    // HD22
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, hd21, 109.4, 1), 0, hd22, 0, 3);
                    coordsArray = fillCoordsArray(HD22, coordsArray, hd22);
                    // HD23
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, hd21, 109.4, -1), 0, hd23, 0, 3);
                    coordsArray = fillCoordsArray(HD23, coordsArray, hd23);
                    break;
                }
            case ILE:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG1 = (Atom) newResidue.getAtomNode("CG1");
                    double[] cg1 = coordsArray[CG1.getIndex() - 1];
                    Atom CG2 = (Atom) newResidue.getAtomNode("CG2");
                    double[] cg2 = coordsArray[CG2.getIndex() - 1];
                    Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
                    double[] cd1 = coordsArray[CD1.getIndex() - 1];
                    Atom HB = (Atom) newResidue.getAtomNode("HB");
                    double[] hb = coordsArray[HB.getIndex() - 1];
                    Atom HG12 = (Atom) newResidue.getAtomNode("HG12");
                    double[] hg12 = coordsArray[HG12.getIndex() - 1];
                    Atom HG13 = (Atom) newResidue.getAtomNode("HG13");
                    double[] hg13 = coordsArray[HG13.getIndex() - 1];
                    Atom HG21 = (Atom) newResidue.getAtomNode("HG21");
                    double[] hg21 = coordsArray[HG21.getIndex() - 1];
                    Atom HG22 = (Atom) newResidue.getAtomNode("HG22");
                    double[] hg22 = coordsArray[HG22.getIndex() - 1];
                    Atom HG23 = (Atom) newResidue.getAtomNode("HG23");
                    double[] hg23 = coordsArray[HG23.getIndex() - 1];
                    Atom HD11 = (Atom) newResidue.getAtomNode("HD11");
                    double[] hd11 = coordsArray[HD11.getIndex() - 1];
                    Atom HD12 = (Atom) newResidue.getAtomNode("HD12");
                    double[] hd12 = coordsArray[HD12.getIndex() - 1];
                    Atom HD13 = (Atom) newResidue.getAtomNode("HD13");
                    double[] hd13 = coordsArray[HD13.getIndex() - 1];
                    Bond CG1_CB = CG1.getBond(CB);
                    Bond CG2_CB = CG2.getBond(CB);
                    Bond CD1_CG1 = CD1.getBond(CG1);
                    Bond HB_CB = HB.getBond(CB);
                    Bond HG1_CG = HG12.getBond(CG1);
                    Bond HG2_CG = HG22.getBond(CG2);
                    Bond HD_CD = HD12.getBond(CD1);
                    double dCG1_CB = CG1_CB.bondType.distance;
                    double dCG2_CB = CG2_CB.bondType.distance;
                    double dCD1_CG1 = CD1_CG1.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG1_CG = HG1_CG.bondType.distance;
                    double dHG2_CG = HG2_CG.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    Angle CG1_CB_CA = CG1.getAngle(CB, CA);
                    Angle CG2_CB_CA = CG2.getAngle(CB, CA);
                    Angle CD1_CG1_CB = CD1.getAngle(CG1, CB);
                    Angle HB_CB_CA = HB.getAngle(CB, CA);
                    Angle HG1_CG_CB = HG12.getAngle(CG1, CB);
                    Angle HG2_CG_CB = HG21.getAngle(CG2, CB);
                    Angle HD_CD1_CG1 = HD11.getAngle(CD1, CG1);
                    double dCG1_CB_CA = CG1_CB_CA.angleType.angle[CG1_CB_CA.nh];
                    double dCG2_CB_CA = CG2_CB_CA.angleType.angle[CG2_CB_CA.nh];
                    double dCD1_CG1_CB = CD1_CG1_CB.angleType.angle[CD1_CG1_CB.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG1_CG_CB = HG1_CG_CB.angleType.angle[HG1_CG_CB.nh];
                    double dHG2_CG_CB = HG2_CG_CB.angleType.angle[HG2_CG_CB.nh];
                    double dHD_CD1_CG1 = HD_CD1_CG1.angleType.angle[HD_CD1_CG1.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG1
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG1_CB, ca, dCG1_CB_CA, n, rotScale * 180.0, 0), 0, cg1, 0, 3);
                    coordsArray = fillCoordsArray(CG1, coordsArray, cg1);
                    // CG2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG2_CB, ca, dCG2_CB_CA, cg1, 109.5, 1), 0, cg2, 0, 3);
                    coordsArray = fillCoordsArray(CG2, coordsArray, cg2);
                    // CD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg1, dCD1_CG1, cb, dCD1_CG1_CB, ca, 180, 0), 0, cd1, 0, 3);
                    coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
                    // HB
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg2, 109.4, 1), 0, hb, 0, 3);
                    coordsArray = fillCoordsArray(HB, coordsArray, hb);
                    // HG12
                    System.arraycopy(BondedUtils.determineIntxyz(cg1, dHG1_CG, cb, dHG1_CG_CB, cd1, 109.4, 1), 0, hg12, 0, 3);
                    coordsArray = fillCoordsArray(HG12, coordsArray, hg12);
                    // HG13
                    System.arraycopy(BondedUtils.determineIntxyz(cg1, dHG1_CG, cb, dHG1_CG_CB, cd1, 109.4, -1), 0, hg13, 0, 3);
                    coordsArray = fillCoordsArray(HG13, coordsArray, hg13);
                    // HG21
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG2_CG, cb, dHG2_CG_CB, cg1, 180.0, 0), 0, hg21, 0, 3);
                    coordsArray = fillCoordsArray(HG21, coordsArray, hg21);
                    // HG22
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG2_CG, cb, dHG2_CG_CB, hg21, 109.0, 1), 0, hg22, 0, 3);
                    coordsArray = fillCoordsArray(HG22, coordsArray, hg22);
                    // HG23
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG2_CG, cb, dHG2_CG_CB, hg21, 109.0, -1), 0, hg23, 0, 3);
                    coordsArray = fillCoordsArray(HG23, coordsArray, hg23);
                    // HD11
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg1, dHD_CD1_CG1, cb, 180.0, 0), 0, hd11, 0, 3);
                    coordsArray = fillCoordsArray(HD11, coordsArray, hd11);
                    // HD12
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg1, dHD_CD1_CG1, hd11, 109.0, 1), 0, hd12, 0, 3);
                    coordsArray = fillCoordsArray(HD12, coordsArray, hd12);
                    // HD13
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg1, dHD_CD1_CG1, hd11, 109.0, -1), 0, hd13, 0, 3);
                    coordsArray = fillCoordsArray(HD13, coordsArray, hd13);
                    break;
                }
            case SER:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom OG = (Atom) newResidue.getAtomNode("OG");
                    double[] og = coordsArray[OG.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG = (Atom) newResidue.getAtomNode("HG");
                    double[] hg = coordsArray[HG.getIndex() - 1];
                    Bond OG_CB = OG.getBond(CB);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_OG = HG.getBond(OG);
                    double dOG_CB = OG_CB.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_OG = HG_OG.bondType.distance;
                    Angle OG_CB_CA = OG.getAngle(CB, CA);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_OG_CB = HG.getAngle(OG, CB);
                    double dOG_CB_CA = OG_CB_CA.angleType.angle[OG_CB_CA.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_OG_CB = HG_OG_CB.angleType.angle[HG_OG_CB.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // OG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dOG_CB, ca, dOG_CB_CA, n, rotScale * 180.0, 0), 0, og, 0, 3);
                    coordsArray = fillCoordsArray(OG, coordsArray, og);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, og, 106.7, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, og, 106.7, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG
                    System.arraycopy(BondedUtils.determineIntxyz(og, dHG_OG, cb, dHG_OG_CB, ca, 180.0, 0), 0, hg, 0, 3);
                    coordsArray = fillCoordsArray(HG, coordsArray, hg);
                    break;
                }
            case THR:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom OG1 = (Atom) newResidue.getAtomNode("OG1");
                    double[] og1 = coordsArray[OG1.getIndex() - 1];
                    Atom CG2 = (Atom) newResidue.getAtomNode("CG2");
                    double[] cg2 = coordsArray[CG2.getIndex() - 1];
                    Atom HB = (Atom) newResidue.getAtomNode("HB");
                    double[] hb = coordsArray[HB.getIndex() - 1];
                    Atom HG1 = (Atom) newResidue.getAtomNode("HG1");
                    double[] hg1 = coordsArray[HG1.getIndex() - 1];
                    Atom HG21 = (Atom) newResidue.getAtomNode("HG21");
                    double[] hg21 = coordsArray[HG21.getIndex() - 1];
                    Atom HG22 = (Atom) newResidue.getAtomNode("HG22");
                    double[] hg22 = coordsArray[HG22.getIndex() - 1];
                    Atom HG23 = (Atom) newResidue.getAtomNode("HG23");
                    double[] hg23 = coordsArray[HG23.getIndex() - 1];
                    Bond OG1_CB = OG1.getBond(CB);
                    Bond CG2_CB = CG2.getBond(CB);
                    Bond HB_CB = HB.getBond(CB);
                    Bond HG1_OG1 = HG1.getBond(OG1);
                    Bond HG2_CG2 = HG21.getBond(CG2);
                    double dOG1_CB = OG1_CB.bondType.distance;
                    double dCG2_CB = CG2_CB.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG1_OG1 = HG1_OG1.bondType.distance;
                    double dHG2_CG2 = HG2_CG2.bondType.distance;
                    Angle OG1_CB_CA = OG1.getAngle(CB, CA);
                    Angle CG2_CB_CA = CG2.getAngle(CB, CA);
                    Angle HB_CB_CA = HB.getAngle(CB, CA);
                    Angle HG1_OG1_CB = HG1.getAngle(OG1, CB);
                    Angle HG2_CG2_CB = HG21.getAngle(CG2, CB);
                    double dOG1_CB_CA = OG1_CB_CA.angleType.angle[OG1_CB_CA.nh];
                    double dCG2_CB_CA = CG2_CB_CA.angleType.angle[CG2_CB_CA.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG1_OG1_CB = HG1_OG1_CB.angleType.angle[HG1_OG1_CB.nh];
                    double dHG2_CG2_CB = HG2_CG2_CB.angleType.angle[HG2_CG2_CB.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // OG1
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dOG1_CB, ca, dOG1_CB_CA, n, rotScale * 180.0, 0), 0, og1, 0, 3);
                    coordsArray = fillCoordsArray(OG1, coordsArray, og1);
                    // CG2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG2_CB, ca, dCG2_CB_CA, og1, 107.7, 1), 0, cg2, 0, 3);
                    coordsArray = fillCoordsArray(CG2, coordsArray, cg2);
                    // HB
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, og1, 106.7, -1), 0, hb, 0, 3);
                    coordsArray = fillCoordsArray(HB, coordsArray, hb);
                    // HG1
                    System.arraycopy(BondedUtils.determineIntxyz(og1, dHG1_OG1, cb, dHG1_OG1_CB, ca, 180.0, 0), 0, hg1, 0, 3);
                    coordsArray = fillCoordsArray(HG1, coordsArray, hg1);
                    // HG21
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG2_CG2, cb, dHG2_CG2_CB, ca, 180.0, 0), 0, hg21, 0, 3);
                    coordsArray = fillCoordsArray(HG21, coordsArray, hg21);
                    // HG22
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG2_CG2, cb, dHG2_CG2_CB, hg21, 109.0, 1), 0, hg22, 0, 3);
                    coordsArray = fillCoordsArray(HG22, coordsArray, hg22);
                    // HG23
                    System.arraycopy(BondedUtils.determineIntxyz(cg2, dHG2_CG2, cb, dHG2_CG2_CB, hg21, 109.0, -1), 0, hg23, 0, 3);
                    coordsArray = fillCoordsArray(HG23, coordsArray, hg23);
                    break;
                }
            case CYS:
            case CYX:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom SG = (Atom) newResidue.getAtomNode("SG");
                    double[] sg = coordsArray[SG.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG = (Atom) newResidue.getAtomNode("HG");
                    double[] hg = coordsArray[HG.getIndex() - 1];
                    Bond SG_CB = SG.getBond(CB);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_SG = HG.getBond(SG);
                    double dSG_CB = SG_CB.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_SG = HG_SG.bondType.distance;
                    Angle SG_CB_CA = SG.getAngle(CB, CA);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_SG_CB = HG.getAngle(SG, CB);
                    double dSG_CB_CA = SG_CB_CA.angleType.angle[SG_CB_CA.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_SG_CB = HG_SG_CB.angleType.angle[HG_SG_CB.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // SG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dSG_CB, ca, dSG_CB_CA, n, rotScale * 180.0, 0), 0, sg, 0, 3);
                    coordsArray = fillCoordsArray(SG, coordsArray, sg);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG
                    System.arraycopy(BondedUtils.determineIntxyz(sg, dHG_SG, cb, dHG_SG_CB, ca, 180.0, 0), 0, hg, 0, 3);
                    coordsArray = fillCoordsArray(HG, coordsArray, hg);
                    break;
                }
            case CYD:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom SG = (Atom) newResidue.getAtomNode("SG");
                    double[] sg = coordsArray[SG.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Bond SG_CB = SG.getBond(CB);
                    Bond HB_CB = HB2.getBond(CB);
                    double dSG_CB = SG_CB.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    Angle SG_CB_CA = SG.getAngle(CB, CA);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    double dSG_CB_CA = SG_CB_CA.angleType.angle[SG_CB_CA.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // SG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dSG_CB, ca, dSG_CB_CA, n, rotScale * 180.0, 0), 0, sg, 0, 3);
                    coordsArray = fillCoordsArray(SG, coordsArray, sg);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, sg, 112.0, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    break;
                }
            case PHE:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
                    double[] cd1 = coordsArray[CD1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
                    double[] ce1 = coordsArray[CE1.getIndex() - 1];
                    Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
                    double[] ce2 = coordsArray[CE2.getIndex() - 1];
                    Atom CZ = (Atom) newResidue.getAtomNode("CZ");
                    double[] cz = coordsArray[CZ.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
                    double[] hd1 = coordsArray[HD1.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Atom HZ = (Atom) newResidue.getAtomNode("HZ");
                    double[] hz = coordsArray[HZ.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD1.getBond(CG);
                    Bond CE_CD = CE1.getBond(CD1);
                    Bond CZ_CE1 = CZ.getBond(CE1);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD_CD = HD1.getBond(CD1);
                    Bond HE_CE = HE1.getBond(CE1);
                    Bond HZ_CZ = HZ.getBond(CZ);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dCE_CD = CE_CD.bondType.distance;
                    double dCZ_CE1 = CZ_CE1.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    double dHE_CE = HE_CE.bondType.distance;
                    double dHZ_CZ = HZ_CZ.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD1.getAngle(CG, CB);
                    Angle CE_CD_CG = CE1.getAngle(CD1, CG);
                    Angle CZ_CE1_CD1 = CZ.getAngle(CE1, CD1);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD_CD1_CG = HD1.getAngle(CD1, CG);
                    Angle HE_CE_CD = HE1.getAngle(CE1, CD1);
                    Angle HZ_CZ_CE1 = HZ.getAngle(CZ, CE1);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
                    double dCZ_CE1_CD1 = CZ_CE1_CD1.angleType.angle[CZ_CE1_CD1.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD_CD1_CG = HD_CD1_CG.angleType.angle[HD_CD1_CG.nh];
                    double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
                    double dHZ_CZ_CE1 = HZ_CZ_CE1.angleType.angle[HZ_CZ_CE1.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd1, 0, 3);
                    coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 120.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // CE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce1, 0, 3);
                    coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
                    // CE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce2, 0, 3);
                    coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
                    // CZ
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dCZ_CE1, cd1, dCZ_CE1_CD1, cg, 0.0, 0), 0, cz, 0, 3);
                    coordsArray = fillCoordsArray(CZ, coordsArray, cz);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg, dHD_CD1_CG, ce1, 120.0, 1), 0, hd1, 0, 3);
                    coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD_CD, cg, dHD_CD1_CG, ce2, 120.0, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dHE_CE, cd1, dHE_CE_CD, cz, 120.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ce2, dHE_CE, cd2, dHE_CE_CD, cz, 120.0, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    // HZ
                    System.arraycopy(BondedUtils.determineIntxyz(cz, dHZ_CZ, ce1, dHZ_CZ_CE1, ce2, 120.0, 1), 0, hz, 0, 3);
                    coordsArray = fillCoordsArray(HZ, coordsArray, hz);
                    break;
                }
            case PRO:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
                    double[] hd3 = coordsArray[HD3.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HD_CD = HD2.getBond(CD);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HD_CD_CG = HD2.getAngle(CD, CG);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 30.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, n, 109.4, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HD3
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, n, 109.4, -1), 0, hd3, 0, 3);
                    coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
                    break;
                }
            case TYR:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
                    double[] cd1 = coordsArray[CD1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
                    double[] ce1 = coordsArray[CE1.getIndex() - 1];
                    Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
                    double[] ce2 = coordsArray[CE2.getIndex() - 1];
                    Atom CZ = (Atom) newResidue.getAtomNode("CZ");
                    double[] cz = coordsArray[CZ.getIndex() - 1];
                    Atom OH = (Atom) newResidue.getAtomNode("OH");
                    double[] oh = coordsArray[OH.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
                    double[] hd1 = coordsArray[HD1.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Atom HH = (Atom) newResidue.getAtomNode("HH");
                    double[] hh = coordsArray[HH.getIndex() - 1];
                    Bond CB_CA = CB.getBond(CA);
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD1.getBond(CG);
                    Bond CE_CD = CE1.getBond(CD1);
                    Bond CZ_CE1 = CZ.getBond(CE1);
                    Bond OH_CZ = OH.getBond(CZ);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD_CD = HD1.getBond(CD1);
                    Bond HE_CE = HE1.getBond(CE1);
                    Bond HH_OH = HH.getBond(OH);
                    double dCB_CA = CB_CA.bondType.distance;
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dCE_CD = CE_CD.bondType.distance;
                    double dCZ_CE1 = CZ_CE1.bondType.distance;
                    double dOH_CZ = OH_CZ.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    double dHE_CE = HE_CE.bondType.distance;
                    double dHH_OH = HH_OH.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD1.getAngle(CG, CB);
                    Angle CE_CD_CG = CE1.getAngle(CD1, CG);
                    Angle CZ_CE1_CD1 = CZ.getAngle(CE1, CD1);
                    Angle OH_CZ_CE2 = OH.getAngle(CZ, CE2);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD_CD_CG = HD1.getAngle(CD1, CG);
                    Angle HE_CE_CD = HE1.getAngle(CE1, CD1);
                    Angle HH_OH_CZ = HH.getAngle(OH, CZ);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
                    double dCZ_CE1_CD1 = CZ_CE1_CD1.angleType.angle[CZ_CE1_CD1.nh];
                    double dOH_CZ_CE2 = OH_CZ_CE2.angleType.angle[OH_CZ_CE2.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
                    double dHH_OH_CZ = HH_OH_CZ.angleType.angle[HH_OH_CZ.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, dCB_CA, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 90.0, 0), 0, cd1, 0, 3);
                    coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 120.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // CE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce1, 0, 3);
                    coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
                    // CE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce2, 0, 3);
                    coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
                    // CZ
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dCZ_CE1, cd1, dCZ_CE1_CD1, cg, 0.0, 0), 0, cz, 0, 3);
                    coordsArray = fillCoordsArray(CZ, coordsArray, cz);
                    // OH
                    System.arraycopy(BondedUtils.determineIntxyz(cz, dOH_CZ, ce2, dOH_CZ_CE2, ce1, 120.0, 1), 0, oh, 0, 3);
                    coordsArray = fillCoordsArray(OH, coordsArray, oh);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, ce1, 120.0, 1), 0, hd1, 0, 3);
                    coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, ce2, 120.0, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dHE_CE, cd1, dHE_CE_CD, cz, 120.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ce2, dHE_CE, cd2, dHE_CE_CD, cz, 120.0, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    // HH
                    System.arraycopy(BondedUtils.determineIntxyz(oh, dHH_OH, cz, dHH_OH_CZ, ce2, 0.0, 0), 0, hh, 0, 3);
                    coordsArray = fillCoordsArray(HH, coordsArray, hh);
                    break;
                }
            case TYD:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
                    double[] cd1 = coordsArray[CD1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
                    double[] ce1 = coordsArray[CE1.getIndex() - 1];
                    Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
                    double[] ce2 = coordsArray[CE2.getIndex() - 1];
                    Atom CZ = (Atom) newResidue.getAtomNode("CZ");
                    double[] cz = coordsArray[CZ.getIndex() - 1];
                    Atom OH = (Atom) newResidue.getAtomNode("OH");
                    double[] oh = coordsArray[OH.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
                    double[] hd1 = coordsArray[HD1.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD1.getBond(CG);
                    Bond CE_CD = CE1.getBond(CD1);
                    Bond CZ_CE1 = CZ.getBond(CE1);
                    Bond OH_CZ = OH.getBond(CZ);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD_CD = HD1.getBond(CD1);
                    Bond HE_CE = HE1.getBond(CE1);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dCE_CD = CE_CD.bondType.distance;
                    double dCZ_CE1 = CZ_CE1.bondType.distance;
                    double dOH_CZ = OH_CZ.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    double dHE_CE = HE_CE.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD1.getAngle(CG, CB);
                    Angle CE_CD_CG = CE1.getAngle(CD1, CG);
                    Angle CZ_CE1_CD1 = CZ.getAngle(CE1, CD1);
                    Angle OH_CZ_CE2 = OH.getAngle(CZ, CE2);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD_CD_CG = HD1.getAngle(CD1, CG);
                    Angle HE_CE_CD = HE1.getAngle(CE1, CD1);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
                    double dCZ_CE1_CD1 = CZ_CE1_CD1.angleType.angle[CZ_CE1_CD1.nh];
                    double dOH_CZ_CE2 = OH_CZ_CE2.angleType.angle[OH_CZ_CE2.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 90.0, 0), 0, cd1, 0, 3);
                    coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, cd1, 120.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // CE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce1, 0, 3);
                    coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
                    // CE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dCE_CD, cg, dCE_CD_CG, cb, 180, 0), 0, ce2, 0, 3);
                    coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
                    // CZ
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dCZ_CE1, cd1, dCZ_CE1_CD1, cg, 0.0, 0), 0, cz, 0, 3);
                    coordsArray = fillCoordsArray(CZ, coordsArray, cz);
                    // OH
                    System.arraycopy(BondedUtils.determineIntxyz(cz, dOH_CZ, ce2, dOH_CZ_CE2, ce1, 120.0, 1), 0, oh, 0, 3);
                    coordsArray = fillCoordsArray(OH, coordsArray, oh);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD_CD, cg, dHD_CD_CG, ce1, 120.0, 1), 0, hd1, 0, 3);
                    coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD_CD, cg, dHD_CD_CG, ce2, 120.0, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dHE_CE, cd1, dHE_CE_CD, cz, 120.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ce2, dHE_CE, cd2, dHE_CE_CD, cz, 120.0, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    break;
                }
            case TRP:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD1 = (Atom) newResidue.getAtomNode("CD1");
                    double[] cd1 = coordsArray[CD1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom NE1 = (Atom) newResidue.getAtomNode("NE1");
                    double[] ne1 = coordsArray[NE1.getIndex() - 1];
                    Atom CE2 = (Atom) newResidue.getAtomNode("CE2");
                    double[] ce2 = coordsArray[CE2.getIndex() - 1];
                    Atom CE3 = (Atom) newResidue.getAtomNode("CE3");
                    double[] ce3 = coordsArray[CE3.getIndex() - 1];
                    Atom CZ2 = (Atom) newResidue.getAtomNode("CZ2");
                    double[] cz2 = coordsArray[CZ2.getIndex() - 1];
                    Atom CZ3 = (Atom) newResidue.getAtomNode("CZ3");
                    double[] cz3 = coordsArray[CZ3.getIndex() - 1];
                    Atom CH2 = (Atom) newResidue.getAtomNode("CH2");
                    double[] ch2 = coordsArray[CH2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
                    double[] hd1 = coordsArray[HD1.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
                    double[] he3 = coordsArray[HE3.getIndex() - 1];
                    Atom HZ2 = (Atom) newResidue.getAtomNode("HZ2");
                    double[] hz2 = coordsArray[HZ2.getIndex() - 1];
                    Atom HZ3 = (Atom) newResidue.getAtomNode("HZ3");
                    double[] hz3 = coordsArray[HZ3.getIndex() - 1];
                    Atom HH2 = (Atom) newResidue.getAtomNode("HH2");
                    double[] hh2 = coordsArray[HH2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD1_CG = CD1.getBond(CG);
                    Bond CD2_CG = CD2.getBond(CG);
                    Bond NE1_CD1 = NE1.getBond(CD1);
                    Bond CE2_NE1 = CE2.getBond(NE1);
                    Bond CE3_CD2 = CE3.getBond(CD2);
                    Bond CZ2_CE2 = CZ2.getBond(CE2);
                    Bond CZ3_CE3 = CZ3.getBond(CE3);
                    Bond CH2_CZ2 = CH2.getBond(CZ2);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD1_CD1 = HD1.getBond(CD1);
                    Bond HE1_NE1 = HE1.getBond(NE1);
                    Bond HE3_CE3 = HE3.getBond(CE3);
                    Bond HZ2_CZ2 = HZ2.getBond(CZ2);
                    Bond HZ3_CZ3 = HZ3.getBond(CZ3);
                    Bond HH2_CH2 = HH2.getBond(CH2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD1_CG = CD1_CG.bondType.distance;
                    double dCD2_CG = CD2_CG.bondType.distance;
                    double dNE1_CD1 = NE1_CD1.bondType.distance;
                    double dCE2_NE1 = CE2_NE1.bondType.distance;
                    double dCE3_CD2 = CE3_CD2.bondType.distance;
                    double dCZ2_CE2 = CZ2_CE2.bondType.distance;
                    double dCZ3_CE3 = CZ3_CE3.bondType.distance;
                    double dCH2_CZ2 = CH2_CZ2.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD1_CD1 = HD1_CD1.bondType.distance;
                    double dHE1_NE1 = HE1_NE1.bondType.distance;
                    double dHE3_CE3 = HE3_CE3.bondType.distance;
                    double dHZ2_CZ2 = HZ2_CZ2.bondType.distance;
                    double dHZ3_CZ3 = HZ3_CZ3.bondType.distance;
                    double dHH2_CH2 = HH2_CH2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD1_CG_CB = CD1.getAngle(CG, CB);
                    Angle CD2_CG_CB = CD2.getAngle(CG, CB);
                    Angle NE1_CD1_CG = NE1.getAngle(CD1, CG);
                    Angle CE2_NE1_CD1 = CE2.getAngle(NE1, CD1);
                    Angle CE3_CD2_CE2 = CE3.getAngle(CD2, CE2);
                    Angle CZ2_CE2_CD2 = CZ2.getAngle(CE2, CD2);
                    Angle CZ3_CE3_CD2 = CZ3.getAngle(CE3, CD2);
                    Angle CH2_CZ2_CE2 = CH2.getAngle(CZ2, CE2);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD1_CD1_CG = HD1.getAngle(CD1, CG);
                    Angle HE1_NE1_CD1 = HE1.getAngle(NE1, CD1);
                    Angle HE3_CE3_CD2 = HE3.getAngle(CE3, CD2);
                    Angle HZ2_CZ2_CE2 = HZ2.getAngle(CZ2, CE2);
                    Angle HZ3_CZ3_CE3 = HZ3.getAngle(CZ3, CH2);
                    Angle HH2_CH2_CZ2 = HH2.getAngle(CH2, CZ3);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD1_CG_CB = CD1_CG_CB.angleType.angle[CD1_CG_CB.nh];
                    double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
                    double dNE1_CD1_CG = NE1_CD1_CG.angleType.angle[NE1_CD1_CG.nh];
                    double dCE2_NE1_CD1 = CE2_NE1_CD1.angleType.angle[CE2_NE1_CD1.nh];
                    double dCE3_CD2_CE2 = CE3_CD2_CE2.angleType.angle[CE3_CD2_CE2.nh];
                    double dCZ2_CE2_CD2 = CZ2_CE2_CD2.angleType.angle[CZ2_CE2_CD2.nh];
                    double dCZ3_CE3_CD2 = CZ3_CE3_CD2.angleType.angle[CZ3_CE3_CD2.nh];
                    double dCH2_CZ2_CE2 = CH2_CZ2_CE2.angleType.angle[CH2_CZ2_CE2.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD1_CD1_CG = HD1_CD1_CG.angleType.angle[HD1_CD1_CG.nh];
                    double dHE1_NE1_CD1 = HE1_NE1_CD1.angleType.angle[HE1_NE1_CD1.nh];
                    double dHE3_CE3_CD2 = HE3_CE3_CD2.angleType.angle[HE3_CE3_CD2.nh];
                    double dHZ2_CZ2_CE2 = HZ2_CZ2_CE2.angleType.angle[HZ2_CZ2_CE2.nh];
                    double dHZ3_CZ3_CE3 = HZ3_CZ3_CE3.angleType.angle[HZ3_CZ3_CE3.nh];
                    double dHH2_CH2_CZ2 = HH2_CH2_CZ2.angleType.angle[HH2_CH2_CZ2.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD1_CG, cb, dCD1_CG_CB, ca, -90.0, 0), 0, cd1, 0, 3);
                    coordsArray = fillCoordsArray(CD1, coordsArray, cd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, cd1, 108.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // NE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dNE1_CD1, cg, dNE1_CD1_CG, cd2, 0.0, 0), 0, ne1, 0, 3);
                    coordsArray = fillCoordsArray(NE1, coordsArray, ne1);
                    // CE2
                    System.arraycopy(BondedUtils.determineIntxyz(ne1, dCE2_NE1, cd1, dCE2_NE1_CD1, cg, 0.0, 0), 0, ce2, 0, 3);
                    coordsArray = fillCoordsArray(CE2, coordsArray, ce2);
                    // CE3
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dCE3_CD2, ce2, dCE3_CD2_CE2, ne1, 180.0, 0), 0, ce3, 0, 3);
                    coordsArray = fillCoordsArray(CE3, coordsArray, ce3);
                    // CZ2
                    System.arraycopy(BondedUtils.determineIntxyz(ce2, dCZ2_CE2, cd2, dCZ2_CE2_CD2, ce3, 0.0, 0), 0, cz2, 0, 3);
                    coordsArray = fillCoordsArray(CZ2, coordsArray, cz2);
                    // CZ3
                    System.arraycopy(BondedUtils.determineIntxyz(ce3, dCZ3_CE3, cd2, dCZ3_CE3_CD2, ce2, 0.0, 0), 0, cz3, 0, 3);
                    coordsArray = fillCoordsArray(CZ3, coordsArray, cz3);
                    // CH2
                    System.arraycopy(BondedUtils.determineIntxyz(cz2, dCH2_CZ2, ce2, dCH2_CZ2_CE2, cd2, 0.0, 0), 0, ch2, 0, 3);
                    coordsArray = fillCoordsArray(CH2, coordsArray, ch2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD1
                    System.arraycopy(BondedUtils.determineIntxyz(cd1, dHD1_CD1, cg, dHD1_CD1_CG, ne1, 126.0, 1), 0, hd1, 0, 3);
                    coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ne1, dHE1_NE1, cd1, dHE1_NE1_CD1, ce2, 126.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE3
                    System.arraycopy(BondedUtils.determineIntxyz(ce3, dHE3_CE3, cd2, dHE3_CE3_CD2, cz3, 120.0, 1), 0, he3, 0, 3);
                    coordsArray = fillCoordsArray(HE3, coordsArray, he3);
                    // HZ2
                    System.arraycopy(BondedUtils.determineIntxyz(cz2, dHZ2_CZ2, ce2, dHZ2_CZ2_CE2, ch2, 120.0, 1), 0, hz2, 0, 3);
                    coordsArray = fillCoordsArray(HZ2, coordsArray, hz2);
                    // HZ3
                    System.arraycopy(BondedUtils.determineIntxyz(cz3, dHZ3_CZ3, ce3, dHZ3_CZ3_CE3, ch2, 120.0, 1), 0, hz3, 0, 3);
                    coordsArray = fillCoordsArray(HZ3, coordsArray, hz3);
                    // HH2
                    System.arraycopy(BondedUtils.determineIntxyz(ch2, dHH2_CH2, cz2, dHH2_CH2_CZ2, cz3, 120.0, 1), 0, hh2, 0, 3);
                    coordsArray = fillCoordsArray(HH2, coordsArray, hh2);
                    break;
                }
            case HIS:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom ND1 = (Atom) newResidue.getAtomNode("ND1");
                    double[] nd1 = coordsArray[ND1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
                    double[] ce1 = coordsArray[CE1.getIndex() - 1];
                    Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
                    double[] ne2 = coordsArray[NE2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
                    double[] hd1 = coordsArray[HD1.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond ND1_CG = ND1.getBond(CG);
                    Bond CD2_CG = CD2.getBond(CG);
                    Bond CE1_ND1 = CE1.getBond(ND1);
                    Bond NE2_CD2 = NE2.getBond(CD2);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD1_ND1 = HD1.getBond(ND1);
                    Bond HD2_CD2 = HD2.getBond(CD2);
                    Bond HE1_CE1 = HE1.getBond(CE1);
                    Bond HE2_NE2 = HE2.getBond(NE2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dND1_CG = ND1_CG.bondType.distance;
                    double dCD2_CG = CD2_CG.bondType.distance;
                    double dCE1_ND1 = CE1_ND1.bondType.distance;
                    double dNE2_CD2 = NE2_CD2.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD1_ND1 = HD1_ND1.bondType.distance;
                    double dHD2_CD2 = HD2_CD2.bondType.distance;
                    double dHE1_CE1 = HE1_CE1.bondType.distance;
                    double dHE2_NE2 = HE2_NE2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle ND1_CG_CB = ND1.getAngle(CG, CB);
                    Angle CD2_CG_CB = CD2.getAngle(CG, CB);
                    Angle CE1_ND1_CG = CE1.getAngle(ND1, CG);
                    Angle NE2_CD2_CG = NE2.getAngle(CD2, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD1_ND1_CG = HD1.getAngle(ND1, CG);
                    Angle HD2_CD2_CG = HD2.getAngle(CD2, CG);
                    Angle HE1_CE1_ND1 = HE1.getAngle(CE1, ND1);
                    Angle HE2_NE2_CD2 = HE2.getAngle(NE2, CD2);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dND1_CG_CB = ND1_CG_CB.angleType.angle[ND1_CG_CB.nh];
                    double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
                    double dCE1_ND1_CG = CE1_ND1_CG.angleType.angle[CE1_ND1_CG.nh];
                    double dNE2_CD2_CG = NE2_CD2_CG.angleType.angle[NE2_CD2_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD1_ND1_CG = HD1_ND1_CG.angleType.angle[HD1_ND1_CG.nh];
                    double dHD2_CD2_CG = HD2_CD2_CG.angleType.angle[HD2_CD2_CG.nh];
                    double dHE1_CE1_ND1 = HE1_CE1_ND1.angleType.angle[HE1_CE1_ND1.nh];
                    double dHE2_NE2_CD2 = HE2_NE2_CD2.angleType.angle[HE2_NE2_CD2.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // ND1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dND1_CG, cb, dND1_CG_CB, ca, 180.0, 0), 0, nd1, 0, 3);
                    coordsArray = fillCoordsArray(ND1, coordsArray, nd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, nd1, 108.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // CE1
                    System.arraycopy(BondedUtils.determineIntxyz(nd1, dCE1_ND1, cg, dCE1_ND1_CG, cd2, 0.0, 0), 0, ce1, 0, 3);
                    coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
                    // NE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dNE2_CD2, cg, dNE2_CD2_CG, nd1, 0.0, 0), 0, ne2, 0, 3);
                    coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD1
                    System.arraycopy(BondedUtils.determineIntxyz(nd1, dHD1_ND1, cg, dHD1_ND1_CG, cb, 0.0, 0), 0, hd1, 0, 3);
                    coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD2_CD2, cg, dHD2_CD2_CG, ne2, 126.0, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dHE1_CE1, nd1, dHE1_CE1_ND1, ne2, 126.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ne2, dHE2_NE2, cd2, dHE2_NE2_CD2, ce1, 126.0, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    break;
                }
            case HID:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom ND1 = (Atom) newResidue.getAtomNode("ND1");
                    double[] nd1 = coordsArray[ND1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
                    double[] ce1 = coordsArray[CE1.getIndex() - 1];
                    Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
                    double[] ne2 = coordsArray[NE2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD1 = (Atom) newResidue.getAtomNode("HD1");
                    double[] hd1 = coordsArray[HD1.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond ND1_CG = ND1.getBond(CG);
                    Bond CD2_CG = CD2.getBond(CG);
                    Bond CE1_ND1 = CE1.getBond(ND1);
                    Bond NE2_CD2 = NE2.getBond(CD2);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD1_ND1 = HD1.getBond(ND1);
                    Bond HD2_CD2 = HD2.getBond(CD2);
                    Bond HE1_CE1 = HE1.getBond(CE1);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dND1_CG = ND1_CG.bondType.distance;
                    double dCD2_CG = CD2_CG.bondType.distance;
                    double dCE1_ND1 = CE1_ND1.bondType.distance;
                    double dNE2_CD2 = NE2_CD2.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD1_ND1 = HD1_ND1.bondType.distance;
                    double dHD2_CD2 = HD2_CD2.bondType.distance;
                    double dHE1_CE1 = HE1_CE1.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle ND1_CG_CB = ND1.getAngle(CG, CB);
                    Angle CD2_CG_CB = CD2.getAngle(CG, CB);
                    Angle CE1_ND1_CG = CE1.getAngle(ND1, CG);
                    Angle NE2_CD2_CG = NE2.getAngle(CD2, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD1_ND1_CG = HD1.getAngle(ND1, CG);
                    Angle HD2_CD2_CG = HD2.getAngle(CD2, CG);
                    Angle HE1_CE1_ND1 = HE1.getAngle(CE1, ND1);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dND1_CG_CB = ND1_CG_CB.angleType.angle[ND1_CG_CB.nh];
                    double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
                    double dCE1_ND1_CG = CE1_ND1_CG.angleType.angle[CE1_ND1_CG.nh];
                    double dNE2_CD2_CG = NE2_CD2_CG.angleType.angle[NE2_CD2_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD1_ND1_CG = HD1_ND1_CG.angleType.angle[HD1_ND1_CG.nh];
                    double dHD2_CD2_CG = HD2_CD2_CG.angleType.angle[HD2_CD2_CG.nh];
                    double dHE1_CE1_ND1 = HE1_CE1_ND1.angleType.angle[HE1_CE1_ND1.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // ND1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dND1_CG, cb, dND1_CG_CB, ca, 180.0, 0), 0, nd1, 0, 3);
                    coordsArray = fillCoordsArray(ND1, coordsArray, nd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, nd1, 108.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // CE1
                    System.arraycopy(BondedUtils.determineIntxyz(nd1, dCE1_ND1, cg, dCE1_ND1_CG, cd2, 0.0, 0), 0, ce1, 0, 3);
                    coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
                    // NE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dNE2_CD2, cg, dNE2_CD2_CG, nd1, 0.0, 0), 0, ne2, 0, 3);
                    coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD1
                    System.arraycopy(BondedUtils.determineIntxyz(nd1, dHD1_ND1, cg, dHD1_ND1_CG, cb, 0.0, 0), 0, hd1, 0, 3);
                    coordsArray = fillCoordsArray(HD1, coordsArray, hd1);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD2_CD2, cg, dHD2_CD2_CG, ne2, 126.0, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dHE1_CE1, nd1, dHE1_CE1_ND1, ne2, 126.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    break;
                }
            case HIE:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom ND1 = (Atom) newResidue.getAtomNode("ND1");
                    double[] nd1 = coordsArray[ND1.getIndex() - 1];
                    Atom CD2 = (Atom) newResidue.getAtomNode("CD2");
                    double[] cd2 = coordsArray[CD2.getIndex() - 1];
                    Atom CE1 = (Atom) newResidue.getAtomNode("CE1");
                    double[] ce1 = coordsArray[CE1.getIndex() - 1];
                    Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
                    double[] ne2 = coordsArray[NE2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond ND1_CG = ND1.getBond(CG);
                    Bond CD2_CG = CD2.getBond(CG);
                    Bond CE1_ND1 = CE1.getBond(ND1);
                    Bond NE2_CD2 = NE2.getBond(CD2);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD2_CD2 = HD2.getBond(CD2);
                    Bond HE1_CE1 = HE1.getBond(CE1);
                    Bond HE2_NE2 = HE2.getBond(NE2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dND1_CG = ND1_CG.bondType.distance;
                    double dCD2_CG = CD2_CG.bondType.distance;
                    double dCE1_ND1 = CE1_ND1.bondType.distance;
                    double dNE2_CD2 = NE2_CD2.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD2_CD2 = HD2_CD2.bondType.distance;
                    double dHE1_CE1 = HE1_CE1.bondType.distance;
                    double dHE2_NE2 = HE2_NE2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle ND1_CG_CB = ND1.getAngle(CG, CB);
                    Angle CD2_CG_CB = CD2.getAngle(CG, CB);
                    Angle CE1_ND1_CG = CE1.getAngle(ND1, CG);
                    Angle NE2_CD2_CG = NE2.getAngle(CD2, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD2_CD2_CG = HD2.getAngle(CD2, CG);
                    Angle HE1_CE1_ND1 = HE1.getAngle(CE1, ND1);
                    Angle HE2_NE2_CD2 = HE2.getAngle(NE2, CD2);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dND1_CG_CB = ND1_CG_CB.angleType.angle[ND1_CG_CB.nh];
                    double dCD2_CG_CB = CD2_CG_CB.angleType.angle[CD2_CG_CB.nh];
                    double dCE1_ND1_CG = CE1_ND1_CG.angleType.angle[CE1_ND1_CG.nh];
                    double dNE2_CD2_CG = NE2_CD2_CG.angleType.angle[NE2_CD2_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD2_CD2_CG = HD2_CD2_CG.angleType.angle[HD2_CD2_CG.nh];
                    double dHE1_CE1_ND1 = HE1_CE1_ND1.angleType.angle[HE1_CE1_ND1.nh];
                    double dHE2_NE2_CD2 = HE2_NE2_CD2.angleType.angle[HE2_NE2_CD2.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // ND1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dND1_CG, cb, dND1_CG_CB, ca, 180.0, 0), 0, nd1, 0, 3);
                    coordsArray = fillCoordsArray(ND1, coordsArray, nd1);
                    // CD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD2_CG, cb, dCD2_CG_CB, nd1, 108.0, 1), 0, cd2, 0, 3);
                    coordsArray = fillCoordsArray(CD2, coordsArray, cd2);
                    // CE1
                    System.arraycopy(BondedUtils.determineIntxyz(nd1, dCE1_ND1, cg, dCE1_ND1_CG, cd2, 0.0, 0), 0, ce1, 0, 3);
                    coordsArray = fillCoordsArray(CE1, coordsArray, ce1);
                    // NE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dNE2_CD2, cg, dNE2_CD2_CG, nd1, 0.0, 0), 0, ne2, 0, 3);
                    coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd2, dHD2_CD2, cg, dHD2_CD2_CG, ne2, 126.0, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce1, dHE1_CE1, nd1, dHE1_CE1_ND1, ne2, 126.0, 1), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ne2, dHE2_NE2, cd2, dHE2_NE2_CD2, ce1, 126.0, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    break;
                }
            case ASP:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom OD1 = (Atom) newResidue.getAtomNode("OD1");
                    double[] od1 = coordsArray[OD1.getIndex() - 1];
                    Atom OD2 = (Atom) newResidue.getAtomNode("OD2");
                    double[] od2 = coordsArray[OD2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond OD1_CG = OD1.getBond(CG);
                    Bond OD2_CG = OD2.getBond(CG);
                    Bond HB_CB = HB2.getBond(CB);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dOD1_CG = OD1_CG.bondType.distance;
                    double dOD2_CG = OD2_CG.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle OD1_CG_CB = OD1.getAngle(CG, CB);
                    Angle OD2_CG_CB = OD2.getAngle(CG, CB);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dOD1_CG_CB = OD1_CG_CB.angleType.angle[OD1_CG_CB.nh];
                    double dOD2_CG_CB = OD2_CG_CB.angleType.angle[OD2_CG_CB.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // OD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dOD1_CG, cb, dOD1_CG_CB, ca, 0.0, 0), 0, od1, 0, 3);
                    coordsArray = fillCoordsArray(OD1, coordsArray, od1);
                    // OD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dOD2_CG, cb, dOD2_CG_CB, od1, 126.0, 1), 0, od2, 0, 3);
                    coordsArray = fillCoordsArray(OD2, coordsArray, od2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    break;
                }
            case ASH:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom OD1 = (Atom) newResidue.getAtomNode("OD1");
                    double[] od1 = coordsArray[OD1.getIndex() - 1];
                    Atom OD2 = (Atom) newResidue.getAtomNode("OD2");
                    double[] od2 = coordsArray[OD2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond OD1_CG = OD1.getBond(CG);
                    Bond OD2_CG = OD2.getBond(CG);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD2_OD2 = HD2.getBond(OD2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dOD1_CG = OD1_CG.bondType.distance;
                    double dOD2_CG = OD2_CG.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD2_OD2 = HD2_OD2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle OD1_CG_CB = OD1.getAngle(CG, CB);
                    Angle OD2_CG_CB = OD2.getAngle(CG, CB);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD2_OD2_CG = HD2.getAngle(OD2, CG);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dOD1_CG_CB = OD1_CG_CB.angleType.angle[OD1_CG_CB.nh];
                    double dOD2_CG_CB = OD2_CG_CB.angleType.angle[OD2_CG_CB.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD2_OD2_CG = HD2_OD2_CG.angleType.angle[HD2_OD2_CG.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // OD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dOD1_CG, cb, dOD1_CG_CB, ca, 0.0, 0), 0, od1, 0, 3);
                    coordsArray = fillCoordsArray(OD1, coordsArray, od1);
                    // OD2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dOD2_CG, cb, dOD2_CG_CB, od1, 126.0, 1), 0, od2, 0, 3);
                    coordsArray = fillCoordsArray(OD2, coordsArray, od2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(od2, dHD2_OD2, cg, dHD2_OD2_CG, od1, 0.0, 0), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    break;
                }
            case ASN:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom OD1 = (Atom) newResidue.getAtomNode("OD1");
                    double[] od1 = coordsArray[OD1.getIndex() - 1];
                    Atom ND2 = (Atom) newResidue.getAtomNode("ND2");
                    double[] nd2 = coordsArray[ND2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HD21 = (Atom) newResidue.getAtomNode("HD21");
                    double[] hd21 = coordsArray[HD21.getIndex() - 1];
                    Atom HD22 = (Atom) newResidue.getAtomNode("HD22");
                    double[] hd22 = coordsArray[HD22.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond OD1_CG = OD1.getBond(CG);
                    Bond ND2_CG = ND2.getBond(CG);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HD2_ND2 = HD21.getBond(ND2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dOD1_CG = OD1_CG.bondType.distance;
                    double dND2_CG = ND2_CG.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHD2_ND2 = HD2_ND2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle OD1_CG_CB = OD1.getAngle(CG, CB);
                    Angle ND2_CG_CB = ND2.getAngle(CG, CB);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HD2_ND2_CG = HD21.getAngle(ND2, CG);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dOD1_CG_CB = OD1_CG_CB.angleType.angle[OD1_CG_CB.nh];
                    double dND2_CG_CB = ND2_CG_CB.angleType.angle[ND2_CG_CB.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHD2_ND2_CG = HD2_ND2_CG.angleType.angle[HD2_ND2_CG.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // OD1
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dOD1_CG, cb, dOD1_CG_CB, ca, 0.0, 0), 0, od1, 0, 3);
                    coordsArray = fillCoordsArray(OD1, coordsArray, od1);
                    // ND2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dND2_CG, cb, dND2_CG_CB, od1, 124.0, 1), 0, nd2, 0, 3);
                    coordsArray = fillCoordsArray(ND2, coordsArray, nd2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 107.9, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HD21
                    System.arraycopy(BondedUtils.determineIntxyz(nd2, dHD2_ND2, cg, dHD2_ND2_CG, cb, 0.0, 0), 0, hd21, 0, 3);
                    coordsArray = fillCoordsArray(HD21, coordsArray, hd21);
                    // HD22
                    System.arraycopy(BondedUtils.determineIntxyz(nd2, dHD2_ND2, cg, dHD2_ND2_CG, hd21, 120.0, 1), 0, hd22, 0, 3);
                    coordsArray = fillCoordsArray(HD22, coordsArray, hd22);
                    break;
                }
            case GLU:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom OE1 = (Atom) newResidue.getAtomNode("OE1");
                    double[] oe1 = coordsArray[OE1.getIndex() - 1];
                    Atom OE2 = (Atom) newResidue.getAtomNode("OE2");
                    double[] oe2 = coordsArray[OE2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond OE1_CD = OE1.getBond(CD);
                    Bond OE2_CD = OE2.getBond(CD);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dOE1_CD = OE1_CD.bondType.distance;
                    double dOE2_CD = OE2_CD.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle OE1_CD_CG = OE1.getAngle(CD, CG);
                    Angle OE2_CD_CG = OE2.getAngle(CD, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dOE1_CD_CG = OE1_CD_CG.angleType.angle[OE1_CD_CG.nh];
                    double dOE2_CD_CG = OE2_CD_CG.angleType.angle[OE2_CD_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // OE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dOE1_CD, cg, dOE1_CD_CG, cb, 180.0, 0), 0, oe1, 0, 3);
                    coordsArray = fillCoordsArray(OE1, coordsArray, oe1);
                    // OE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dOE2_CD, cg, dOE2_CD_CG, oe1, 126.0, 1), 0, oe2, 0, 3);
                    coordsArray = fillCoordsArray(OE2, coordsArray, oe2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    break;
                }
            case GLH:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom OE1 = (Atom) newResidue.getAtomNode("OE1");
                    double[] oe1 = coordsArray[OE1.getIndex() - 1];
                    Atom OE2 = (Atom) newResidue.getAtomNode("OE2");
                    double[] oe2 = coordsArray[OE2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond OE1_CD = OE1.getBond(CD);
                    Bond OE2_CD = OE2.getBond(CD);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HE2_OE2 = HE2.getBond(OE2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dOE1_CD = OE1_CD.bondType.distance;
                    double dOE2_CD = OE2_CD.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHE2_OE2 = HE2_OE2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle OE1_CD_CG = OE1.getAngle(CD, CG);
                    Angle OE2_CD_CG = OE2.getAngle(CD, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HE2_OE2_CD = HE2.getAngle(OE2, CD);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dOE1_CD_CG = OE1_CD_CG.angleType.angle[OE1_CD_CG.nh];
                    double dOE2_CD_CG = OE2_CD_CG.angleType.angle[OE2_CD_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHE2_OE2_CD = HE2_OE2_CD.angleType.angle[HE2_OE2_CD.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // OE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dOE1_CD, cg, dOE1_CD_CG, cb, 180.0, 0), 0, oe1, 0, 3);
                    coordsArray = fillCoordsArray(OE1, coordsArray, oe1);
                    // OE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dOE2_CD, cg, dOE2_CD_CG, oe1, 126.0, 1), 0, oe2, 0, 3);
                    coordsArray = fillCoordsArray(OE2, coordsArray, oe2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(oe2, dHE2_OE2, cd, dHE2_OE2_CD, oe1, 0.0, 0), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    break;
                }
            case GLN:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom OE1 = (Atom) newResidue.getAtomNode("OE1");
                    double[] oe1 = coordsArray[OE1.getIndex() - 1];
                    Atom NE2 = (Atom) newResidue.getAtomNode("NE2");
                    double[] ne2 = coordsArray[NE2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HE21 = (Atom) newResidue.getAtomNode("HE21");
                    double[] he21 = coordsArray[HE21.getIndex() - 1];
                    Atom HE22 = (Atom) newResidue.getAtomNode("HE22");
                    double[] he22 = coordsArray[HE22.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond OE1_CD = OE1.getBond(CD);
                    Bond NE2_CD = NE2.getBond(CD);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HE2_NE2 = HE21.getBond(NE2);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dOE1_CD = OE1_CD.bondType.distance;
                    double dNE2_CD = NE2_CD.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHE2_NE2 = HE2_NE2.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle OE1_CD_CG = OE1.getAngle(CD, CG);
                    Angle NE2_CD_CG = NE2.getAngle(CD, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HE2_NE2_CD = HE21.getAngle(NE2, CD);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dOE1_CD_CG = OE1_CD_CG.angleType.angle[OE1_CD_CG.nh];
                    double dNE2_CD_CG = NE2_CD_CG.angleType.angle[NE2_CD_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHE2_NE2_CD = HE2_NE2_CD.angleType.angle[HE2_NE2_CD.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // OE1
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dOE1_CD, cg, dOE1_CD_CG, cb, 180.0, 0), 0, oe1, 0, 3);
                    coordsArray = fillCoordsArray(OE1, coordsArray, oe1);
                    // NE2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dNE2_CD, cg, dNE2_CD_CG, oe1, 124.0, 1), 0, ne2, 0, 3);
                    coordsArray = fillCoordsArray(NE2, coordsArray, ne2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 107.9, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HE21
                    System.arraycopy(BondedUtils.determineIntxyz(ne2, dHE2_NE2, cd, dHE2_NE2_CD, cg, 0.0, 0), 0, he21, 0, 3);
                    coordsArray = fillCoordsArray(HE21, coordsArray, he21);
                    // HE22
                    System.arraycopy(BondedUtils.determineIntxyz(ne2, dHE2_NE2, cd, dHE2_NE2_CD, he21, 120.0, 1), 0, he22, 0, 3);
                    coordsArray = fillCoordsArray(HE22, coordsArray, he22);
                    break;
                }
            case MET:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom SD = (Atom) newResidue.getAtomNode("SD");
                    double[] sd = coordsArray[SD.getIndex() - 1];
                    Atom CE = (Atom) newResidue.getAtomNode("CE");
                    double[] ce = coordsArray[CE.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HE1 = (Atom) newResidue.getAtomNode("HE1");
                    double[] he1 = coordsArray[HE1.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
                    double[] he3 = coordsArray[HE3.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond SD_CG = SD.getBond(CG);
                    Bond CE_SD = CE.getBond(SD);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HE_CE = HE1.getBond(CE);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dSD_CG = SD_CG.bondType.distance;
                    double dCE_SD = CE_SD.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHE_CE = HE_CE.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle SD_CG_CB = SD.getAngle(CG, CB);
                    Angle CE_SD_CG = CE.getAngle(SD, CG);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HE_CE_SD = HE1.getAngle(CE, SD);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dSD_CG_CB = SD_CG_CB.angleType.angle[SD_CG_CB.nh];
                    double dCE_SD_CG = CE_SD_CG.angleType.angle[CE_SD_CG.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHE_CE_SD = HE_CE_SD.angleType.angle[HE_CE_SD.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // SD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dSD_CG, cb, dSD_CG_CB, ca, 180.0, 0), 0, sd, 0, 3);
                    coordsArray = fillCoordsArray(SD, coordsArray, sd);
                    // CE
                    System.arraycopy(BondedUtils.determineIntxyz(sd, dCE_SD, cg, dCE_SD_CG, cb, 180.0, 0), 0, ce, 0, 3);
                    coordsArray = fillCoordsArray(CE, coordsArray, ce);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, sd, 112.0, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, sd, 112.0, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HE1
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, sd, dHE_CE_SD, cg, 180.0, 0), 0, he1, 0, 3);
                    coordsArray = fillCoordsArray(HE1, coordsArray, he1);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, sd, dHE_CE_SD, he1, 109.4, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    // HE3
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, sd, dHE_CE_SD, he1, 109.4, -1), 0, he3, 0, 3);
                    coordsArray = fillCoordsArray(HE3, coordsArray, he3);
                    break;
                }
            case LYS:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom CE = (Atom) newResidue.getAtomNode("CE");
                    double[] ce = coordsArray[CE.getIndex() - 1];
                    Atom NZ = (Atom) newResidue.getAtomNode("NZ");
                    double[] nz = coordsArray[NZ.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
                    double[] hd3 = coordsArray[HD3.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
                    double[] he3 = coordsArray[HE3.getIndex() - 1];
                    Atom HZ1 = (Atom) newResidue.getAtomNode("HZ1");
                    double[] hz1 = coordsArray[HZ1.getIndex() - 1];
                    Atom HZ2 = (Atom) newResidue.getAtomNode("HZ2");
                    double[] hz2 = coordsArray[HZ2.getIndex() - 1];
                    Atom HZ3 = (Atom) newResidue.getAtomNode("HZ3");
                    double[] hz3 = coordsArray[HZ3.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond CE_CD = CE.getBond(CD);
                    Bond NZ_CE = NZ.getBond(CE);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HD_CD = HD2.getBond(CD);
                    Bond HE_CE = HE2.getBond(CE);
                    Bond HZ_NZ = HZ1.getBond(NZ);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dCE_CD = CE_CD.bondType.distance;
                    double dNZ_CE = NZ_CE.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    double dHE_CE = HE_CE.bondType.distance;
                    double dHZ_NZ = HZ_NZ.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle CE_CD_CG = CE.getAngle(CD, CG);
                    Angle NZ_CE_CD = NZ.getAngle(CE, CD);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HD_CD_CG = HD2.getAngle(CD, CG);
                    Angle HE_CE_CD = HE2.getAngle(CE, CD);
                    Angle HZ_NZ_CE = HZ1.getAngle(NZ, CE);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
                    double dNZ_CE_CD = NZ_CE_CD.angleType.angle[NZ_CE_CD.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
                    double dHZ_NZ_CE = HZ_NZ_CE.angleType.angle[HZ_NZ_CE.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // CE
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dCE_CD, cg, dCE_CD_CG, cb, 180.0, 0), 0, ce, 0, 3);
                    coordsArray = fillCoordsArray(CE, coordsArray, ce);
                    // NZ
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dNZ_CE, cd, dNZ_CE_CD, cg, 180.0, 0), 0, nz, 0, 3);
                    coordsArray = fillCoordsArray(NZ, coordsArray, nz);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HD3
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, -1), 0, hd3, 0, 3);
                    coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    // HE3
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, -1), 0, he3, 0, 3);
                    coordsArray = fillCoordsArray(HE3, coordsArray, he3);
                    // HZ1
                    System.arraycopy(BondedUtils.determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, cd, 180.0, 0), 0, hz1, 0, 3);
                    coordsArray = fillCoordsArray(HZ1, coordsArray, hz1);
                    // HZ2
                    System.arraycopy(BondedUtils.determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, hz1, 109.5, 1), 0, hz2, 0, 3);
                    coordsArray = fillCoordsArray(HZ2, coordsArray, hz2);
                    // HZ3
                    System.arraycopy(BondedUtils.determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, hz1, 109.5, -1), 0, hz3, 0, 3);
                    coordsArray = fillCoordsArray(HZ3, coordsArray, hz3);
                    break;
                }
            case LYD:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom CE = (Atom) newResidue.getAtomNode("CE");
                    double[] ce = coordsArray[CE.getIndex() - 1];
                    Atom NZ = (Atom) newResidue.getAtomNode("NZ");
                    double[] nz = coordsArray[NZ.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HD2.getIndex() - 1];
                    Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
                    double[] hd3 = coordsArray[HD3.getIndex() - 1];
                    Atom HE2 = (Atom) newResidue.getAtomNode("HE2");
                    double[] he2 = coordsArray[HE2.getIndex() - 1];
                    Atom HE3 = (Atom) newResidue.getAtomNode("HE3");
                    double[] he3 = coordsArray[HE3.getIndex() - 1];
                    Atom HZ1 = (Atom) newResidue.getAtomNode("HZ1");
                    double[] hz1 = coordsArray[HZ1.getIndex() - 1];
                    Atom HZ2 = (Atom) newResidue.getAtomNode("HZ2");
                    double[] hz2 = coordsArray[HZ2.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond CE_CD = CE.getBond(CD);
                    Bond NZ_CE = NZ.getBond(CE);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HD_CD = HD2.getBond(CD);
                    Bond HE_CE = HE2.getBond(CE);
                    Bond HZ_NZ = HZ1.getBond(NZ);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dCE_CD = CE_CD.bondType.distance;
                    double dNZ_CE = NZ_CE.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    double dHE_CE = HE_CE.bondType.distance;
                    double dHZ_NZ = HZ_NZ.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle CE_CD_CG = CE.getAngle(CD, CG);
                    Angle NZ_CE_CD = NZ.getAngle(CE, CD);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HD_CD_CG = HD2.getAngle(CD, CG);
                    Angle HE_CE_CD = HE2.getAngle(CE, CD);
                    Angle HZ_NZ_CE = HZ1.getAngle(NZ, CE);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dCE_CD_CG = CE_CD_CG.angleType.angle[CE_CD_CG.nh];
                    double dNZ_CE_CD = NZ_CE_CD.angleType.angle[NZ_CE_CD.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    double dHE_CE_CD = HE_CE_CD.angleType.angle[HE_CE_CD.nh];
                    double dHZ_NZ_CE = HZ_NZ_CE.angleType.angle[HZ_NZ_CE.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // CE
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dCE_CD, cg, dCE_CD_CG, cb, 180.0, 0), 0, ce, 0, 3);
                    coordsArray = fillCoordsArray(CE, coordsArray, ce);
                    // NZ
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dNZ_CE, cd, dNZ_CE_CD, cg, 180.0, 0), 0, nz, 0, 3);
                    coordsArray = fillCoordsArray(NZ, coordsArray, nz);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HD3
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ce, 109.4, -1), 0, hd3, 0, 3);
                    coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
                    // HE2
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, 1), 0, he2, 0, 3);
                    coordsArray = fillCoordsArray(HE2, coordsArray, he2);
                    // HE3
                    System.arraycopy(BondedUtils.determineIntxyz(ce, dHE_CE, cd, dHE_CE_CD, nz, 108.8, -1), 0, he3, 0, 3);
                    coordsArray = fillCoordsArray(HE3, coordsArray, he3);
                    // HZ1
                    System.arraycopy(BondedUtils.determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, cd, 180.0, 0), 0, hz1, 0, 3);
                    coordsArray = fillCoordsArray(HZ1, coordsArray, hz1);
                    // HZ2
                    System.arraycopy(BondedUtils.determineIntxyz(nz, dHZ_NZ, ce, dHZ_NZ_CE, hz1, 109.5, 1), 0, hz2, 0, 3);
                    coordsArray = fillCoordsArray(HZ2, coordsArray, hz2);
                    break;
                }
            case ARG:
                {
                    Atom CB = (Atom) newResidue.getAtomNode("CB");
                    double[] cb = coordsArray[CB.getIndex() - 1];
                    Atom CG = (Atom) newResidue.getAtomNode("CG");
                    double[] cg = coordsArray[CG.getIndex() - 1];
                    Atom CD = (Atom) newResidue.getAtomNode("CD");
                    double[] cd = coordsArray[CD.getIndex() - 1];
                    Atom NE = (Atom) newResidue.getAtomNode("NE");
                    double[] ne = coordsArray[NE.getIndex() - 1];
                    Atom CZ = (Atom) newResidue.getAtomNode("CZ");
                    double[] cz = coordsArray[CZ.getIndex() - 1];
                    Atom NH1 = (Atom) newResidue.getAtomNode("NH1");
                    double[] nh1 = coordsArray[NH1.getIndex() - 1];
                    Atom NH2 = (Atom) newResidue.getAtomNode("NH2");
                    double[] nh2 = coordsArray[NH2.getIndex() - 1];
                    Atom HB2 = (Atom) newResidue.getAtomNode("HB2");
                    double[] hb2 = coordsArray[HB2.getIndex() - 1];
                    Atom HB3 = (Atom) newResidue.getAtomNode("HB3");
                    double[] hb3 = coordsArray[HB3.getIndex() - 1];
                    Atom HG2 = (Atom) newResidue.getAtomNode("HG2");
                    double[] hg2 = coordsArray[HG2.getIndex() - 1];
                    Atom HG3 = (Atom) newResidue.getAtomNode("HG3");
                    double[] hg3 = coordsArray[HG3.getIndex() - 1];
                    Atom HD2 = (Atom) newResidue.getAtomNode("HD2");
                    double[] hd2 = coordsArray[HG2.getIndex() - 1];
                    Atom HD3 = (Atom) newResidue.getAtomNode("HD3");
                    double[] hd3 = coordsArray[HD3.getIndex() - 1];
                    Atom HE = (Atom) newResidue.getAtomNode("HE");
                    double[] he = coordsArray[HE.getIndex() - 1];
                    Atom HH11 = (Atom) newResidue.getAtomNode("HH11");
                    double[] hh11 = coordsArray[HH11.getIndex() - 1];
                    Atom HH12 = (Atom) newResidue.getAtomNode("HH12");
                    double[] hh12 = coordsArray[HH12.getIndex() - 1];
                    Atom HH21 = (Atom) newResidue.getAtomNode("HH21");
                    double[] hh21 = coordsArray[HH21.getIndex() - 1];
                    Atom HH22 = (Atom) newResidue.getAtomNode("HH22");
                    double[] hh22 = coordsArray[HH22.getIndex() - 1];
                    Bond CG_CB = CG.getBond(CB);
                    Bond CD_CG = CD.getBond(CG);
                    Bond NE_CD = NE.getBond(CD);
                    Bond CZ_NE = CZ.getBond(NE);
                    Bond NH_CZ = NH1.getBond(CZ);
                    Bond HB_CB = HB2.getBond(CB);
                    Bond HG_CG = HG2.getBond(CG);
                    Bond HD_CD = HD2.getBond(CD);
                    Bond HE_NE = HE.getBond(NE);
                    Bond HH_NH = HH11.getBond(NH1);
                    double dCG_CB = CG_CB.bondType.distance;
                    double dCD_CG = CD_CG.bondType.distance;
                    double dNE_CD = NE_CD.bondType.distance;
                    double dCZ_NE = CZ_NE.bondType.distance;
                    double dNH_CZ = NH_CZ.bondType.distance;
                    double dHB_CB = HB_CB.bondType.distance;
                    double dHG_CG = HG_CG.bondType.distance;
                    double dHD_CD = HD_CD.bondType.distance;
                    double dHE_NE = HE_NE.bondType.distance;
                    double dHH_NH = HH_NH.bondType.distance;
                    Angle CG_CB_CA = CG.getAngle(CB, CA);
                    Angle CD_CG_CB = CD.getAngle(CG, CB);
                    Angle NE_CD_CG = NE.getAngle(CD, CG);
                    Angle CZ_NE_CD = CZ.getAngle(NE, CD);
                    Angle NH_CZ_NE = NH1.getAngle(CZ, NE);
                    Angle HB_CB_CA = HB2.getAngle(CB, CA);
                    Angle HG_CG_CB = HG2.getAngle(CG, CB);
                    Angle HD_CD_CG = HD2.getAngle(CD, CG);
                    Angle HE_NE_CD = HE.getAngle(NE, CD);
                    Angle HH_NH_CZ = HH11.getAngle(NH1, CZ);
                    double dCG_CB_CA = CG_CB_CA.angleType.angle[CG_CB_CA.nh];
                    double dCD_CG_CB = CD_CG_CB.angleType.angle[CD_CG_CB.nh];
                    double dNE_CD_CG = NE_CD_CG.angleType.angle[NE_CD_CG.nh];
                    double dCZ_NE_CD = CZ_NE_CD.angleType.angle[CZ_NE_CD.nh];
                    double dNH_CZ_NE = NH_CZ_NE.angleType.angle[NH_CZ_NE.nh];
                    double dHB_CB_CA = HB_CB_CA.angleType.angle[HB_CB_CA.nh];
                    double dHG_CG_CB = HG_CG_CB.angleType.angle[HG_CG_CB.nh];
                    double dHD_CD_CG = HD_CD_CG.angleType.angle[HD_CD_CG.nh];
                    double dHE_NE_CD = HE_NE_CD.angleType.angle[HE_NE_CD.nh];
                    double dHH_NH_CZ = HH_NH_CZ.angleType.angle[HH_NH_CZ.nh];
                    System.arraycopy(BondedUtils.determineIntxyz(ca, 1.54, n, 109.5, c, 107.8, 1), 0, cb, 0, 3);
                    coordsArray = fillCoordsArray(CB, coordsArray, cb);
                    // CG
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dCG_CB, ca, dCG_CB_CA, n, rotScale * 180.0, 0), 0, cg, 0, 3);
                    coordsArray = fillCoordsArray(CG, coordsArray, cg);
                    // CD
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dCD_CG, cb, dCD_CG_CB, ca, 180.0, 0), 0, cd, 0, 3);
                    coordsArray = fillCoordsArray(CD, coordsArray, cd);
                    // NE
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dNE_CD, cg, dNE_CD_CG, cb, 180.0, 0), 0, ne, 0, 3);
                    coordsArray = fillCoordsArray(NE, coordsArray, ne);
                    // CZ
                    System.arraycopy(BondedUtils.determineIntxyz(ne, dCZ_NE, cd, dCZ_NE_CD, cg, 180.0, 0), 0, cz, 0, 3);
                    coordsArray = fillCoordsArray(CZ, coordsArray, cz);
                    // NH1
                    System.arraycopy(BondedUtils.determineIntxyz(cz, dNH_CZ, ne, dNH_CZ_NE, cd, 180, 0), 0, nh1, 0, 3);
                    coordsArray = fillCoordsArray(NH1, coordsArray, nh1);
                    // NH2
                    System.arraycopy(BondedUtils.determineIntxyz(cz, dNH_CZ, ne, dNH_CZ_NE, nh1, 120.0, 1), 0, nh2, 0, 3);
                    coordsArray = fillCoordsArray(NH2, coordsArray, nh2);
                    // HB2
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, 1), 0, hb2, 0, 3);
                    coordsArray = fillCoordsArray(HB2, coordsArray, hb2);
                    // HB3
                    System.arraycopy(BondedUtils.determineIntxyz(cb, dHB_CB, ca, dHB_CB_CA, cg, 109.4, -1), 0, hb3, 0, 3);
                    coordsArray = fillCoordsArray(HB3, coordsArray, hb3);
                    // HG2
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, 1), 0, hg2, 0, 3);
                    coordsArray = fillCoordsArray(HG2, coordsArray, hg2);
                    // HG3
                    System.arraycopy(BondedUtils.determineIntxyz(cg, dHG_CG, cb, dHG_CG_CB, cd, 109.4, -1), 0, hg3, 0, 3);
                    coordsArray = fillCoordsArray(HG3, coordsArray, hg3);
                    // HD2
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ne, 109.4, 1), 0, hd2, 0, 3);
                    coordsArray = fillCoordsArray(HD2, coordsArray, hd2);
                    // HD3
                    System.arraycopy(BondedUtils.determineIntxyz(cd, dHD_CD, cg, dHD_CD_CG, ne, 109.4, -1), 0, hd3, 0, 3);
                    coordsArray = fillCoordsArray(HD3, coordsArray, hd3);
                    // HE
                    System.arraycopy(BondedUtils.determineIntxyz(ne, dHE_NE, cd, dHE_NE_CD, cz, 120.0, 1), 0, he, 0, 3);
                    coordsArray = fillCoordsArray(HE, coordsArray, he);
                    // HH11
                    System.arraycopy(BondedUtils.determineIntxyz(nh1, dHH_NH, cz, dHH_NH_CZ, ne, 180.0, 0), 0, hh11, 0, 3);
                    coordsArray = fillCoordsArray(HH11, coordsArray, hh11);
                    // HH12
                    System.arraycopy(BondedUtils.determineIntxyz(nh1, dHH_NH, cz, dHH_NH_CZ, hh11, 120.0, 1), 0, hh12, 0, 3);
                    coordsArray = fillCoordsArray(HH12, coordsArray, hh12);
                    // HH21
                    System.arraycopy(BondedUtils.determineIntxyz(nh2, dHH_NH, cz, dHH_NH_CZ, ne, 180.0, 0), 0, hh21, 0, 3);
                    coordsArray = fillCoordsArray(HH21, coordsArray, hh21);
                    // HH22
                    System.arraycopy(BondedUtils.determineIntxyz(nh2, dHH_NH, cz, dHH_NH_CZ, hh21, 120.0, 1), 0, hh22, 0, 3);
                    coordsArray = fillCoordsArray(HH22, coordsArray, hh22);
                    break;
                }
            default:
                break;
        }
    }
    double[] coordsArray1D = new double[atomArray.length * 3];
    for (int i = 0; i < atomArray.length; i++) {
        for (int j = 0; j < 3; j++) {
            coordsArray1D[i * 3 + j] = coordsArray[i][j];
        }
    }
    return coordsArray1D;
}
Also used : AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3)

Example 12 with AminoAcid3

use of ffx.potential.bonded.ResidueEnumerations.AminoAcid3 in project ffx by mjschnie.

the class Residue method getRotamers.

/**
 * Gets the Rotamers for this residue, potentially incorporating the
 * original coordinates if RotamerLibrary's original coordinates rotamer
 * flag has been set.
 *
 * @param library Rotamer library to use
 * @return An array of Rotamer.
 */
public Rotamer[] getRotamers(RotamerLibrary library) {
    /**
     * If the rotamers for this residue have been cached, return them.
     */
    if (rotamers != null) {
        return rotamers;
    }
    /**
     * Return rotamers for this residue from the RotamerLibrary.
     */
    Rotamer[] libRotamers = library.getRotamers(this);
    /**
     * If there are no rotamers, and addOrigRot is true, return an array with
     * only an original-coordinates rotamer. Else if there are no rotamers,
     * return (null) library rotamers. If there are rotamers, and original
     * coordinates are turned off, return (filled) library rotamers. Else,
     * continue generating the rotamers array.
     */
    if (libRotamers == null) {
        if (addOrigRot) {
            rotamers = new Rotamer[1];
            ResidueState origState = this.storeState();
            double[] chi = RotamerLibrary.measureRotamer(this, false);
            switch(residueType) {
                case AA:
                    AminoAcid3 aa3 = AminoAcid3.UNK;
                    try {
                        aa3 = AminoAcid3.valueOf(getName());
                    } catch (Exception e) {
                    }
                    originalRotamer = new Rotamer(aa3, origState, chi[0], 0, chi[1], 0, chi[2], 0, chi[3], 0);
                    rotamers[0] = originalRotamer;
                    break;
                case NA:
                    NucleicAcid3 na3 = NucleicAcid3.UNK;
                    try {
                        na3 = NucleicAcid3.valueOf(getName());
                    } catch (Exception e) {
                    }
                    originalRotamer = new Rotamer(na3, origState, chi[0], 0, chi[1], 0, chi[2], 0, chi[3], 0, chi[4], 0, chi[5], 0);
                    rotamers[0] = originalRotamer;
                    break;
                default:
                    originalRotamer = null;
                    // Resets to null.
                    rotamers = libRotamers;
            }
            return rotamers;
        } else {
            return libRotamers;
        }
    } else if (!library.getUsingOrigCoordsRotamer()) {
        return libRotamers;
    }
    /**
     * Define the current coordinates as a new rotamer.
     */
    ResidueState origState = storeState();
    double[] chi = RotamerLibrary.measureRotamer(this, false);
    switch(residueType) {
        case AA:
            AminoAcid3 aa3 = this.getAminoAcid3();
            originalRotamer = new Rotamer(aa3, origState, chi[0], 0, chi[1], 0, chi[2], 0, chi[3], 0);
            break;
        case NA:
            NucleicAcid3 na3 = this.getNucleicAcid3();
            originalRotamer = new Rotamer(na3, origState, chi[0], 0, chi[1], 0, chi[2], 0, chi[3], 0, chi[4], 0, chi[5], 0);
            break;
        default:
            double[] rotaValues = new double[chi.length * 2];
            for (int i = 0; i < chi.length; i++) {
                int ii = i * 2;
                rotaValues[ii] = chi[i];
                rotaValues[ii + 1] = 0.0;
            }
            originalRotamer = new Rotamer(origState, rotaValues);
            break;
    }
    /**
     * Add the new rotamer to those from the library and cache the result.
     */
    int nRots = libRotamers.length;
    rotamers = new Rotamer[nRots + 1];
    if (origAtEnd) {
        System.arraycopy(libRotamers, 0, rotamers, 0, nRots);
        rotamers[rotamers.length - 1] = originalRotamer;
    } else {
        System.arraycopy(libRotamers, 0, rotamers, 1, nRots);
        rotamers[0] = originalRotamer;
    }
    /**
     * Return the rotamer array.
     */
    return rotamers;
}
Also used : NucleicAcid3(ffx.potential.bonded.ResidueEnumerations.NucleicAcid3) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3)

Example 13 with AminoAcid3

use of ffx.potential.bonded.ResidueEnumerations.AminoAcid3 in project ffx by mjschnie.

the class TitrationUtils method performTitration.

/**
 * Perform the requested titration on the given MultiResidue. Remember to
 * call reInit() on affected ForceFieldEnergy and MolecularDynamics objects!
 *
 * @param multiRes
 * @param titration
 */
public static TitrationType performTitration(MultiResidue multiRes, Titration titration, boolean inactivateBackground) {
    AminoAcid3 current = multiRes.getActive().getAminoAcid3();
    final TitrationType type;
    final AminoAcid3 target;
    if (current == titration.protForm) {
        type = TitrationType.DEPROT;
        target = titration.deprotForm;
    } else if (current == titration.deprotForm) {
        type = TitrationType.PROT;
        target = titration.protForm;
    } else {
        throw new IllegalStateException();
    }
    boolean success = multiRes.requestSetActiveResidue(target);
    if (!success) {
        logger.severe(String.format("Couldn't perform requested titration for MultiRes: %s", multiRes.toString()));
    }
    List<Atom> oldAtoms = multiRes.getActive().getAtomList();
    List<Atom> newAtoms = multiRes.getActive().getAtomList();
    // identify which atoms were actually inserted/removed
    List<Atom> removedAtoms = new ArrayList<>();
    List<Atom> insertedAtoms = new ArrayList<>();
    for (Atom oldAtom : oldAtoms) {
        boolean found = false;
        for (Atom newAtom : newAtoms) {
            if (newAtom == oldAtom || (newAtom.getResidueNumber() == oldAtom.getResidueNumber() && newAtom.getName().equals(oldAtom.getName()))) {
                found = true;
                break;
            }
        }
        if (!found) {
            removedAtoms.add(oldAtom);
        }
    }
    for (Atom newAtom : newAtoms) {
        boolean found = false;
        for (Atom oldAtom : oldAtoms) {
            if (newAtom == oldAtom || (newAtom.getResidueNumber() == oldAtom.getResidueNumber() && newAtom.getName().equals(oldAtom.getName()))) {
                found = true;
                break;
            }
        }
        if (!found) {
            insertedAtoms.add(newAtom);
        }
    }
    if (insertedAtoms.size() + removedAtoms.size() > 1) {
        logger.warning("Protonate: removed + inserted atom count > 1.");
    }
    if (inactivateBackground) {
        activateResidue(multiRes.getActive());
        for (Residue res : multiRes.getInactive()) {
            inactivateResidue(res);
        }
    }
    return type;
}
Also used : MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) ArrayList(java.util.ArrayList) Atom(ffx.potential.bonded.Atom)

Example 14 with AminoAcid3

use of ffx.potential.bonded.ResidueEnumerations.AminoAcid3 in project ffx by mjschnie.

the class RotamerLibrary method measureAARotamer.

/**
 * Measures the torsions of an amino acid Residue's current configuration.
 *
 * @param residue To be measured.
 * @param chi Array to be filled with torsion values.
 * @param print Verbosity flag.
 */
public static void measureAARotamer(Residue residue, double[] chi, boolean print) {
    if (residue instanceof MultiResidue) {
        residue = ((MultiResidue) residue).getActive();
    }
    AminoAcid3 name = residue.getAminoAcid3();
    /*try {
            name = AminoAcid3.valueOf(residue.getName());
        } catch (IllegalArgumentException ex) {
            logger.info(String.format("(IAE) valueOf(%s)", residue.getName()));
            throw ex;
        }*/
    switch(name) {
        case VAL:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG1 = (Atom) residue.getAtomNode("CG1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG1)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                        break;
                    }
                }
                break;
            }
        case LEU:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CD1 = (Atom) residue.getAtomNode("CD1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case ILE:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD1 = (Atom) residue.getAtomNode("CD1");
                Atom CG1 = (Atom) residue.getAtomNode("CG1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG1)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG1, CD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case SER:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom OG = (Atom) residue.getAtomNode("OG");
                Atom HG = (Atom) residue.getAtomNode("HG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, OG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, OG, HG)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case THR:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom OG1 = (Atom) residue.getAtomNode("OG1");
                Atom HG1 = (Atom) residue.getAtomNode("HG1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, OG1)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, OG1, HG1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case CYX:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom SG = (Atom) residue.getAtomNode("SG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, SG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                        break;
                    }
                }
                break;
            }
        case CYD:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom SG = (Atom) residue.getAtomNode("SG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, SG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                        break;
                    }
                }
                break;
            }
        case PHE:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD1 = (Atom) residue.getAtomNode("CD1");
                Atom CG = (Atom) residue.getAtomNode("CG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                        break;
                    }
                }
                break;
            }
        case PRO:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom CG = (Atom) residue.getAtomNode("CG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case TYR:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD1 = (Atom) residue.getAtomNode("CD1");
                Atom CE2 = (Atom) residue.getAtomNode("CE2");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CZ = (Atom) residue.getAtomNode("CZ");
                Atom OH = (Atom) residue.getAtomNode("OH");
                Atom HH = (Atom) residue.getAtomNode("HH");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CE2, CZ, OH, HH)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case TYD:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD1 = (Atom) residue.getAtomNode("CD1");
                Atom CG = (Atom) residue.getAtomNode("CG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case TRP:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD1 = (Atom) residue.getAtomNode("CD1");
                Atom CG = (Atom) residue.getAtomNode("CG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case HIS:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom ND1 = (Atom) residue.getAtomNode("ND1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, ND1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case HID:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom ND1 = (Atom) residue.getAtomNode("ND1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, ND1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case HIE:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom ND1 = (Atom) residue.getAtomNode("ND1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, ND1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case ASP:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                        break;
                    }
                }
                break;
            }
        case ASH:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom OD1 = (Atom) residue.getAtomNode("OD1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, OD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case ASN:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom OD1 = (Atom) residue.getAtomNode("OD1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, OD1)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case GLU:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom OE1 = (Atom) residue.getAtomNode("OE1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, CD, OE1)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case GLH:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom OE1 = (Atom) residue.getAtomNode("OE1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, CD, OE1)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case GLN:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom OE1 = (Atom) residue.getAtomNode("OE1");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, CD, OE1)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case MET:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CE = (Atom) residue.getAtomNode("CE");
                Atom SD = (Atom) residue.getAtomNode("SD");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, SD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, SD, CE)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case LYS:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom CE = (Atom) residue.getAtomNode("CE");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom NZ = (Atom) residue.getAtomNode("NZ");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, CD, CE)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CG, CD, CE, NZ)) {
                        chi[3] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case LYD:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom CE = (Atom) residue.getAtomNode("CE");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom NZ = (Atom) residue.getAtomNode("NZ");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, CD, CE)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CG, CD, CE, NZ)) {
                        chi[3] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case ARG:
            {
                ArrayList<ROLS> torsions = residue.getTorsionList();
                Atom N = (Atom) residue.getAtomNode("N");
                Atom CA = (Atom) residue.getAtomNode("CA");
                Atom CB = (Atom) residue.getAtomNode("CB");
                Atom CD = (Atom) residue.getAtomNode("CD");
                Atom CG = (Atom) residue.getAtomNode("CG");
                Atom CZ = (Atom) residue.getAtomNode("CZ");
                Atom NE = (Atom) residue.getAtomNode("NE");
                for (ROLS rols : torsions) {
                    Torsion torsion = (Torsion) rols;
                    if (torsion.compare(N, CA, CB, CG)) {
                        chi[0] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CA, CB, CG, CD)) {
                        chi[1] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CB, CG, CD, NE)) {
                        chi[2] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                    if (torsion.compare(CG, CD, NE, CZ)) {
                        chi[3] = torsion.getValue();
                        if (print) {
                            logger.info(torsion.toString());
                        }
                    }
                }
                break;
            }
        case UNK:
            chi = new double[7];
            String resName = residue.getName().toUpperCase();
            if (nonstdRotCache.containsKey(resName)) {
                nonstdRotCache.get(resName).measureNonstdRot(residue, chi, print);
            // nonstdRotCache.get(resName).applyNonstdRotamer(residue, rotamer);
            } else {
                throw new IllegalArgumentException(String.format("(IAE) valueOf(%s)", residue.getName()));
            }
            break;
        default:
            {
            }
    }
}
Also used : AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) ArrayList(java.util.ArrayList)

Example 15 with AminoAcid3

use of ffx.potential.bonded.ResidueEnumerations.AminoAcid3 in project ffx by mjschnie.

the class MultiResidue method getRotamers.

@Override
public Rotamer[] getRotamers(RotamerLibrary library) {
    if (rotamers != null) {
        return rotamers;
    }
    List<Rotamer[]> usual = new ArrayList<>();
    int nRots = 0;
    for (Residue residue : consideredResidues) {
        Rotamer[] rotamers = library.getRotamers(residue);
        if (rotamers != null && rotamers.length > 0) {
            usual.add(rotamers);
            nRots += rotamers.length;
        }
    }
    if (library.getUsingOrigCoordsRotamer()) {
        if (originalRotamer == null && (residueType == ResidueType.AA || residueType == ResidueType.NA)) {
            ResidueState origState = storeState();
            double[] chi = RotamerLibrary.measureRotamer(activeResidue, false);
            if (residueType == ResidueType.AA) {
                AminoAcid3 aa3 = this.getAminoAcid3();
                originalRotamer = new Rotamer(aa3, origState, chi);
            } else if (residueType == ResidueType.NA) {
                NucleicAcid3 na3 = this.getNucleicAcid3();
                originalRotamer = new Rotamer(na3, origState, chi);
            }
        }
        Rotamer[] allRotamers;
        if (originalRotamer != null) {
            allRotamers = new Rotamer[nRots + 1];
            int index;
            if (origAtEnd) {
                index = 0;
                allRotamers[allRotamers.length - 1] = originalRotamer;
            } else {
                index = 1;
                allRotamers[0] = originalRotamer;
            }
            for (Rotamer[] rotamersI : usual) {
                int nrotamers = rotamersI.length;
                System.arraycopy(rotamersI, 0, allRotamers, index, nrotamers);
                index += nrotamers;
            }
        } else {
            allRotamers = addAllDefaultRotamers(usual, nRots);
        }
        return allRotamers;
    } else {
        return addAllDefaultRotamers(usual, nRots);
    }
}
Also used : NucleicAcid3(ffx.potential.bonded.ResidueEnumerations.NucleicAcid3) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) ArrayList(java.util.ArrayList)

Aggregations

AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)19 Atom (ffx.potential.bonded.Atom)9 ArrayList (java.util.ArrayList)9 Residue (ffx.potential.bonded.Residue)7 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)4 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)4 MultiResidue (ffx.potential.bonded.MultiResidue)4 NucleicAcid3 (ffx.potential.bonded.ResidueEnumerations.NucleicAcid3)4 AtomType (ffx.potential.parameters.AtomType)4 Bond (ffx.potential.bonded.Bond)3 Polymer (ffx.potential.bonded.Polymer)3 ResidueEnumerations.aminoAcidList (ffx.potential.bonded.ResidueEnumerations.aminoAcidList)3 ResidueEnumerations.nucleicAcidList (ffx.potential.bonded.ResidueEnumerations.nucleicAcidList)3 Torsion (ffx.potential.bonded.Torsion)3 TitrationUtils.inactivateResidue (ffx.potential.extended.TitrationUtils.inactivateResidue)3 List (java.util.List)3 MSNode (ffx.potential.bonded.MSNode)2 Molecule (ffx.potential.bonded.Molecule)2 ResiduePosition (ffx.potential.bonded.Residue.ResiduePosition)2 ResidueState (ffx.potential.bonded.ResidueState)2