Skip to content

Commit

Permalink
When moving around positional variation ensure all atoms are moved.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Jul 21, 2016
1 parent 7c77138 commit 555cf60
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,25 @@ private void placePositionalVariation(IAtomContainer mol) {
// get all atoms connected to the part we will move
Set<Integer> visited = new HashSet<>();
visit(visited, adjlist, atomIdx);

// gather up other position group
Set<Integer> newvisit = new HashSet<>();
do {
newvisit.clear();
for (Integer idx : visited) {
IAtom visitedAtom = mol.getAtom(idx);
for (Map.Entry<Set<IAtom>, IAtom> e2 : mapping.entries()) {
if (e2.getKey().contains(visitedAtom)) {
int other = idxs.get(e2.getValue());
if (!visited.contains(other) && newvisit.add(other)) {
visit(newvisit, adjlist, other);
}
}
}
}
visited.addAll(newvisit);
} while (!newvisit.isEmpty());

IAtomContainer frag = mol.getBuilder().newInstance(IAtomContainer.class);
for (Integer visit : visited)
frag.addAtom(mol.getAtom(visit));
Expand Down

0 comments on commit 555cf60

Please sign in to comment.