use of ffx.potential.MolecularAssembly in project ffx by mjschnie.
the class PDBFilter method writeSIFTFile.
public boolean writeSIFTFile(File saveFile, boolean append, String[] resAndScore) {
if (saveFile == null) {
return false;
}
if (vdwH) {
logger.info(" Printing hydrogens to van der Waals centers instead of nuclear locations.");
}
if (nSymOp != 0) {
logger.info(String.format(" Printing atoms with symmetry operator %s", activeMolecularAssembly.getCrystal().spaceGroup.getSymOp(nSymOp).toString()));
}
/**
* Create StringBuilders for ATOM, ANISOU and TER records that can be
* reused.
*/
StringBuilder sb = new StringBuilder("ATOM ");
StringBuilder anisouSB = new StringBuilder("ANISOU");
StringBuilder terSB = new StringBuilder("TER ");
for (int i = 6; i < 80; i++) {
sb.append(' ');
anisouSB.append(' ');
terSB.append(' ');
}
FileWriter fw;
BufferedWriter bw;
try {
File newFile = saveFile;
if (!append && !noVersioning) {
newFile = version(saveFile);
}
activeMolecularAssembly.setFile(newFile);
activeMolecularAssembly.setName(newFile.getName());
if (logWrites) {
logger.log(Level.INFO, " Saving {0}", newFile.getName());
}
fw = new FileWriter(newFile, append);
bw = new BufferedWriter(fw);
// =============================================================================
// The CRYST1 record presents the unit cell parameters, space group, and Z
// value. If the structure was not determined by crystallographic means, CRYST1
// simply provides the unitary values, with an appropriate REMARK.
//
// 7 - 15 Real(9.3) a a (Angstroms).
// 16 - 24 Real(9.3) b b (Angstroms).
// 25 - 33 Real(9.3) c c (Angstroms).
// 34 - 40 Real(7.2) alpha alpha (degrees).
// 41 - 47 Real(7.2) beta beta (degrees).
// 48 - 54 Real(7.2) gamma gamma (degrees).
// 56 - 66 LString sGroup Space group.
// 67 - 70 Integer z Z value.
// =============================================================================
Crystal crystal = activeMolecularAssembly.getCrystal();
if (crystal != null && !crystal.aperiodic()) {
Crystal c = crystal.getUnitCell();
if (!listMode) {
bw.write(format("CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %10s\n", c.a, c.b, c.c, c.alpha, c.beta, c.gamma, padRight(c.spaceGroup.pdbName, 10)));
} else {
listOutput.add(format("CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %10s", c.a, c.b, c.c, c.alpha, c.beta, c.gamma, padRight(c.spaceGroup.pdbName, 10)));
}
}
// =============================================================================
// The SSBOND record identifies each disulfide bond in protein and polypeptide
// structures by identifying the two residues involved in the bond.
// The disulfide bond distance is included after the symmetry operations at
// the end of the SSBOND record.
//
// 8 - 10 Integer serNum Serial number.
// 12 - 14 LString(3) "CYS" Residue name.
// 16 Character chainID1 Chain identifier.
// 18 - 21 Integer seqNum1 Residue sequence number.
// 22 AChar icode1 Insertion code.
// 26 - 28 LString(3) "CYS" Residue name.
// 30 Character chainID2 Chain identifier.
// 32 - 35 Integer seqNum2 Residue sequence number.
// 36 AChar icode2 Insertion code.
// 60 - 65 SymOP sym1 Symmetry oper for 1st resid
// 67 - 72 SymOP sym2 Symmetry oper for 2nd resid
// 74 – 78 Real(5.2) Length Disulfide bond distance
//
// If SG of cysteine is disordered then there are possible alternate linkages.
// wwPDB practice is to put together all possible SSBOND records. This is
// problematic because the alternate location identifier is not specified in
// the SSBOND record.
// =============================================================================
int serNum = 1;
Polymer[] polymers = activeMolecularAssembly.getChains();
if (polymers != null) {
for (Polymer polymer : polymers) {
ArrayList<Residue> residues = polymer.getResidues();
for (Residue residue : residues) {
if (residue.getName().equalsIgnoreCase("CYS")) {
List<Atom> cysAtoms = residue.getAtomList();
Atom SG1 = null;
for (Atom atom : cysAtoms) {
if (atom.getName().equalsIgnoreCase("SG")) {
SG1 = atom;
break;
}
}
List<Bond> bonds = SG1.getBonds();
for (Bond bond : bonds) {
Atom SG2 = bond.get1_2(SG1);
if (SG2.getName().equalsIgnoreCase("SG")) {
if (SG1.getIndex() < SG2.getIndex()) {
bond.energy(false);
if (!listMode) {
bw.write(format("SSBOND %3d CYS %1s %4s CYS %1s %4s %36s %5.2f\n", serNum++, SG1.getChainID().toString(), Hybrid36.encode(4, SG1.getResidueNumber()), SG2.getChainID().toString(), Hybrid36.encode(4, SG2.getResidueNumber()), "", bond.getValue()));
} else {
listOutput.add(format("SSBOND %3d CYS %1s %4s CYS %1s %4s %36s %5.2f\n", serNum++, SG1.getChainID().toString(), Hybrid36.encode(4, SG1.getResidueNumber()), SG2.getChainID().toString(), Hybrid36.encode(4, SG2.getResidueNumber()), "", bond.getValue()));
}
}
}
}
}
}
}
}
// =============================================================================
//
// 7 - 11 Integer serial Atom serial number.
// 13 - 16 Atom name Atom name.
// 17 Character altLoc Alternate location indicator.
// 18 - 20 Residue name resName Residue name.
// 22 Character chainID Chain identifier.
// 23 - 26 Integer resSeq Residue sequence number.
// 27 AChar iCode Code for insertion of residues.
// 31 - 38 Real(8.3) x Orthogonal coordinates for X in Angstroms.
// 39 - 46 Real(8.3) y Orthogonal coordinates for Y in Angstroms.
// 47 - 54 Real(8.3) z Orthogonal coordinates for Z in Angstroms.
// 55 - 60 Real(6.2) occupancy Occupancy.
// 61 - 66 Real(6.2) tempFactor Temperature factor.
// 77 - 78 LString(2) element Element symbol, right-justified.
// 79 - 80 LString(2) charge Charge on the atom.
// =============================================================================
// 1 2 3 4 5 6 7
// 123456789012345678901234567890123456789012345678901234567890123456789012345678
// ATOM 1 N ILE A 16 60.614 71.140 -10.592 1.00 7.38 N
// ATOM 2 CA ILE A 16 60.793 72.149 -9.511 1.00 6.91 C
MolecularAssembly[] molecularAssemblies = this.getMolecularAssemblys();
int serial = 1;
// Loop over biomolecular chains
if (polymers != null) {
for (Polymer polymer : polymers) {
currentSegID = polymer.getName();
currentChainID = polymer.getChainID();
sb.setCharAt(21, currentChainID);
// Loop over residues
ArrayList<Residue> residues = polymer.getResidues();
for (Residue residue : residues) {
String resName = residue.getName();
if (resName.length() > 3) {
resName = resName.substring(0, 3);
}
int resID = residue.getResidueNumber();
int i = 0;
String[] entries = null;
for (; i < resAndScore.length; i++) {
entries = resAndScore[i].split("\\t");
if (!entries[0].equals(entries[0].replaceAll("\\D+", ""))) {
String[] subEntries = entries[0].split("[^0-9]");
entries[0] = subEntries[0];
}
if (entries[0].equals(String.valueOf(resID)) && !".".equals(entries[1])) {
break;
}
}
sb.replace(17, 20, padLeft(resName.toUpperCase(), 3));
sb.replace(22, 26, String.format("%4s", Hybrid36.encode(4, resID)));
// Loop over atoms
ArrayList<Atom> residueAtoms = residue.getAtomList();
boolean altLocFound = false;
for (Atom atom : residueAtoms) {
if (i != resAndScore.length) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, entries[1]);
} else {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
}
Character altLoc = atom.getAltLoc();
if (altLoc != null && !altLoc.equals(' ')) {
altLocFound = true;
}
}
// Write out alternate conformers
if (altLocFound) {
for (int ma = 1; ma < molecularAssemblies.length; ma++) {
MolecularAssembly altMolecularAssembly = molecularAssemblies[ma];
Polymer altPolymer = altMolecularAssembly.getPolymer(currentChainID, currentSegID, false);
Residue altResidue = altPolymer.getResidue(resName, resID, false);
residueAtoms = altResidue.getAtomList();
for (Atom atom : residueAtoms) {
if (atom.getAltLoc() != null && !atom.getAltLoc().equals(' ') && !atom.getAltLoc().equals('A')) {
if (i != resAndScore.length) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, entries[1]);
} else {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
}
}
}
}
}
}
terSB.replace(6, 11, String.format("%5s", Hybrid36.encode(5, serial++)));
terSB.replace(12, 16, " ");
terSB.replace(16, 26, sb.substring(16, 26));
if (!listMode) {
bw.write(terSB.toString());
bw.newLine();
} else {
listOutput.add(terSB.toString());
}
}
}
sb.replace(0, 6, "HETATM");
sb.setCharAt(21, 'A');
int resID = 1;
Polymer polymer = activeMolecularAssembly.getPolymer('A', "A", false);
if (polymer != null) {
ArrayList<Residue> residues = polymer.getResidues();
for (Residue residue : residues) {
int resID2 = residue.getResidueNumber();
if (resID2 >= resID) {
resID = resID2 + 1;
}
}
}
/**
* Loop over molecules, ions and then water.
*/
ArrayList<Molecule> molecules = activeMolecularAssembly.getMolecules();
for (int i = 0; i < molecules.size(); i++) {
Molecule molecule = (Molecule) molecules.get(i);
Character chainID = molecule.getChainID();
sb.setCharAt(21, chainID);
String resName = molecule.getResidueName();
if (resName.length() > 3) {
resName = resName.substring(0, 3);
}
sb.replace(17, 20, padLeft(resName.toUpperCase(), 3));
sb.replace(22, 26, String.format("%4s", Hybrid36.encode(4, resID)));
ArrayList<Atom> moleculeAtoms = molecule.getAtomList();
boolean altLocFound = false;
for (Atom atom : moleculeAtoms) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
Character altLoc = atom.getAltLoc();
if (altLoc != null && !altLoc.equals(' ')) {
altLocFound = true;
}
}
// Write out alternate conformers
if (altLocFound) {
for (int ma = 1; ma < molecularAssemblies.length; ma++) {
MolecularAssembly altMolecularAssembly = molecularAssemblies[ma];
MSNode altmolecule = altMolecularAssembly.getMolecules().get(i);
moleculeAtoms = altmolecule.getAtomList();
for (Atom atom : moleculeAtoms) {
if (atom.getAltLoc() != null && !atom.getAltLoc().equals(' ') && !atom.getAltLoc().equals('A')) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
}
}
}
}
resID++;
}
ArrayList<MSNode> ions = activeMolecularAssembly.getIons();
for (int i = 0; i < ions.size(); i++) {
Molecule ion = (Molecule) ions.get(i);
Character chainID = ion.getChainID();
sb.setCharAt(21, chainID);
String resName = ion.getResidueName();
if (resName.length() > 3) {
resName = resName.substring(0, 3);
}
sb.replace(17, 20, padLeft(resName.toUpperCase(), 3));
sb.replace(22, 26, String.format("%4s", Hybrid36.encode(4, resID)));
ArrayList<Atom> ionAtoms = ion.getAtomList();
boolean altLocFound = false;
for (Atom atom : ionAtoms) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
Character altLoc = atom.getAltLoc();
if (altLoc != null && !altLoc.equals(' ')) {
altLocFound = true;
}
}
// Write out alternate conformers
if (altLocFound) {
for (int ma = 1; ma < molecularAssemblies.length; ma++) {
MolecularAssembly altMolecularAssembly = molecularAssemblies[ma];
MSNode altion = altMolecularAssembly.getIons().get(i);
ionAtoms = altion.getAtomList();
for (Atom atom : ionAtoms) {
if (atom.getAltLoc() != null && !atom.getAltLoc().equals(' ') && !atom.getAltLoc().equals('A')) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
}
}
}
}
resID++;
}
ArrayList<MSNode> waters = activeMolecularAssembly.getWaters();
for (int i = 0; i < waters.size(); i++) {
Molecule water = (Molecule) waters.get(i);
Character chainID = water.getChainID();
sb.setCharAt(21, chainID);
String resName = water.getResidueName();
if (resName.length() > 3) {
resName = resName.substring(0, 3);
}
sb.replace(17, 20, padLeft(resName.toUpperCase(), 3));
sb.replace(22, 26, String.format("%4s", Hybrid36.encode(4, resID)));
ArrayList<Atom> waterAtoms = water.getAtomList();
boolean altLocFound = false;
for (Atom atom : waterAtoms) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
Character altLoc = atom.getAltLoc();
if (altLoc != null && !altLoc.equals(' ')) {
altLocFound = true;
}
}
// Write out alternate conformers
if (altLocFound) {
for (int ma = 1; ma < molecularAssemblies.length; ma++) {
MolecularAssembly altMolecularAssembly = molecularAssemblies[ma];
MSNode altwater = altMolecularAssembly.getWaters().get(i);
waterAtoms = altwater.getAtomList();
for (Atom atom : waterAtoms) {
if (atom.getAltLoc() != null && !atom.getAltLoc().equals(' ') && !atom.getAltLoc().equals('A')) {
writeSIFTAtom(atom, serial++, sb, anisouSB, bw, null);
}
}
}
}
resID++;
}
if (!listMode) {
bw.write("END");
bw.newLine();
} else {
listOutput.add("END");
}
bw.close();
} catch (Exception e) {
String message = "Exception writing to file: " + saveFile.toString();
logger.log(Level.WARNING, message, e);
return false;
}
return true;
}
use of ffx.potential.MolecularAssembly in project ffx by mjschnie.
the class ExtendedVariableTest method setup.
public MolecularAssembly setup(String filename, boolean quietly) {
if (quietly || resultsOnly) {
utils.setSilentPotential(true);
}
MolecularAssembly mola = openResource(filename, quietly);
// Turn off checks for overlapping atoms, which is expected for lambda=0.
mola.getPotentialEnergy().getCrystal().setSpecialPositionCutoff(0.0);
return mola;
}
use of ffx.potential.MolecularAssembly in project ffx by mjschnie.
the class ExtendedVariableTest method setupWithExtended.
public MolecularAssembly setupWithExtended(String filename, boolean quietly, ExtendedSystemConfig esvConfig) {
if (quietly || resultsOnly) {
utils.setSilentPotential(true);
}
setProp("pme.qi", true);
MolecularAssembly mola = openResource(filename, quietly);
// Turn off checks for overlapping atoms, which is expected for lambda=0.
mola.getPotentialEnergy().getCrystal().setSpecialPositionCutoff(0.0);
// Create extended variables; add to system; hook up to assembly.
ExtendedSystem esvSystem = (esvConfig != null) ? new ExtendedSystem(mola, esvConfig) : new ExtendedSystem(mola);
esvSystem.setConstantPh(7.4);
esvSystem.populate(esvResidueIDs);
mola.getPotentialEnergy().attachExtendedSystem(esvSystem);
ExtendedSystemConfig.print(esvSystem.config);
return mola;
}
use of ffx.potential.MolecularAssembly in project ffx by mjschnie.
the class ExtendedVariableTest method testDerivatives.
/**
* Analytic Derivative vs Finite Difference: VdW,PermReal,PermRecip,Total
*/
public void testDerivatives(ExtendedSystemConfig esvConfig) {
if (esvConfig == null) {
esvConfig = setDebugParameters();
}
MolecularAssembly mola = setupWithExtended(esvFilename, false, esvConfig);
ForceFieldEnergy ffe = mola.getPotentialEnergy();
ExtendedSystem esvSystem = ffe.getExtendedSystem();
if (resultsOnly) {
utils.setSilentPotential(true);
}
final double step = 1e-6;
for (int i = 0; i < esvSystem.size(); i++) {
final String esvName = esvSystem.getEsv(i).getName();
if (!mola.getCrystal().aperiodic()) {
sb.append(format(" Finite Diff: %5.5s (Crystal)\n", esvName));
} else {
sb.append(format(" Finite Diff: %5.5s (Aprodc.)\n", esvName));
}
// Reset lambdas.
for (int k = 0; k < esvSystem.size(); k++) {
esvSystem.setLambda(k, initialLambda[k]);
}
for (double lambda : lambdaValuesToTest) {
final double center, low, high;
if (oneSidedFiniteAtExtremes) {
center = lambda;
low = (center - step >= 0.0) ? center - step : center;
high = (center + step <= 1.0) ? center + step : center;
} else {
center = (lambda - step < 0.0) ? lambda + step : (lambda + step > 1.0) ? lambda - step : lambda;
low = center - step;
high = center + step;
}
final double width = high - low;
// Collect numeric derivative components.
esvSystem.setLambda(i, low);
ffe.energy(true, false);
final double vdwLow = ffe.getEnergyComponent(PotentialComponent.VanDerWaals);
final double bondedLow = ffe.getEnergyComponent(PotentialComponent.Bonded);
final double biasLow = ffe.getEnergyComponent(PotentialComponent.pHMD);
final double permRealLow = ffe.getEnergyComponent(PotentialComponent.PermanentRealSpace);
final double permSelfLow = ffe.getEnergyComponent(PotentialComponent.PermanentSelf);
final double permRecipLow = ffe.getEnergyComponent(PotentialComponent.PermanentReciprocal);
final double indRealLow = ffe.getEnergyComponent(PotentialComponent.InducedRealSpace);
final double indSelfLow = ffe.getEnergyComponent(PotentialComponent.InducedSelf);
final double indRecipLow = ffe.getEnergyComponent(PotentialComponent.InducedReciprocal);
final double totalLow = ffe.getEnergyComponent(PotentialComponent.ForceFieldEnergy);
esvSystem.setLambda(i, high);
ffe.energy(true, false);
final double vdwHigh = ffe.getEnergyComponent(PotentialComponent.VanDerWaals);
final double bondedHigh = ffe.getEnergyComponent(PotentialComponent.Bonded);
final double biasHigh = ffe.getEnergyComponent(PotentialComponent.pHMD);
final double permRealHigh = ffe.getEnergyComponent(PotentialComponent.PermanentRealSpace);
final double permSelfHigh = ffe.getEnergyComponent(PotentialComponent.PermanentSelf);
final double permRecipHigh = ffe.getEnergyComponent(PotentialComponent.PermanentReciprocal);
final double indRealHigh = ffe.getEnergyComponent(PotentialComponent.InducedRealSpace);
final double indSelfHigh = ffe.getEnergyComponent(PotentialComponent.InducedSelf);
final double indRecipHigh = ffe.getEnergyComponent(PotentialComponent.InducedReciprocal);
final double totalHigh = ffe.getEnergyComponent(PotentialComponent.ForceFieldEnergy);
// Get analytic derivatives from the center.
esvSystem.setLambda(i, center);
ffe.energy(true, false);
final double vdwAna = esvSystem.getDerivativeComponent(PotentialComponent.VanDerWaals, i);
final double bondedAna = esvSystem.getDerivativeComponent(PotentialComponent.Bonded, i);
final double biasAna = esvSystem.getDerivativeComponent(PotentialComponent.pHMD, i);
final double permRealAna = esvSystem.getDerivativeComponent(PotentialComponent.PermanentRealSpace, i);
final double permSelfAna = esvSystem.getDerivativeComponent(PotentialComponent.PermanentSelf, i);
final double permRecipAna = esvSystem.getDerivativeComponent(PotentialComponent.PermanentReciprocal, i);
final double indRealAna = esvSystem.getDerivativeComponent(PotentialComponent.InducedRealSpace, i);
final double indSelfAna = esvSystem.getDerivativeComponent(PotentialComponent.InducedSelf, i);
final double indRecipAna = esvSystem.getDerivativeComponent(PotentialComponent.InducedReciprocal, i);
final double totalAna = esvSystem.getDerivativeComponent(PotentialComponent.ForceFieldEnergy, i);
// Calculate numeric derivatives and error.
final double vdwNum = (vdwHigh - vdwLow) / (width);
final double vdwErr = (vdwAna - vdwNum);
final double bondedNum = (bondedHigh - bondedLow) / (width);
final double bondedErr = (bondedAna - bondedNum);
final double biasNum = (biasHigh - biasLow) / (width);
final double biasErr = (biasAna - biasNum);
final double permRealNum = (permRealHigh - permRealLow) / (width);
final double permRealErr = (permRealAna - permRealNum);
final double permSelfNum = (permSelfHigh - permSelfLow) / (width);
final double permSelfErr = (permSelfAna - permSelfNum);
final double permRecipNum = (permRecipHigh - permRecipLow) / (width);
final double permRecipErr = (permRecipAna - permRecipNum);
final double indRealNum = (indRealHigh - indRealLow) / (width);
final double indRealErr = (indRealAna - indRealNum);
final double indSelfNum = (indSelfHigh - indSelfLow) / (width);
final double indSelfErr = (indSelfAna - indSelfNum);
final double indRecipNum = (indRecipHigh - indRecipLow) / (width);
final double indRecipErr = (indRecipAna - indRecipNum);
final double totalNum = (totalHigh - totalLow) / (width);
final double totalErr = (totalAna - totalNum);
sb.append(format(" %-28s %12s %12s %12s %12s %12s %12s %12s %12s %12s %12s\n", StringUtils.repeat("*", 28), "vdw ", "bonded", "bias", "permReal", "permSelf", "permRecip", "indReal", "indSelf", "indRecip", "total"));
sb.append(format(" %-28s %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g\n", format("Numeric @L=%s", esvSystem.getLambdaList()), vdwNum, bondedNum, biasNum, permRealNum, permSelfNum, permRecipNum, indRealNum, indSelfNum, indRecipNum, totalNum));
sb.append(format(" %-28s %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g %+12.6g\n", format("Analytic @L=%s", esvSystem.getLambdaList()), vdwAna, bondedAna, biasAna, permRealAna, permSelfAna, permRecipAna, indRealAna, indSelfAna, indRecipAna, totalAna));
sb.append(format(" %-28s %12s %12s %12s %12s %12s %12s %12s %12s %12s %12s\n", "Error:", err(vdwAna, vdwNum), err(bondedAna, bondedNum), err(biasAna, biasNum), err(permRealAna, permRealNum), err(permSelfAna, permSelfNum), err(permRecipAna, permRecipNum), err(indRealAna, indRealNum), err(indSelfAna, indSelfNum), err(indRecipAna, indRecipNum), err(totalAna, totalNum)));
utils.setSilentPotential(false);
logger.info(sb.toString());
if (assertions) {
assertEquals("VanDerWaals Deriv Error", 0.0, vdwErr, tolerance);
assertEquals("Bonded Deriv Error", 0.0, bondedErr, tolerance);
assertEquals("Bias Deriv Error", 0.0, biasErr, tolerance);
assertEquals("PermReal Deriv Error", 0.0, permRealErr, tolerance);
assertEquals("PermSelf Deriv Error", 0.0, permSelfErr, tolerance);
assertEquals("PermRecip Deriv Error", 0.0, permRecipErr, tolerance);
assertEquals("IndReal Deriv Error", 0.0, indRealErr, tolerance);
assertEquals("IndSelf Deriv Error", 0.0, indSelfErr, tolerance);
assertEquals("IndRecip Deriv Error", 0.0, indRecipErr, tolerance);
assertEquals("Total Deriv Error", 0.0, totalErr, tolerance);
}
}
// lambda loop
}
// ESV loop
}
use of ffx.potential.MolecularAssembly in project ffx by mjschnie.
the class ModelingShell method returnEnergy.
/**
* <p>
* returnEnergy</p>
*
* @return Current system energy (a double).
*/
public double returnEnergy() {
if (interrupted) {
logger.info(" Algorithm interrupted - skipping energy.");
return 0.0;
}
if (terminatableAlgorithm != null) {
logger.info(" Algorithm already running - skipping energy.");
return 0.0;
}
MolecularAssembly active = mainPanel.getHierarchy().getActive();
if (active != null) {
ForceFieldEnergy energy = active.getPotentialEnergy();
if (energy == null) {
energy = ForceFieldEnergy.energyFactory(active);
active.setPotential(energy);
}
return energy.energy(false, true);
}
logger.warning(" Energy could not be calculated");
return 0.0;
}
Aggregations