use of ffx.potential.bonded.Bond in project ffx by mjschnie.
the class SimulationFilter method readFile.
/**
* {@inheritDoc}
*/
@Override
public boolean readFile() {
// information
for (int i = 0; i < system.numatoms; i++) {
AtomType atomType = atomTypes.get(system.types[i]);
if (atomType == null) {
atomType = new AtomType(system.types[i], -1, system.name[i], system.story[i], system.atomic[i], system.mass[i], 0);
atomTypes.put(system.types[i], atomType);
}
}
atomList = new ArrayList<Atom>();
Vector<Integer> bonds1 = new Vector<Integer>();
Vector<Integer> bonds2 = new Vector<Integer>();
double[] d = new double[3];
int[] b = new int[4];
for (int i = 0; i < system.numatoms; i++) {
d[0] = system.coordinates[0][i];
d[1] = system.coordinates[1][i];
d[2] = system.coordinates[2][i];
String s = new String("" + system.types[i]);
AtomType atomType = atomTypes.get(s);
Atom a = new Atom(i + 1, new String("" + atomType.type), atomType, d);
atomList.add(a);
int b1 = i + 1;
b[0] = system.connectivity[0][i];
b[1] = system.connectivity[1][i];
b[2] = system.connectivity[2][i];
b[3] = system.connectivity[3][i];
int j = 0;
while (j < 4 && b[j] != 0) {
int b2 = b[j];
bonds1.add(b1);
bonds2.add(b2);
j++;
}
}
bondList = new ArrayList<Bond>();
for (int i = 0; i < bonds1.size(); i++) {
int a1 = bonds1.get(i);
int a2 = bonds2.get(i);
if (a1 < a2) {
Atom atom1 = atomList.get(a1 - 1);
Atom atom2 = atomList.get(a2 - 1);
bondList.add(new Bond(atom1, atom2));
}
}
setFileRead(true);
return true;
}
use of ffx.potential.bonded.Bond in project ffx by mjschnie.
the class ForceFieldEnergyOpenMM method setUpHydrogenConstraints.
public void setUpHydrogenConstraints(PointerByReference system) {
int i;
int iAtom1;
int iAtom2;
// Atom[] atoms = molecularAssembly.getAtomArray();
Bond[] bonds = super.getBonds();
logger.info(String.format(" Setting up Hydrogen constraints"));
if (bonds == null || bonds.length < 1) {
return;
}
int nBonds = bonds.length;
Atom atom1;
Atom atom2;
Atom parentAtom;
Bond bondForBondLength;
BondType bondType;
for (i = 0; i < nBonds; i++) {
Bond bond = bonds[i];
atom1 = bond.getAtom(0);
atom2 = bond.getAtom(1);
if (atom1.isHydrogen()) {
parentAtom = atom1.getBonds().get(0).get1_2(atom1);
bondForBondLength = atom1.getBonds().get(0);
bondType = bondForBondLength.bondType;
iAtom1 = atom1.getXyzIndex() - 1;
iAtom2 = parentAtom.getXyzIndex() - 1;
OpenMM_System_addConstraint(system, iAtom1, iAtom2, bondForBondLength.bondType.distance * OpenMM_NmPerAngstrom);
} else if (atom2.isHydrogen()) {
parentAtom = atom2.getBonds().get(0).get1_2(atom2);
bondForBondLength = atom2.getBonds().get(0);
bondType = bondForBondLength.bondType;
iAtom1 = atom2.getXyzIndex() - 1;
iAtom2 = parentAtom.getXyzIndex() - 1;
OpenMM_System_addConstraint(system, iAtom1, iAtom2, bondForBondLength.bondType.distance * OpenMM_NmPerAngstrom);
}
}
}
use of ffx.potential.bonded.Bond in project ffx by mjschnie.
the class ForceFieldEnergyOpenMM method addBondForce.
private void addBondForce() {
Bond[] bonds = super.getBonds();
if (bonds == null || bonds.length < 1) {
return;
}
int nBonds = bonds.length;
amoebaBondForce = OpenMM_AmoebaBondForce_create();
double kParameterConversion = OpenMM_KJPerKcal / (OpenMM_NmPerAngstrom * OpenMM_NmPerAngstrom);
for (int i = 0; i < nBonds; i++) {
Bond bond = bonds[i];
int i1 = bond.getAtom(0).getXyzIndex() - 1;
int i2 = bond.getAtom(1).getXyzIndex() - 1;
BondType bondType = bond.bondType;
OpenMM_AmoebaBondForce_addBond(amoebaBondForce, i1, i2, bond.bondType.distance * OpenMM_NmPerAngstrom, kParameterConversion * bondType.forceConstant * BondType.units);
}
if (bonds[0].bondType.bondFunction == BondFunction.QUARTIC) {
OpenMM_AmoebaBondForce_setAmoebaGlobalBondCubic(amoebaBondForce, BondType.cubic / OpenMM_NmPerAngstrom);
OpenMM_AmoebaBondForce_setAmoebaGlobalBondQuartic(amoebaBondForce, BondType.quartic / (OpenMM_NmPerAngstrom * OpenMM_NmPerAngstrom));
}
OpenMM_System_addForce(system, amoebaBondForce);
logger.log(Level.INFO, " Added bonds ({0})", nBonds);
}
use of ffx.potential.bonded.Bond in project ffx by mjschnie.
the class Utilities method addPhosphate.
/**
* Add a phosphate and its bonded oxygens that are not bonded to a carbon to
* the specified residue.
*
* @param phosphate Atom
* @param residue Residue
*/
public static void addPhosphate(Atom phosphate, Residue residue) {
if (phosphate == null) {
return;
}
residue.addMSNode(phosphate);
for (Bond b : phosphate.getBonds()) {
Atom oxygen = b.get1_2(phosphate);
// Add oxygens not bonded to a Carbon
if (numberOfBondsWith(oxygen, 6) == 0) {
residue.addMSNode(oxygen);
// Add hydrogens atoms for protonated oxygen groups
Atom hydrogen = findBondWith(oxygen, 1);
if (hydrogen != null) {
residue.addMSNode(hydrogen);
}
}
}
}
use of ffx.potential.bonded.Bond in project ffx by mjschnie.
the class Utilities method biochemistry.
/**
* This routine sub-divides a system into groups of ions, water, hetero
* molecules, and polynucleotides/polypeptides.
*
* @param molecularAssembly a {@link ffx.potential.MolecularAssembly}
* object.
* @param atoms a {@link java.util.List} object.
*/
public static void biochemistry(MolecularAssembly molecularAssembly, List<Atom> atoms) {
Atom atom, seed = null;
int num = 0;
int waterNum = 0;
int ionNum = 0;
int moleculeNum = 0;
List<String> segIDs = new ArrayList<>();
while (atoms.size() > 0) {
/**
* Nitrogen is used to "seed" a backbone search because carbon can
* be separated from the backbone by a sulfur (ie. MET).
*/
for (Atom a : atoms) {
seed = a;
if (seed.getAtomicNumber() == 7) {
break;
}
}
/**
* If no nitrogen atoms remain, there are no nucleic or amino acids.
*/
if (seed.getAtomicNumber() != 7) {
List<Atom> moleculeAtoms;
while (atoms.size() > 0) {
atom = atoms.get(0);
// Check for a metal ion or noble gas
if (atom.getNumBonds() == 0) {
ionNum++;
Molecule ion = new Molecule(atom.getName() + "-" + ionNum);
ion.addMSNode(atom);
atoms.remove(0);
molecularAssembly.addMSNode(ion);
continue;
} else // Check for water
if (atom.getAtomicNumber() == 8 && isWaterOxygen(atom)) {
waterNum++;
Molecule water = new Molecule("Water-" + waterNum);
water.addMSNode(atom);
atoms.remove(0);
List<Bond> bonds = atom.getBonds();
for (Bond b : bonds) {
Atom hydrogen = b.get1_2(atom);
water.addMSNode(hydrogen);
atoms.remove(hydrogen);
}
molecularAssembly.addMSNode(water);
continue;
}
// Otherwise classify the molecule as a hetero
moleculeNum++;
Molecule molecule = new Molecule("Molecule-" + moleculeNum);
moleculeAtoms = getAtomListFromPool();
collectAtoms(atoms.get(0), moleculeAtoms);
while (moleculeAtoms.size() > 0) {
atom = moleculeAtoms.get(0);
moleculeAtoms.remove(0);
molecule.addMSNode(atom);
atoms.remove(atom);
}
molecularAssembly.addMSNode(molecule);
}
seed = null;
break;
}
List<Atom> backbone = findPolymer(atoms, seed, null);
if (backbone.size() > 0) {
for (ListIterator li = backbone.listIterator(backbone.size()); li.hasPrevious(); ) {
seed = (Atom) li.previous();
if (seed.getAtomicNumber() == 7) {
break;
}
}
backbone = findPolymer(atoms, seed, null);
}
Character chainID = getChainID(num);
String segID = getSegID(chainID, segIDs);
Polymer c = new Polymer(chainID, segID, true);
if (backbone.size() > 2 && divideBackbone(backbone, c)) {
for (Atom a : c.getAtomList()) {
atoms.remove(a);
}
logger.fine(" Sequenced chain: " + c.getName());
molecularAssembly.addMSNode(c);
num++;
} else {
moleculeNum++;
Molecule hetero = new Molecule("" + moleculeNum + "-Hetero");
atom = backbone.get(0);
List<Atom> heteroAtomList = getAtomListFromPool();
collectAtoms(atom, heteroAtomList);
for (Atom a : heteroAtomList) {
hetero.addMSNode(a);
}
for (Atom a : hetero.getAtomList()) {
atoms.remove(a);
}
molecularAssembly.addMSNode(hetero);
}
}
}
Aggregations