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;
}
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;
}
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;
}
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;
}
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++;
}
}
}
Aggregations