Search in sources :

Example 26 with Polymer

use of ffx.potential.bonded.Polymer 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)

Example 27 with Polymer

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

the class TitrationUtils method chooseTitratables.

/**
 * Choose titratables with intrinsic pKa inside (pH-window,pH+window).
 *
 * @param pH
 * @param window
 */
public static List<Residue> chooseTitratables(double pH, double window, MolecularAssembly searchMe) {
    List<Residue> chosen = new ArrayList<>();
    Polymer[] polymers = searchMe.getChains();
    for (int i = 0; i < polymers.length; i++) {
        ArrayList<Residue> residues = polymers[i].getResidues();
        for (int j = 0; j < residues.size(); j++) {
            Residue res = residues.get(j);
            Titration[] avail = Titration.multiLookup(res);
            for (Titration titration : avail) {
                double pKa = titration.pKa;
                if (pKa >= pH - window && pKa <= pH + window) {
                    chosen.add(residues.get(j));
                }
            }
        }
    }
    return chosen;
}
Also used : MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) ArrayList(java.util.ArrayList) Polymer(ffx.potential.bonded.Polymer)

Example 28 with Polymer

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

the class TitrationUtils method findResiduePolymer.

/**
 * Locate to which Polymer in a MolecularAssembly the given Residue belongs.
 */
public static Polymer findResiduePolymer(Residue residue, MolecularAssembly mola) {
    if (residue.getChainID() == null) {
        logger.severe("No chain ID for residue " + residue);
    }
    Polymer[] polymers = mola.getChains();
    Polymer location = null;
    for (Polymer p : polymers) {
        if (p.getChainID().equals(residue.getChainID())) {
            location = p;
        }
    }
    if (location == null) {
        logger.severe("Couldn't find polymer for residue " + residue);
    }
    return location;
}
Also used : Polymer(ffx.potential.bonded.Polymer)

Example 29 with Polymer

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

the class TitrationUtils method titratingMultiresidueFactory.

/**
 * Create a MultiResidue from the given Residue by adding its alternated
 * protonation state(s) as alternate possibilities.
 */
public static MultiResidue titratingMultiresidueFactory(MolecularAssembly mola, Residue res) {
    ForceField ff = mola.getForceField();
    Potential potential = mola.getPotentialEnergy();
    if (!(potential instanceof ForceFieldEnergy)) {
        logger.warning(String.format("TitrationFactory only supported by ForceFieldEnergy potentials."));
        throw new IllegalStateException();
    }
    ForceFieldEnergy ffe = (ForceFieldEnergy) potential;
    /* Create new titration state. */
    Titration titration = Titration.lookup(res);
    String targetName = (titration.protForm != res.getAminoAcid3()) ? titration.protForm.toString() : titration.deprotForm.toString();
    int resNumber = res.getResidueNumber();
    Residue.ResidueType resType = res.getResidueType();
    Residue newRes = new Residue(targetName, resNumber, resType);
    /* Wrap both states in a MultiResidue. */
    MultiResidue multiRes = new MultiResidue(res, ff, ffe);
    Polymer polymer = findResiduePolymer(res, mola);
    polymer.addMultiResidue(multiRes);
    multiRes.addResidue(newRes);
    /* Begin in protonated state by default. */
    multiRes.setActiveResidue(titration.protForm);
    propagateInactiveResidues(multiRes, false);
    ffe.reInit();
    return multiRes;
}
Also used : MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) Polymer(ffx.potential.bonded.Polymer) ForceField(ffx.potential.parameters.ForceField) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) Potential(ffx.numerics.Potential) MultiResidue(ffx.potential.bonded.MultiResidue)

Example 30 with Polymer

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

the class COMRestraint method computeCOM.

private void computeCOM(double[][] com, int nMolecules) {
    int i = 0;
    while (i < nMolecules) {
        if (polymers != null && polymers.length > 0) {
            // Find the center of mass
            for (Polymer polymer : polymers) {
                List<Atom> list = polymer.getAtomList();
                com[0][i] = 0.0;
                com[1][i] = 0.0;
                com[2][i] = 0.0;
                double totalMass = 0.0;
                for (Atom atom : list) {
                    double m = atom.getMass();
                    com[0][i] += atom.getX() * m;
                    com[1][i] += atom.getY() * m;
                    com[2][i] += atom.getZ() * m;
                    totalMass += m;
                }
                com[0][i] /= totalMass;
                com[1][i] /= totalMass;
                com[2][i] /= totalMass;
                i++;
            }
        }
        // Loop over each molecule
        for (MSNode molecule : molecules) {
            List<Atom> list = molecule.getAtomList();
            // Find the center of mass
            com[0][i] = 0.0;
            com[1][i] = 0.0;
            com[2][i] = 0.0;
            double totalMass = 0.0;
            for (Atom atom : list) {
                double m = atom.getMass();
                com[0][i] += atom.getX() * m;
                com[1][i] += atom.getY() * m;
                com[2][i] += atom.getZ() * m;
                totalMass += m;
            }
            com[0][i] /= totalMass;
            com[1][i] /= totalMass;
            com[2][i] /= totalMass;
            i++;
        }
        // Loop over each water
        for (MSNode water : waters) {
            List<Atom> list = water.getAtomList();
            // Find the center of mass
            com[0][i] = 0.0;
            com[1][i] = 0.0;
            com[2][i] = 0.0;
            double totalMass = 0.0;
            for (Atom atom : list) {
                double m = atom.getMass();
                com[0][i] += atom.getX() * m;
                com[1][i] += atom.getY() * m;
                com[2][i] += atom.getZ() * m;
                totalMass += m;
            }
            com[0][i] /= totalMass;
            com[1][i] /= totalMass;
            com[2][i] /= totalMass;
            i++;
        }
        // Loop over each ion
        for (MSNode ion : ions) {
            List<Atom> list = ion.getAtomList();
            // Find the center of mass
            com[0][i] = 0.0;
            com[1][i] = 0.0;
            com[2][i] = 0.0;
            double totalMass = 0.0;
            for (Atom atom : list) {
                double m = atom.getMass();
                com[0][i] += atom.getX() * m;
                com[1][i] += atom.getY() * m;
                com[2][i] += atom.getZ() * m;
                totalMass += m;
            }
            com[0][i] /= totalMass;
            com[1][i] /= totalMass;
            com[2][i] /= totalMass;
            i++;
        }
    }
}
Also used : MSNode(ffx.potential.bonded.MSNode) Polymer(ffx.potential.bonded.Polymer) Atom(ffx.potential.bonded.Atom)

Aggregations

Polymer (ffx.potential.bonded.Polymer)38 Residue (ffx.potential.bonded.Residue)29 Atom (ffx.potential.bonded.Atom)21 MSNode (ffx.potential.bonded.MSNode)19 ArrayList (java.util.ArrayList)14 Molecule (ffx.potential.bonded.Molecule)13 Bond (ffx.potential.bonded.Bond)10 MultiResidue (ffx.potential.bonded.MultiResidue)9 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)7 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)7 IOException (java.io.IOException)7 Crystal (ffx.crystal.Crystal)4 MolecularAssembly (ffx.potential.MolecularAssembly)4 BufferedWriter (java.io.BufferedWriter)4 File (java.io.File)4 FileWriter (java.io.FileWriter)4 SSBond (org.biojava.bio.structure.SSBond)4 MSGroup (ffx.potential.bonded.MSGroup)3 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)3 Rotamer (ffx.potential.bonded.Rotamer)3