Search in sources :

Example 1 with ResiduePosition

use of ffx.potential.bonded.Residue.ResiduePosition in project ffx by mjschnie.

the class AminoAcidUtils method assignAminoAcidAtomTypes.

public static void assignAminoAcidAtomTypes(Residue residue, Residue previousResidue, Residue nextResidue, ForceField forceField, ArrayList<Bond> bondList) throws MissingHeavyAtomException, MissingAtomTypeException {
    String residueName = residue.getName().toUpperCase();
    int j = 1;
    ResiduePosition position = MIDDLE_RESIDUE;
    if (previousResidue == null) {
        j = 0;
        position = FIRST_RESIDUE;
    } else if (nextResidue == null) {
        j = 2;
        position = LAST_RESIDUE;
        /**
         * If the last residue only contains a nitrogen turn it into an NH2
         * group.
         */
        Atom N = (Atom) residue.getAtomNode("N");
        if (residue.getAtomNodeList().size() == 1 && N != null) {
            residueName = "NH2".intern();
            residue.setName(residueName);
        }
    }
    AminoAcid3 aminoAcid = getAminoAcid(residueName);
    int aminoAcidNumber = getAminoAcidNumber(residueName);
    /**
     * Non-standard Amino Acid; use ALA backbone types.
     */
    boolean nonStandard = false;
    if (aminoAcid == AminoAcid3.UNK) {
        aminoAcidNumber = getAminoAcidNumber("ALA");
        nonStandard = true;
    }
    /**
     * Only the last residue in a chain should have an OXT/OT2 atom.
     */
    if (nextResidue != null) {
        removeOXT_OT2(residue);
    }
    /**
     * Only the first nitrogen should have H1, H2 and H3 atoms, unless it's
     * an NME cap.
     */
    if (previousResidue != null) {
        removeH1_H2_H3(aminoAcid, residue);
    }
    /**
     * Check for missing heavy atoms. This check ignores special terminating
     * groups like FOR, NH2, etc.
     */
    if (!nonStandard) {
        try {
            checkForMissingHeavyAtoms(aminoAcidNumber, aminoAcid, position, residue);
        } catch (BondedUtils.MissingHeavyAtomException e) {
            logger.log(Level.INFO, " {0} could not be parsed.", residue.toString());
            logger.warning("MissingHeavyAtomException incoming from 194.");
            throw e;
        }
    }
    Atom pC = null;
    Atom pCA = null;
    if (previousResidue != null) {
        pC = (Atom) previousResidue.getAtomNode("C");
        pCA = (Atom) previousResidue.getAtomNode("CA");
    }
    /**
     * Backbone heavy atoms.
     */
    Atom N = (Atom) residue.getAtomNode("N");
    if (N != null) {
        N.setAtomType(BondedUtils.findAtomType(AA_N[j][aminoAcidNumber], forceField));
        if (position != FIRST_RESIDUE) {
            buildBond(pC, N, forceField, bondList);
        }
    }
    Atom CA = null;
    Atom C = null;
    Atom O = null;
    if (!(position == LAST_RESIDUE && aminoAcid == AminoAcid3.NH2)) {
        if (aminoAcid == AminoAcid3.ACE || aminoAcid == AminoAcid3.NME) {
            CA = buildHeavy(residue, "CH3", N, AA_CA[j][aminoAcidNumber], forceField, bondList);
        } else {
            CA = buildHeavy(residue, "CA", N, AA_CA[j][aminoAcidNumber], forceField, bondList);
        }
        if (!(position == LAST_RESIDUE && aminoAcid == AminoAcid3.NME)) {
            C = buildHeavy(residue, "C", CA, AA_C[j][aminoAcidNumber], forceField, bondList);
            O = (Atom) residue.getAtomNode("O");
            if (O == null) {
                O = (Atom) residue.getAtomNode("OT1");
            }
            AtomType atomType = findAtomType(AA_O[j][aminoAcidNumber], forceField);
            if (O == null) {
                MissingHeavyAtomException missingHeavyAtom = new MissingHeavyAtomException("O", atomType, C);
                logger.warning(" MissingHeavyAtomException incoming from 234.");
                throw missingHeavyAtom;
            }
            O.setAtomType(atomType);
            buildBond(C, O, forceField, bondList);
        }
    }
    /**
     * Nitrogen hydrogen atoms.
     */
    AtomType atomType = findAtomType(AA_HN[j][aminoAcidNumber], forceField);
    switch(position) {
        case FIRST_RESIDUE:
            switch(aminoAcid) {
                case PRO:
                    buildHydrogenAtom(residue, "H2", N, 1.02, CA, 109.5, C, 0.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H3", N, 1.02, CA, 109.5, C, -120.0, 0, atomType, forceField, bondList);
                    break;
                case PCA:
                    buildHydrogenAtom(residue, "H", N, 1.02, CA, 109.5, C, -60.0, 0, atomType, forceField, bondList);
                    break;
                case ACE:
                    break;
                default:
                    buildHydrogenAtom(residue, "H1", N, 1.02, CA, 109.5, C, 180.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H2", N, 1.02, CA, 109.5, C, 60.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H3", N, 1.02, CA, 109.5, C, -60.0, 0, atomType, forceField, bondList);
            }
            break;
        case LAST_RESIDUE:
            switch(aminoAcid) {
                case NH2:
                    buildHydrogenAtom(residue, "H1", N, 1.02, pC, 119.0, pCA, 0.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H2", N, 1.02, pC, 119.0, pCA, 180.0, 0, atomType, forceField, bondList);
                    break;
                case NME:
                    buildHydrogenAtom(residue, "H", N, 1.02, pC, 118.0, CA, 121.0, 1, atomType, forceField, bondList);
                    break;
                default:
                    buildHydrogenAtom(residue, "H", N, 1.02, pC, 119.0, CA, 119.0, 1, atomType, forceField, bondList);
            }
            break;
        default:
            // Mid-chain nitrogen hydrogen.
            buildHydrogenAtom(residue, "H", N, 1.02, pC, 119.0, CA, 119.0, 1, atomType, forceField, bondList);
    }
    /**
     * C-alpha hydrogen atoms.
     */
    String haName = "HA";
    if (aminoAcid == AminoAcid3.GLY) {
        haName = "HA2";
    }
    atomType = findAtomType(AA_HA[j][aminoAcidNumber], forceField);
    switch(position) {
        case FIRST_RESIDUE:
            switch(aminoAcid) {
                case FOR:
                    buildHydrogenAtom(residue, "H", C, 1.12, O, 0.0, null, 0.0, 0, atomType, forceField, bondList);
                    break;
                case ACE:
                    buildHydrogenAtom(residue, "H1", CA, 1.10, C, 109.5, O, 180.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H2", CA, 1.10, C, 109.5, O, 60.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H3", CA, 1.10, C, 109.5, O, -60.0, 0, atomType, forceField, bondList);
                    break;
                default:
                    buildHydrogenAtom(residue, haName, CA, 1.10, N, 109.5, C, 109.5, -1, atomType, forceField, bondList);
                    break;
            }
            break;
        case LAST_RESIDUE:
            switch(aminoAcid) {
                case NME:
                    buildHydrogenAtom(residue, "H1", CA, 1.10, N, 109.5, pC, 180.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H2", CA, 1.10, N, 109.5, pC, 60.0, 0, atomType, forceField, bondList);
                    buildHydrogenAtom(residue, "H3", CA, 1.10, N, 109.5, pC, -60.0, 0, atomType, forceField, bondList);
                    break;
                default:
                    buildHydrogenAtom(residue, haName, CA, 1.10, N, 109.5, C, 109.5, -1, atomType, forceField, bondList);
            }
            break;
        default:
            buildHydrogenAtom(residue, haName, CA, 1.10, N, 109.5, C, 109.0, -1, atomType, forceField, bondList);
    }
    /**
     * Build the amino acid side chain.
     */
    assignAminoAcidSideChain(position, aminoAcid, residue, CA, N, C, forceField, bondList);
    /**
     * Build the terminal oxygen if the residue is not NH2 or NME.
     */
    if (position == LAST_RESIDUE && !(aminoAcid == AminoAcid3.NH2 || aminoAcid == AminoAcid3.NME)) {
        atomType = findAtomType(AA_O[2][aminoAcidNumber], forceField);
        Atom OXT = (Atom) residue.getAtomNode("OXT");
        if (OXT == null) {
            OXT = (Atom) residue.getAtomNode("OT2");
            if (OXT != null) {
                OXT.setName("OXT");
            }
        }
        if (OXT == null) {
            String resName = C.getResidueName();
            int resSeq = C.getResidueNumber();
            Character chainID = C.getChainID();
            Character altLoc = C.getAltLoc();
            String segID = C.getSegID();
            double occupancy = C.getOccupancy();
            double tempFactor = C.getTempFactor();
            OXT = new Atom(0, "OXT", altLoc, new double[3], resName, resSeq, chainID, occupancy, tempFactor, segID);
            OXT.setAtomType(atomType);
            residue.addMSNode(OXT);
            intxyz(OXT, C, 1.25, CA, 117.0, O, 126.0, 1);
        } else {
            OXT.setAtomType(atomType);
        }
        buildBond(C, OXT, forceField, bondList);
    }
    /**
     * Do some checks on the current residue to make sure all atoms have
     * been assigned an atom type.
     */
    List<Atom> resAtoms = residue.getAtomList();
    for (Atom atom : resAtoms) {
        atomType = atom.getAtomType();
        if (atomType == null) {
            /**
             * Sometimes, with deuterons, a proton has been constructed in
             * its place, so we have a "dummy" deuteron still hanging
             * around.
             */
            String protonEq = atom.getName().replaceFirst("D", "H");
            Atom correspH = (Atom) residue.getAtomNode(protonEq);
            if (correspH == null || correspH.getAtomType() == null) {
                MissingAtomTypeException missingAtomTypeException = new MissingAtomTypeException(residue, atom);
                logger.warning("MissingAtomTypeException incoming from 393.");
                throw missingAtomTypeException;
            } else {
                correspH.setName(atom.getName());
                atom.removeFromParent();
                atom = correspH;
                atomType = atom.getAtomType();
            }
        }
        int numberOfBonds = atom.getNumBonds();
        if (numberOfBonds != atomType.valence) {
            if (atom == C && numberOfBonds == atomType.valence - 1 && position != LAST_RESIDUE) {
                continue;
            }
            logger.warning(format(" An atom for residue %s has the wrong number of bonds:\n %s", residueName, atom.toString()));
            logger.warning(format(" Expected: %d Actual: %d.", atomType.valence, numberOfBonds));
        }
    }
}
Also used : ResiduePosition(ffx.potential.bonded.Residue.ResiduePosition) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) MissingHeavyAtomException(ffx.potential.bonded.BondedUtils.MissingHeavyAtomException) MissingHeavyAtomException(ffx.potential.bonded.BondedUtils.MissingHeavyAtomException) BondedUtils.buildHydrogenAtom(ffx.potential.bonded.BondedUtils.buildHydrogenAtom) MissingAtomTypeException(ffx.potential.bonded.BondedUtils.MissingAtomTypeException) AtomType(ffx.potential.parameters.AtomType) BondedUtils.findAtomType(ffx.potential.bonded.BondedUtils.findAtomType)

Example 2 with ResiduePosition

use of ffx.potential.bonded.Residue.ResiduePosition in project ffx by mjschnie.

the class BiojavaFilter method assignNucleicAcidAtomTypes.

/**
 * Assign atom types for a nucleic acid polymer.
 *
 * @param residues
 * @throws ffx.potential.parsers.PDBFilter.MissingHeavyAtomException
 */
private void assignNucleicAcidAtomTypes(List<Residue> residues) throws MissingHeavyAtomException, MissingAtomTypeException {
    /**
     * A reference to the O3* atom of the previous base.
     */
    Atom pO3s = null;
    /**
     * Loop over residues.
     */
    int numberOfResidues = residues.size();
    for (int residueNumber = 0; residueNumber < numberOfResidues; residueNumber++) {
        /**
         * Match the residue name to a known nucleic acid residue.
         */
        Residue residue = residues.get(residueNumber);
        String residueName = residue.getName().toUpperCase();
        NucleicAcid3 nucleicAcid = null;
        int naNumber = -1;
        for (NucleicAcid3 nucleic : nucleicAcidList) {
            naNumber++;
            String nuc3 = nucleic.toString();
            nuc3 = nuc3.substring(nuc3.length() - 3);
            if (nuc3.equalsIgnoreCase(residueName)) {
                nucleicAcid = nucleic;
                break;
            }
        }
        /**
         * Do atom name conversions.
         */
        List<Atom> resAtoms = residue.getAtomList();
        int natoms = resAtoms.size();
        for (int i = 0; i < natoms; i++) {
            Atom atom = resAtoms.get(i);
            String name = atom.getName();
            name = name.replace('*', '\'');
            // name = name.replace('D', 'H');
            atom.setName(name);
        }
        /**
         * Check if this is a 3' phosphate being listed as its own residue.
         */
        /*if (residue.getAtomList().size() == 1) {
             Atom P3s = (Atom) residue.getAtomNode("NA_P");
             if (P3s != null) {
             Residue prevResidue = residue.getPreviousResidue();
             if (prevResidue != null) {
             Atom O2sPrev = (Atom) prevResidue.getAtomNode("NA_O2\'");
             if (O2sPrev == null) {
             P3s = buildHeavy(prevResidue, "P3s", null, 1247);
             } else {
             P3s = buildHeavy(prevResidue, "P3s", null, 1235);
             }
             } else {
             return;
             }
             } else {
             return;
             }
             }*/
        /**
         * Check if the sugar is deoxyribose and change the residue name if
         * necessary.
         */
        boolean isDNA = false;
        Atom O2s = (Atom) residue.getAtomNode("O2\'");
        if (O2s == null) {
            /**
             * Assume deoxyribose (DNA) since there is an O2* atom.
             */
            isDNA = true;
            if (!residueName.startsWith("D")) {
                switch(nucleicAcid) {
                    case ADE:
                        nucleicAcid = NucleicAcid3.DAD;
                        residueName = "DAD";
                        residue.setName(residueName);
                        break;
                    case CYT:
                        nucleicAcid = NucleicAcid3.DCY;
                        residueName = "DCY";
                        residue.setName(residueName);
                        break;
                    case GUA:
                        nucleicAcid = NucleicAcid3.DGU;
                        residueName = "DGU";
                        residue.setName(residueName);
                        break;
                    case THY:
                        nucleicAcid = NucleicAcid3.DTY;
                        residueName = "DTY";
                        residue.setName(residueName);
                        break;
                    default:
                }
            }
        } else /**
         * Assume ribose (RNA) since there is an O2* atom.
         */
        if (residueName.startsWith("D")) {
            switch(nucleicAcid) {
                case DAD:
                    nucleicAcid = NucleicAcid3.ADE;
                    residueName = "ADE";
                    residue.setName(residueName);
                    break;
                case DCY:
                    nucleicAcid = NucleicAcid3.CYT;
                    residueName = "CYT";
                    residue.setName(residueName);
                    break;
                case DGU:
                    nucleicAcid = NucleicAcid3.GUA;
                    residueName = "GUA";
                    residue.setName(residueName);
                    break;
                case DTY:
                    nucleicAcid = NucleicAcid3.THY;
                    residueName = "THY";
                    residue.setName(residueName);
                    break;
                default:
            }
        }
        /**
         * Set a position flag.
         */
        ResiduePosition position = MIDDLE_RESIDUE;
        if (residueNumber == 0) {
            position = FIRST_RESIDUE;
        } else if (residueNumber == numberOfResidues - 1) {
            position = LAST_RESIDUE;
        }
        /**
         * Build the phosphate atoms of the current residue.
         */
        Atom phosphate = null;
        Atom O5s = null;
        if (position == FIRST_RESIDUE) {
            /**
             * The 5' O5' oxygen of the nucleic acid is generally terminated
             * by 1.) A phosphate group PO3 (-3). 2.) A hydrogen.
             *
             * If the base has phosphate atom we will assume a PO3 group.
             */
            phosphate = (Atom) residue.getAtomNode("P");
            if (phosphate != null) {
                if (isDNA) {
                    phosphate = buildHeavy(residue, "P", null, 1247);
                    buildHeavy(residue, "OP1", phosphate, 1248);
                    buildHeavy(residue, "OP2", phosphate, 1248);
                    buildHeavy(residue, "OP3", phosphate, 1248);
                    O5s = buildHeavy(residue, "O5\'", phosphate, 1246);
                } else {
                    phosphate = buildHeavy(residue, "P", null, 1235);
                    buildHeavy(residue, "OP1", phosphate, 1236);
                    buildHeavy(residue, "OP2", phosphate, 1236);
                    buildHeavy(residue, "OP3", phosphate, 1236);
                    O5s = buildHeavy(residue, "O5\'", phosphate, 1234);
                }
            } else if (isDNA) {
                O5s = buildHeavy(residue, "O5\'", phosphate, 1244);
            } else {
                O5s = buildHeavy(residue, "O5\'", phosphate, 1232);
            }
        } else {
            phosphate = buildHeavy(residue, "P", pO3s, NA_P[naNumber]);
            buildHeavy(residue, "OP1", phosphate, NA_OP[naNumber]);
            buildHeavy(residue, "OP2", phosphate, NA_OP[naNumber]);
            O5s = buildHeavy(residue, "O5\'", phosphate, NA_O5[naNumber]);
        }
        /**
         * Build the ribose sugar atoms of the current base.
         */
        Atom C5s = buildHeavy(residue, "C5\'", O5s, NA_C5[naNumber]);
        Atom C4s = buildHeavy(residue, "C4\'", C5s, NA_C4[naNumber]);
        Atom O4s = buildHeavy(residue, "O4\'", C4s, NA_O4[naNumber]);
        Atom C1s = buildHeavy(residue, "C1\'", O4s, NA_C1[naNumber]);
        Atom C3s = buildHeavy(residue, "C3\'", C4s, NA_C3[naNumber]);
        Atom C2s = buildHeavy(residue, "C2\'", C3s, NA_C2[naNumber]);
        buildBond(C2s, C1s);
        Atom O3s = null;
        if (position == LAST_RESIDUE || numberOfResidues == 1) {
            if (isDNA) {
                O3s = buildHeavy(residue, "O3\'", C3s, 1249);
            } else {
                O3s = buildHeavy(residue, "O3\'", C3s, 1237);
            }
        } else {
            O3s = buildHeavy(residue, "O3\'", C3s, NA_O3[naNumber]);
        }
        if (!isDNA) {
            O2s = buildHeavy(residue, "O2\'", C2s, NA_O2[naNumber]);
        }
        /**
         * Build the backbone hydrogen atoms.
         */
        if (position == FIRST_RESIDUE && phosphate == null) {
            buildHydrogen(residue, "H5T", O5s, 1.00e0, C5s, 109.5e0, C4s, 180.0e0, 0, NA_H5T[naNumber]);
        }
        buildHydrogen(residue, "H5\'1", C5s, 1.09e0, O5s, 109.5e0, C4s, 109.5e0, 1, NA_H51[naNumber]);
        buildHydrogen(residue, "H5\'2", C5s, 1.09e0, O5s, 109.5e0, C4s, 109.5e0, -1, NA_H52[naNumber]);
        buildHydrogen(residue, "H4\'", C4s, 1.09e0, C5s, 109.5e0, C3s, 109.5e0, -1, NA_H4[naNumber]);
        buildHydrogen(residue, "H3\'", C3s, 1.09e0, C4s, 109.5e0, C2s, 109.5e0, -1, NA_H3[naNumber]);
        if (isDNA) {
            buildHydrogen(residue, "H2\'1", C2s, 1.09e0, C3s, 109.5e0, C1s, 109.5e0, -1, NA_H21[naNumber]);
            buildHydrogen(residue, "H2\'2", C2s, 1.09e0, C3s, 109.5e0, C1s, 109.5e0, 1, NA_H22[naNumber]);
        } else {
            buildHydrogen(residue, "H2\'", C2s, 1.09e0, C3s, 109.5e0, C1s, 109.5e0, -1, NA_H21[naNumber]);
            // Add the NA_O2' Methyl for OMC and OMG
            if (nucleicAcid == NucleicAcid3.OMC || nucleicAcid == NucleicAcid3.OMG) {
                Atom CM2 = buildHeavy(residue, "CM2", O2s, 1427);
                Atom HM21 = buildHydrogen(residue, "HM21", CM2, 1.08e0, O2s, 109.5e0, C2s, 0.0e0, 0, 1428);
                buildHydrogen(residue, "HM22", CM2, 1.08e0, O2s, 109.5e0, HM21, 109.5e0, 1, 1429);
                buildHydrogen(residue, "HM23", CM2, 1.08e0, O2s, 109.5e0, HM21, 109.5e0, -1, 1430);
            } else {
                buildHydrogen(residue, "HO\'", O2s, 1.00e0, C2s, 109.5e0, C3s, 180.0e0, 0, NA_H22[naNumber]);
            }
        }
        buildHydrogen(residue, "H1\'", C1s, 1.09e0, O4s, 109.5e0, C2s, 109.5e0, -1, NA_H1[naNumber]);
        if (position == LAST_RESIDUE || numberOfResidues == 1) {
            buildHydrogen(residue, "H3T", O3s, 1.00e0, C3s, 109.5e0, C4s, 180.0e0, 0, NA_H3T[naNumber]);
        // Else, if it is terminated by a 3' phosphate cap:
        // Will need to see how PDB would label a 3' phosphate cap.
        }
        /**
         * Build the nucleic acid base.
         */
        try {
            assignNucleicAcidBaseAtomTypes(nucleicAcid, residue, C1s, O4s, C2s);
        } catch (MissingHeavyAtomException missingHeavyAtomException) {
            logger.throwing(PDBFilter.class.getName(), "assignNucleicAcidAtomTypes", missingHeavyAtomException);
            throw missingHeavyAtomException;
        }
        /**
         * Do some checks on the current base to make sure all atoms have
         * been assigned an atom type.
         */
        resAtoms = residue.getAtomList();
        for (Atom atom : resAtoms) {
            AtomType atomType = atom.getAtomType();
            if (atomType == null) {
                MissingAtomTypeException missingAtomTypeException = new MissingAtomTypeException(residue, atom);
                logger.throwing(PDBFilter.class.getName(), "assignNucleicAcidAtomTypes", missingAtomTypeException);
                throw missingAtomTypeException;
            }
            int numberOfBonds = atom.getNumBonds();
            if (numberOfBonds != atomType.valence) {
                if (atom == O3s && numberOfBonds == atomType.valence - 1 && position != LAST_RESIDUE && numberOfResidues != 1) {
                    continue;
                }
                logger.log(Level.WARNING, format(" An atom for residue %s has the wrong number of bonds:\n %s", residueName, atom.toString()));
                logger.log(Level.WARNING, format(" Expected: %d Actual: %d.", atomType.valence, numberOfBonds));
            }
        }
        /**
         * Save a reference to the current O3* oxygen.
         */
        pO3s = O3s;
    }
}
Also used : ResiduePosition(ffx.potential.bonded.Residue.ResiduePosition) MissingAtomTypeException(ffx.potential.bonded.BondedUtils.MissingAtomTypeException) Residue(ffx.potential.bonded.Residue) NucleicAcid3(ffx.potential.bonded.ResidueEnumerations.NucleicAcid3) AtomType(ffx.potential.parameters.AtomType) MissingHeavyAtomException(ffx.potential.bonded.BondedUtils.MissingHeavyAtomException) Atom(ffx.potential.bonded.Atom)

Example 3 with ResiduePosition

use of ffx.potential.bonded.Residue.ResiduePosition in project ffx by mjschnie.

the class BiojavaFilter method assignAminoAcidAtomTypes.

private void assignAminoAcidAtomTypes(Residue residue, Residue previousResidue, Residue nextResidue) throws MissingHeavyAtomException, MissingAtomTypeException {
    String residueName = residue.getName().toUpperCase();
    int j = 1;
    ResiduePosition position = MIDDLE_RESIDUE;
    if (previousResidue == null) {
        j = 0;
        position = FIRST_RESIDUE;
    } else if (nextResidue == null) {
        j = 2;
        position = LAST_RESIDUE;
        /**
         * If the last residue only contains a nitrogen turn it into an NH2
         * group.
         */
        Atom N = (Atom) residue.getAtomNode("N");
        if (residue.getAtomNodeList().size() == 1 && N != null) {
            residueName = "NH2".intern();
            residue.setName(residueName);
        }
    }
    AminoAcid3 aminoAcid = getAminoAcid(residueName);
    int aminoAcidNumber = getAminoAcidNumber(residueName);
    /**
     * Non-standard Amino Acid; use ALA backbone types.
     */
    boolean nonStandard = false;
    if (aminoAcid == AminoAcid3.UNK) {
        aminoAcidNumber = getAminoAcidNumber("ALA");
        nonStandard = true;
    }
    /**
     * Only the last residue in a chain should have an OXT/OT2 atom.
     */
    if (nextResidue != null) {
        removeOXT_OT2(residue);
    }
    /**
     * Only the first nitrogen should have H1, H2 and H3 atoms, unless it's
     * an NME cap.
     */
    if (previousResidue != null) {
        removeH1_H2_H3(aminoAcid, residue);
    }
    /**
     * Check for missing heavy atoms. This check ignores special terminating
     * groups like FOR, NH2, etc.
     */
    if (!nonStandard) {
        try {
            checkForMissingHeavyAtoms(aminoAcidNumber, aminoAcid, position, residue);
        } catch (MissingHeavyAtomException e) {
            logger.log(Level.INFO, " {0} could not be parsed.", residue.toString());
            throw e;
        }
    }
    Atom pC = null;
    Atom pCA = null;
    if (previousResidue != null) {
        pC = (Atom) previousResidue.getAtomNode("C");
        pCA = (Atom) previousResidue.getAtomNode("CA");
    }
    /**
     * Backbone heavy atoms.
     */
    Atom N = (Atom) residue.getAtomNode("N");
    if (N != null) {
        N.setAtomType(findAtomType(AA_N[j][aminoAcidNumber]));
        if (position != FIRST_RESIDUE) {
            buildBond(pC, N);
        }
    }
    Atom CA = null;
    Atom C = null;
    Atom O = null;
    if (!(position == LAST_RESIDUE && aminoAcid == AminoAcid3.NH2)) {
        if (aminoAcid == AminoAcid3.ACE || aminoAcid == AminoAcid3.NME) {
            CA = buildHeavy(residue, "CH3", N, AA_CA[j][aminoAcidNumber]);
        } else {
            CA = buildHeavy(residue, "CA", N, AA_CA[j][aminoAcidNumber]);
        }
        if (!(position == LAST_RESIDUE && aminoAcid == AminoAcid3.NME)) {
            C = buildHeavy(residue, "C", CA, AA_C[j][aminoAcidNumber]);
            O = (Atom) residue.getAtomNode("O");
            if (O == null) {
                O = (Atom) residue.getAtomNode("OT1");
            }
            AtomType atomType = findAtomType(AA_O[j][aminoAcidNumber]);
            if (O == null) {
                MissingHeavyAtomException missingHeavyAtom = new MissingHeavyAtomException("O", atomType, C);
                throw missingHeavyAtom;
            }
            O.setAtomType(atomType);
            buildBond(C, O);
        }
    }
    /**
     * Nitrogen hydrogen atoms.
     */
    AtomType atomType = findAtomType(AA_HN[j][aminoAcidNumber]);
    switch(position) {
        case FIRST_RESIDUE:
            switch(aminoAcid) {
                case PRO:
                    buildHydrogenAtom(residue, "H2", N, 1.02, CA, 109.5, C, 0.0, 0, atomType);
                    buildHydrogenAtom(residue, "H3", N, 1.02, CA, 109.5, C, -120.0, 0, atomType);
                    break;
                case PCA:
                    buildHydrogenAtom(residue, "H", N, 1.02, CA, 109.5, C, -60.0, 0, atomType);
                    break;
                case ACE:
                    break;
                default:
                    buildHydrogenAtom(residue, "H1", N, 1.02, CA, 109.5, C, 180.0, 0, atomType);
                    buildHydrogenAtom(residue, "H2", N, 1.02, CA, 109.5, C, 60.0, 0, atomType);
                    buildHydrogenAtom(residue, "H3", N, 1.02, CA, 109.5, C, -60.0, 0, atomType);
            }
            break;
        case LAST_RESIDUE:
            switch(aminoAcid) {
                case NH2:
                    buildHydrogenAtom(residue, "H1", N, 1.02, pC, 119.0, pCA, 0.0, 0, atomType);
                    buildHydrogenAtom(residue, "H2", N, 1.02, pC, 119.0, pCA, 180.0, 0, atomType);
                    break;
                case NME:
                    buildHydrogenAtom(residue, "H", N, 1.02, pC, 118.0, CA, 121.0, 1, atomType);
                    break;
                default:
                    buildHydrogenAtom(residue, "H", N, 1.02, pC, 119.0, CA, 119.0, 1, atomType);
            }
            break;
        default:
            // Mid-chain nitrogen hydrogen.
            buildHydrogenAtom(residue, "H", N, 1.02, pC, 119.0, CA, 119.0, 1, atomType);
    }
    /**
     * C-alpha hydrogen atoms.
     */
    String haName = "HA";
    if (aminoAcid == AminoAcid3.GLY) {
        haName = "HA2";
    }
    atomType = findAtomType(AA_HA[j][aminoAcidNumber]);
    switch(position) {
        case FIRST_RESIDUE:
            switch(aminoAcid) {
                case FOR:
                    buildHydrogenAtom(residue, "H", C, 1.12, O, 0.0, null, 0.0, 0, atomType);
                    break;
                case ACE:
                    buildHydrogenAtom(residue, "H1", CA, 1.10, C, 109.5, O, 180.0, 0, atomType);
                    buildHydrogenAtom(residue, "H2", CA, 1.10, C, 109.5, O, 60.0, 0, atomType);
                    buildHydrogenAtom(residue, "H3", CA, 1.10, C, 109.5, O, -60.0, 0, atomType);
                    break;
                default:
                    buildHydrogenAtom(residue, haName, CA, 1.10, N, 109.5, C, 109.5, -1, atomType);
                    break;
            }
            break;
        case LAST_RESIDUE:
            switch(aminoAcid) {
                case NME:
                    buildHydrogenAtom(residue, "H1", CA, 1.10, N, 109.5, pC, 180.0, 0, atomType);
                    buildHydrogenAtom(residue, "H2", CA, 1.10, N, 109.5, pC, 60.0, 0, atomType);
                    buildHydrogenAtom(residue, "H3", CA, 1.10, N, 109.5, pC, -60.0, 0, atomType);
                    break;
                default:
                    buildHydrogenAtom(residue, haName, CA, 1.10, N, 109.5, C, 109.5, -1, atomType);
            }
            break;
        default:
            buildHydrogenAtom(residue, haName, CA, 1.10, N, 109.5, C, 109.0, -1, atomType);
    }
    /**
     * Build the amino acid side chain.
     */
    assignAminoAcidSideChain(position, aminoAcid, residue, CA, N, C);
    /**
     * Build the terminal oxygen if the residue is not NH2 or NME.
     */
    if (position == LAST_RESIDUE && !(aminoAcid == AminoAcid3.NH2 || aminoAcid == AminoAcid3.NME)) {
        atomType = findAtomType(AA_O[2][aminoAcidNumber]);
        Atom OXT = (Atom) residue.getAtomNode("OXT");
        if (OXT == null) {
            OXT = (Atom) residue.getAtomNode("OT2");
            if (OXT != null) {
                OXT.setName("OXT");
            }
        }
        if (OXT == null) {
            String resName = C.getResidueName();
            int resSeq = C.getResidueNumber();
            Character chainID = C.getChainID();
            Character altLoc = C.getAltLoc();
            String segID = C.getSegID();
            double occupancy = C.getOccupancy();
            double tempFactor = C.getTempFactor();
            OXT = new Atom(0, "OXT", altLoc, new double[3], resName, resSeq, chainID, occupancy, tempFactor, segID);
            OXT.setAtomType(atomType);
            residue.addMSNode(OXT);
            intxyz(OXT, C, 1.25, CA, 117.0, O, 126.0, 1);
        } else {
            OXT.setAtomType(atomType);
        }
        buildBond(C, OXT);
    }
    /**
     * Do some checks on the current residue to make sure all atoms have
     * been assigned an atom type.
     */
    List<Atom> resAtoms = residue.getAtomList();
    for (Atom atom : resAtoms) {
        atomType = atom.getAtomType();
        if (atomType == null) {
            MissingAtomTypeException missingAtomTypeException = new MissingAtomTypeException(residue, atom);
            throw missingAtomTypeException;
        }
        int numberOfBonds = atom.getNumBonds();
        if (numberOfBonds != atomType.valence) {
            if (atom == C && numberOfBonds == atomType.valence - 1 && position != LAST_RESIDUE) {
                continue;
            }
            logger.warning(format(" An atom for residue %s has the wrong number of bonds:\n %s", residueName, atom.toString()));
            logger.warning(format(" Expected: %d Actual: %d.", atomType.valence, numberOfBonds));
        }
    }
}
Also used : ResiduePosition(ffx.potential.bonded.Residue.ResiduePosition) MissingAtomTypeException(ffx.potential.bonded.BondedUtils.MissingAtomTypeException) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) AtomType(ffx.potential.parameters.AtomType) MissingHeavyAtomException(ffx.potential.bonded.BondedUtils.MissingHeavyAtomException) Atom(ffx.potential.bonded.Atom)

Example 4 with ResiduePosition

use of ffx.potential.bonded.Residue.ResiduePosition in project ffx by mjschnie.

the class MolecularAssembly method getResiduePosition.

public ResiduePosition getResiduePosition(int residueNumber) {
    ResiduePosition position;
    int numberOfResidues = 0;
    Polymer[] polymers = getChains();
    int nPolymers = polymers.length;
    for (int i = 0; i < nPolymers; i++) {
        Polymer polymer = polymers[i];
        ArrayList<Residue> residues = polymer.getResidues();
        numberOfResidues += residues.size();
    }
    if (residueNumber == 0) {
        position = FIRST_RESIDUE;
    } else if (residueNumber == numberOfResidues - 1) {
        position = LAST_RESIDUE;
    } else {
        position = MIDDLE_RESIDUE;
    }
    return position;
}
Also used : ResiduePosition(ffx.potential.bonded.Residue.ResiduePosition) Residue(ffx.potential.bonded.Residue) Polymer(ffx.potential.bonded.Polymer)

Aggregations

ResiduePosition (ffx.potential.bonded.Residue.ResiduePosition)4 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)3 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)3 AtomType (ffx.potential.parameters.AtomType)3 Atom (ffx.potential.bonded.Atom)2 Residue (ffx.potential.bonded.Residue)2 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)2 BondedUtils.buildHydrogenAtom (ffx.potential.bonded.BondedUtils.buildHydrogenAtom)1 BondedUtils.findAtomType (ffx.potential.bonded.BondedUtils.findAtomType)1 Polymer (ffx.potential.bonded.Polymer)1 NucleicAcid3 (ffx.potential.bonded.ResidueEnumerations.NucleicAcid3)1