/** * Automatically generate coordinates if a user has provided reaction without them. * * @param rxn reaction * @throws CDKException coordinates could not be generated */ private void ensure2dLayout(IReaction rxn) throws CDKException { if (!GeometryUtil.has2DCoordinates(rxn)) { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setAlignMappedReaction(alignMappedReactions); sdg.generateCoordinates(rxn); } }
/** * Automatically generate coordinates if a user has provided reaction without them. * * @param rxn reaction * @throws CDKException coordinates could not be generated */ private void ensure2dLayout(IReaction rxn) throws CDKException { if (!GeometryUtil.has2DCoordinates(rxn)) { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setAlignMappedReaction(alignMappedReactions); sdg.generateCoordinates(rxn); } }
@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()); } }
/** * Reaction from US20050272744A1 [0195], a bond is broken and made. The * reaction layout should not crash. */ @Test public void alignReactionBondBrokenAndMade() throws CDKException { String smiles = "[CH3:18][NH:19][CH3:20].[cH:14]1[cH:13][cH:12][c:11]([cH:16][cH:15]1)[CH2:10][O:9][C:1](=[O:17])[NH:2][C@H:3]2[CH2:8][C:6](=[O:7])[O:5][CH2:4]2>C1CCOC1>[CH3:18][N:19]([CH3:20])[C:6](=[O:7])[CH2:8][C@H:3]([CH2:4][OH:5])[NH:2][C:1](=[O:17])[O:9][CH2:10][c:11]1[cH:12][cH:13][cH:14][cH:15][cH:16]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()); }