use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class MolecularAssembly method getCharge.
/**
* Sums up charge of the system, checking nonstandard residues for
* non-unitary charges.
*
* @param alwaysLog Log non-unitary charge warnings for all nodes
* @return System charge
*/
public double getCharge(boolean alwaysLog) {
double totalCharge = 0;
for (MSNode node : getNodeList()) {
double charge = 0;
boolean isNonstandard = false;
for (Atom atom : node.getAtomList()) {
charge += atom.getMultipoleType().getCharge();
if (atom.isModRes()) {
isNonstandard = true;
}
}
if ((alwaysLog || isNonstandard) && (Math.abs(Math.round(charge) - charge) > 1.0E-5)) {
logger.warning(String.format(" Node %s has non-unitary charge %12.8f", node.toString(), charge));
}
totalCharge += charge;
}
return totalCharge;
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class MolecularAssembly method getMoleculeNumbers.
/**
* This method assigns a unique integer to every molecule in the
* MolecularAssembly beginning at 0. An integer array with these values for
* each atom is returned.
*
* @return an array of molecule numbers for each atom.
*/
public int[] getMoleculeNumbers() {
int[] moleculeNumber = new int[getAtomList().size()];
int current = 0;
// Loop over polymers together
Polymer[] polymers = getChains();
if (polymers != null && polymers.length > 0) {
for (Polymer polymer : polymers) {
List<Atom> atomList = polymer.getAtomList();
for (Atom atom : atomList) {
moleculeNumber[atom.getXyzIndex() - 1] = current;
}
current++;
}
}
// Loop over each molecule
for (MSNode molecule : molecules.getChildList()) {
List<Atom> atomList = molecule.getAtomList();
for (Atom atom : atomList) {
moleculeNumber[atom.getXyzIndex() - 1] = current;
atom.setMoleculeNumber(current);
}
current++;
}
// Loop over each water
for (MSNode wat : water.getChildList()) {
List<Atom> atomList = wat.getAtomList();
for (Atom atom : atomList) {
moleculeNumber[atom.getXyzIndex() - 1] = current;
}
current++;
}
// Loop over each ion
for (MSNode ion : ions.getChildList()) {
List<Atom> atomList = ion.getAtomList();
for (Atom atom : atomList) {
moleculeNumber[atom.getXyzIndex() - 1] = current;
}
current++;
}
return moleculeNumber;
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class MolecularAssembly method getResidue.
private Atom getResidue(Atom atom, boolean create, Residue.ResidueType defaultRT) {
Character chainID = atom.getChainID();
String resName = atom.getResidueName();
int resNum = atom.getResidueNumber();
String segID = atom.getSegID();
// Find/Create the chain
Polymer polymer = getPolymer(chainID, segID, create);
if (polymer == null) {
return null;
}
Residue res = polymer.getResidue(resName, resNum, create, defaultRT);
if (create && res != null) {
return (Atom) res.addMSNode(atom);
}
return null;
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class MolecularAssembly method getActiveAtomArray.
/**
* <p>
* getActiveAtomArray</p>
*
* @return an array of active {@link ffx.potential.bonded.Atom} objects.
*/
public Atom[] getActiveAtomArray() {
ArrayList<Atom> atoms = getAtomList();
ArrayList<Atom> activeAtoms = new ArrayList<>();
for (Atom a : atoms) {
if (a.isActive()) {
activeAtoms.add(a);
}
}
Atom[] atomArray = activeAtoms.toArray(new Atom[activeAtoms.size()]);
Arrays.sort(atomArray);
return atomArray;
}
use of ffx.potential.bonded.Atom 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);
}
}
}
}
Aggregations