Search in sources :

Example 91 with Residue

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

the class XRayEnergy method setOccupancies.

/**
 * set atom occupancies based on current position
 *
 * @param x current parameters to set occupancies with
 */
public void setOccupancies(double[] x) {
    double occ = 0.0;
    int index = nXYZ + nB;
    for (ArrayList<Residue> list : refinementModel.getAltResidues()) {
        for (Residue r : list) {
            occ = x[index++];
            for (Atom a : r.getAtomList()) {
                if (a.getOccupancy() < 1.0) {
                    a.setOccupancy(occ);
                }
            }
        }
    }
    for (ArrayList<Molecule> list : refinementModel.getAltMolecules()) {
        for (Molecule m : list) {
            occ = x[index++];
            for (Atom a : m.getAtomList()) {
                if (a.getOccupancy() < 1.0) {
                    a.setOccupancy(occ);
                }
            }
        }
    }
}
Also used : Molecule(ffx.potential.bonded.Molecule) Residue(ffx.potential.bonded.Residue) Atom(ffx.potential.bonded.Atom)

Example 92 with Residue

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

the class PDBFilter method numberAtoms.

/**
 * <p>
 * numberAtoms</p>
 */
private void numberAtoms() {
    int index = 1;
    for (Atom a : activeMolecularAssembly.getAtomArray()) {
        a.setXyzIndex(index++);
    }
    index--;
    if (logger.isLoggable(Level.INFO)) {
        logger.info(String.format(" Total number of atoms: %d\n", index));
    }
    Polymer[] polymers = activeMolecularAssembly.getChains();
    if (polymers != null) {
        for (Polymer p : polymers) {
            List<Residue> residues = p.getResidues();
            for (Residue r : residues) {
                r.reOrderAtoms();
            }
        }
    }
    List<Molecule> molecules = activeMolecularAssembly.getMolecules();
    for (Molecule n : molecules) {
        n.reOrderAtoms();
    }
    List<MSNode> waters = activeMolecularAssembly.getWaters();
    for (MSNode n : waters) {
        MSGroup m = (MSGroup) n;
        m.reOrderAtoms();
    }
    List<MSNode> ions = activeMolecularAssembly.getIons();
    for (MSNode n : ions) {
        MSGroup m = (MSGroup) n;
        m.reOrderAtoms();
    }
}
Also used : Molecule(ffx.potential.bonded.Molecule) MSNode(ffx.potential.bonded.MSNode) Residue(ffx.potential.bonded.Residue) Polymer(ffx.potential.bonded.Polymer) MSGroup(ffx.potential.bonded.MSGroup) Atom(ffx.potential.bonded.Atom)

Example 93 with Residue

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

the class PDBFilter method findChainBreaks.

private List<List<Residue>> findChainBreaks(List<Residue> residues, double cutoff) {
    List<List<Residue>> subChains = new ArrayList<List<Residue>>();
    List<Residue> subChain = null;
    Residue previousResidue = null;
    Atom pC = null;
    StringBuilder sb = new StringBuilder(" Chain Breaks:");
    for (Residue residue : residues) {
        List<Atom> resAtoms = residue.getAtomList();
        if (pC == null) {
            /**
             * Initialization.
             */
            subChain = new ArrayList<Residue>();
            subChain.add(residue);
            subChains.add(subChain);
        } else {
            /**
             * Find the Nitrogen of the current residue.
             */
            Atom N = null;
            for (Atom a : resAtoms) {
                if (a.getName().equalsIgnoreCase("N")) {
                    N = a;
                    break;
                }
            }
            if (N == null) {
                subChain.add(residue);
                continue;
            }
            /**
             * Compute the distance between the previous carbonyl carbon and
             * the current nitrogen.
             */
            double r = VectorMath.dist(pC.getXYZ(null), N.getXYZ(null));
            if (r > cutoff) {
                /**
                 * Start a new chain.
                 */
                subChain = new ArrayList<Residue>();
                subChain.add(residue);
                subChains.add(subChain);
                char ch1 = previousResidue.getChainID();
                char ch2 = residue.getChainID();
                sb.append(format("\n C-N distance of %6.2f A for %c-%s and %c-%s.", r, ch1, previousResidue.toString(), ch2, residue.toString()));
            } else {
                /**
                 * Continue the current chain.
                 */
                subChain.add(residue);
            }
        }
        /**
         * Save the carbonyl carbon.
         */
        for (Atom a : resAtoms) {
            if (a.getName().equalsIgnoreCase("C")) {
                pC = a;
                break;
            }
        }
        previousResidue = residue;
    }
    if (subChains.size() > 1) {
        logger.info(sb.toString());
    }
    return subChains;
}
Also used : Residue(ffx.potential.bonded.Residue) ArrayList(java.util.ArrayList) ResidueEnumerations.nucleicAcidList(ffx.potential.bonded.ResidueEnumerations.nucleicAcidList) ResidueEnumerations.aminoAcidList(ffx.potential.bonded.ResidueEnumerations.aminoAcidList) List(java.util.List) ArrayList(java.util.ArrayList) Atom(ffx.potential.bonded.Atom)

Example 94 with Residue

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

the class PDBFilter method buildMissingResidues.

/**
 * Currently builds missing internal loops based on information in DBREF and
 * SEQRES records.
 *
 * Known limitations include: 1) No building n- and c-terminal loops. 2) No
 * support for DBREF1 or DBREF2 records. 3) Incomplete optimization scheme
 * to position the loops.
 *
 * @param xyzIndex
 *
 * @return xyzIndex updated based on built atoms.
 */
private int buildMissingResidues(int xyzIndex) {
    /**
     * Only build loops if the buildLoops flag is true.
     */
    if (!properties.getBoolean("buildLoops", false)) {
        return xyzIndex;
    }
    Polymer[] polymers = activeMolecularAssembly.getChains();
    for (Polymer polymer : polymers) {
        Character chainID = polymer.getChainID();
        String[] resNames = seqres.get(chainID);
        int[] seqRange = dbref.get(chainID);
        if (resNames == null || seqRange == null) {
            continue;
        }
        int seqBegin = seqRange[0];
        int seqEnd = seqRange[1];
        logger.info(format("\n Checking for missing residues in chain %s between residues %d and %d.", polymer.toString(), seqBegin, seqEnd));
        int firstResID = polymer.getFirstResidue().getResidueNumber();
        for (int i = 0; i < resNames.length; i++) {
            int currentID = seqBegin + i;
            Residue currentResidue = polymer.getResidue(currentID);
            if (currentResidue != null) {
                continue;
            }
            if (currentID <= firstResID) {
                logger.info(format(" Residue %d is missing, but is at the beginning of the chain.", currentID));
                continue;
            }
            Residue previousResidue = polymer.getResidue(currentID - 1);
            if (previousResidue == null) {
                logger.info(format(" Residue %d is missing, but could not be build (previous residue missing).", currentID));
                continue;
            }
            Residue nextResidue = null;
            for (int j = currentID + 1; j <= seqEnd; j++) {
                nextResidue = polymer.getResidue(j);
                if (nextResidue != null) {
                    break;
                }
            }
            /**
             * Residues at the end of the chain are not currently built.
             */
            if (nextResidue == null) {
                logger.info(format(" Residue %d is missing, but is at the end of the chain.", currentID));
                break;
            }
            /**
             * Find the previous carbonyl carbon and next nitrogen.
             */
            Atom C = (Atom) previousResidue.getAtomNode("C");
            Atom N = (Atom) nextResidue.getAtomNode("N");
            if (C == null || N == null) {
                logger.info(format(" Residue %d is missing, but bonding atoms are missing (C or N).", currentID));
                continue;
            }
            /**
             * Build the missing residue.
             */
            currentResidue = polymer.getResidue(resNames[i], currentID, true);
            double[] vector = new double[3];
            int count = 3 * (nextResidue.getResidueNumber() - previousResidue.getResidueNumber());
            VectorMath.diff(N.getXYZ(null), C.getXYZ(null), vector);
            VectorMath.scalar(vector, 1.0 / count, vector);
            double[] nXYZ = new double[3];
            VectorMath.sum(C.getXYZ(null), vector, nXYZ);
            nXYZ[0] += Math.random() - 0.5;
            nXYZ[1] += Math.random() - 0.5;
            nXYZ[2] += Math.random() - 0.5;
            Atom newN = new Atom(xyzIndex++, "N", C.getAltLoc(), nXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
            currentResidue.addMSNode(newN);
            double[] caXYZ = new double[3];
            VectorMath.scalar(vector, 2.0, vector);
            VectorMath.sum(C.getXYZ(null), vector, caXYZ);
            caXYZ[0] += Math.random() - 0.5;
            caXYZ[1] += Math.random() - 0.5;
            caXYZ[2] += Math.random() - 0.5;
            Atom newCA = new Atom(xyzIndex++, "CA", C.getAltLoc(), caXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
            currentResidue.addMSNode(newCA);
            double[] cXYZ = new double[3];
            VectorMath.scalar(vector, 1.5, vector);
            VectorMath.sum(C.getXYZ(null), vector, cXYZ);
            cXYZ[0] += Math.random() - 0.5;
            cXYZ[1] += Math.random() - 0.5;
            cXYZ[2] += Math.random() - 0.5;
            Atom newC = new Atom(xyzIndex++, "C", C.getAltLoc(), cXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
            currentResidue.addMSNode(newC);
            double[] oXYZ = new double[3];
            vector[0] = Math.random() - 0.5;
            vector[1] = Math.random() - 0.5;
            vector[2] = Math.random() - 0.5;
            VectorMath.sum(cXYZ, vector, oXYZ);
            Atom newO = new Atom(xyzIndex++, "O", C.getAltLoc(), oXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
            currentResidue.addMSNode(newO);
            logger.info(String.format(" Building residue %8s.", currentResidue.toString()));
        }
    }
    return xyzIndex;
}
Also used : Residue(ffx.potential.bonded.Residue) Polymer(ffx.potential.bonded.Polymer) Atom(ffx.potential.bonded.Atom)

Example 95 with Residue

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

the class PDBFilter method assignAminoAcidAtomTypes.

/**
 * Assign atom types to an amino acid polymer.
 *
 * @param residues The residues to assign atom types to.
 *
 * @throws ffx.potential.parsers.PDBFilter.MissingHeavyAtomException
 *
 * @since 1.0
 */
private void assignAminoAcidAtomTypes(List<Residue> residues) throws MissingHeavyAtomException, MissingAtomTypeException {
    /**
     * Loop over amino acid residues.
     */
    int numberOfResidues = residues.size();
    for (int residueNumber = 0; residueNumber < numberOfResidues; residueNumber++) {
        Residue residue = residues.get(residueNumber);
        Residue previousResidue = null;
        Residue nextResidue = null;
        if (residueNumber > 0) {
            previousResidue = residues.get(residueNumber - 1);
        }
        if (residueNumber < numberOfResidues - 1) {
            nextResidue = residues.get(residueNumber + 1);
        }
        AminoAcidUtils.assignAminoAcidAtomTypes(residue, previousResidue, nextResidue, forceField, bondList);
    }
}
Also used : Residue(ffx.potential.bonded.Residue)

Aggregations

Residue (ffx.potential.bonded.Residue)102 MultiResidue (ffx.potential.bonded.MultiResidue)66 Rotamer (ffx.potential.bonded.Rotamer)44 Atom (ffx.potential.bonded.Atom)41 RotamerLibrary.applyRotamer (ffx.potential.bonded.RotamerLibrary.applyRotamer)39 ArrayList (java.util.ArrayList)30 Polymer (ffx.potential.bonded.Polymer)29 IOException (java.io.IOException)20 Molecule (ffx.potential.bonded.Molecule)13 NACorrectionException (ffx.potential.bonded.NACorrectionException)13 MSNode (ffx.potential.bonded.MSNode)12 ResidueState (ffx.potential.bonded.ResidueState)11 Bond (ffx.potential.bonded.Bond)10 Crystal (ffx.crystal.Crystal)8 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)8 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)8 File (java.io.File)8 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)7 TitrationUtils.inactivateResidue (ffx.potential.extended.TitrationUtils.inactivateResidue)6 BufferedWriter (java.io.BufferedWriter)6