Skip to content

Commit

Permalink
Ensure no modifications whilst iterating.
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Oct 21, 2013
1 parent 0debacc commit e367ebf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -1013,9 +1013,7 @@ private void applyMDLValenceModel(IAtom atom, int explicitValence) {
}

private void fixHydrogenIsotopes(IAtomContainer molecule, IsotopeFactory isotopeFactory) {
Iterator<IAtom> atoms = molecule.atoms().iterator();
while (atoms.hasNext()) {
IAtom atom = atoms.next();
for (IAtom atom : AtomContainerManipulator.getAtomArray(molecule)) {
if (atom instanceof IPseudoAtom) {
IPseudoAtom pseudo = (IPseudoAtom) atom;
if ("D".equals(pseudo.getLabel())) {
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.SaturationChecker;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.AtomContainerSetManipulator;
import org.openscience.cdk.tools.manipulator.BondManipulator;

Expand Down Expand Up @@ -83,7 +84,7 @@ public IAtomContainer generate(IAtomContainerSet atomContainers) throws CDKExcep
do{
bondFormed=false;
for(IAtomContainer ac : atomContainers.atomContainers()){
for(IAtom atom : ac.atoms()){
for(IAtom atom : AtomContainerManipulator.getAtomArray(ac)){
if (!satCheck.isSaturated(atom, ac))
{
IAtom partner = getAnotherUnsaturatedNode(atom, atomContainers);
Expand Down
5 changes: 3 additions & 2 deletions src/main/org/openscience/cdk/tools/ProteinBuilderTool.java
Expand Up @@ -34,6 +34,7 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.templates.AminoAcids;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.Map;

Expand Down Expand Up @@ -149,8 +150,8 @@ public static BioPolymer createProtein(String sequence) throws CDKException {
}

private static BioPolymer addAminoAcid(BioPolymer protein, AminoAcid aaToAdd, Strand strand) {
for (IAtom atom : aaToAdd.atoms()) protein.addAtom(atom, aaToAdd, strand);
for (IBond bond : aaToAdd.bonds()) protein.addBond(bond);
for (IAtom atom : AtomContainerManipulator.getAtomArray(aaToAdd)) protein.addAtom(atom, aaToAdd, strand);
for (IBond bond : AtomContainerManipulator.getBondArray(aaToAdd)) protein.addBond(bond);
return protein;
}
}

0 comments on commit e367ebf

Please sign in to comment.