Skip to content

Commit

Permalink
Be strict when placing partial rings, check bond count in addition to…
Browse files Browse the repository at this point in the history
… atom count.
  • Loading branch information
johnmay committed Oct 7, 2018
1 parent 617b36d commit 9a74c3d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ public RingPlacer() {
*/
public void placeRing(IRing ring, IAtomContainer sharedAtoms, Point2d sharedAtomsCenter, Vector2d ringCenterVector,
double bondLength) {
int sharedAtomCount = sharedAtoms.getAtomCount();
logger.debug("placeRing -> sharedAtomCount: " + sharedAtomCount);
if (sharedAtomCount > 2) {
int numSharedAtoms = sharedAtoms.getAtomCount();
int numSharedBonds = sharedAtoms.getBondCount();
logger.debug("placeRing -> sharedAtomCount: " + numSharedAtoms);
if (numSharedAtoms > 2 && numSharedBonds > 1) {
placeBridgedRing(ring, sharedAtoms, sharedAtomsCenter, ringCenterVector, bondLength);
} else if (sharedAtomCount == 2) {
} else if (numSharedAtoms == 2 && numSharedBonds == 1) {
placeFusedRing(ring, sharedAtoms, ringCenterVector, bondLength);
} else if (sharedAtomCount == 1) {
} else if (numSharedAtoms == 1 && numSharedBonds == 0) {
placeSpiroRing(ring, sharedAtoms, sharedAtomsCenter, ringCenterVector, bondLength);
}
}
Expand Down Expand Up @@ -533,7 +534,7 @@ public void placeFusedRing(IRing ring,
}

/**
* Completes the layout of a partiallyed laid out ring.
* Completes the layout of a partially laid out ring.
*
* @param rset ring set
* @param ring the ring to complete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1288,4 +1288,16 @@ public void alignReactionBondBrokenAndMade() throws CDKException {
for (IAtom atom : ReactionManipulator.toMolecule(reaction).atoms())
assertNotNull(atom.getPoint2d());
}

@Test
public void alignReactionBondBrokenAndMade2() throws CDKException {
String smiles = "[CH2:2]1[CH2:3][CH:4]2[CH2:5][CH2:6][CH:1]1[O:7]2.[IH:8]>>[OH:7][C@H:1]1[CH2:6][CH2:5][C@H:4]([I:8])[CH2:3][CH2:2]1";
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
IReaction reaction = smipar.parseReactionSmiles(smiles);
StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setAlignMappedReaction(true);
sdg.generateCoordinates(reaction);
for (IAtom atom : ReactionManipulator.toMolecule(reaction).atoms())
assertNotNull(atom.getPoint2d());
}
}

0 comments on commit 9a74c3d

Please sign in to comment.