Skip to content

Commit fe338f3

Browse files
committed
Should backup and rollback all charges not just the current atom.
1 parent a75ec00 commit fe338f3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/PartialSigmaChargeDescriptor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ public String[] getDescriptorNames() {
128128
*/
129129
@Override
130130
public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
131-
// FIXME: for now I'll cache the original charges, and restore them at the end of this method
132-
Double originalCharge = atom.getCharge();
133131
if (!isCachedAtomContainer(ac)) {
132+
Double[] org = new Double[ac.getAtomCount()];
133+
for (int i = 0; i < org.length; i++)
134+
org[i] = ac.getAtom(i).getCharge();
134135
IAtomContainer mol = atom.getBuilder().newInstance(IAtomContainer.class, ac);
135136
if (maxIterations != 0) peoe.setMaxGasteigerIters(maxIterations);
136137
try {
137138
peoe.assignGasteigerMarsiliSigmaPartialCharges(mol, true);
138-
139139
for (int i = 0; i < ac.getAtomCount(); i++) {
140140
// assume same order, so mol.getAtom(i) == ac.getAtom(i)
141141
cacheDescriptorValue(ac.getAtom(i), ac, new DoubleResult(mol.getAtom(i).getCharge()));
@@ -144,9 +144,9 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
144144
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(
145145
Double.NaN), NAMES, e);
146146
}
147+
for (int i = 0; i < org.length; i++)
148+
mol.getAtom(i).setCharge(org[i]);
147149
}
148-
atom.setCharge(originalCharge);
149-
150150
return getCachedDescriptorValue(atom) != null ? new DescriptorValue(getSpecification(), getParameterNames(),
151151
getParameters(), getCachedDescriptorValue(atom), NAMES) : null;
152152
}

0 commit comments

Comments
 (0)