/** * The main method of this StructurDiagramGenerator. Assign a molecule to the * StructurDiagramGenerator, call the generateCoordinates() method and get * your molecule back. * * @param firstBondVector The vector of the first bond to lay out * @throws CDKException if an error occurs */ public void generateCoordinates(Vector2d firstBondVector) throws CDKException { generateCoordinates(firstBondVector, false, false); }
/** * The main method of this StructurDiagramGenerator. Assign a molecule to the * StructurDiagramGenerator, call the generateCoordinates() method and get * your molecule back. * * @throws CDKException if an error occurs */ public void generateCoordinates() throws CDKException { generateCoordinates(DEFAULT_BOND_VECTOR); }
/** * The main method of this StructurDiagramGenerator. Assign a molecule to the * StructurDiagramGenerator, call the generateCoordinates() method and get * your molecule back. * * @param firstBondVector The vector of the first bond to lay out * @throws CDKException if an error occurs */ public void generateCoordinates(Vector2d firstBondVector) throws CDKException { generateCoordinates(firstBondVector, false, false); }
/** * The main method of this StructurDiagramGenerator. Assign a molecule to the * StructurDiagramGenerator, call the generateCoordinates() method and get * your molecule back. * * @throws CDKException if an error occurs */ public void generateCoordinates() throws CDKException { generateCoordinates(DEFAULT_BOND_VECTOR); }
/** * <p>Convenience method for generating 2D coordinates.</p> * * <p>The method is short-hand for calling:</p> * <pre> * sdg.setMolecule(mol, false); * sdg.generateCoordinates(); * </pre> * * @param mol molecule to layout * @throws CDKException problem with layout */ public final void generateCoordinates(IAtomContainer mol) throws CDKException { setMolecule(mol, false); generateCoordinates(); }
/** * <p>Convenience method for generating 2D coordinates.</p> * * <p>The method is short-hand for calling:</p> * <pre> * sdg.setMolecule(mol, false); * sdg.generateCoordinates(); * </pre> * * @param mol molecule to layout * @throws CDKException problem with layout */ public final void generateCoordinates(IAtomContainer mol) throws CDKException { setMolecule(mol, false); generateCoordinates(); }
/** * Automatically generate coordinates if a user has provided a molecule without them. * * @param container a molecule * @return if coordinates needed to be generated * @throws CDKException coordinates could not be generated */ private boolean ensure2dLayout(IAtomContainer container) throws CDKException { if (!GeometryUtil.has2DCoordinates(container)) { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.generateCoordinates(container); return true; } return false; }
/** * Automatically generate coordinates if a user has provided a molecule without them. * * @param container a molecule * @return if coordinates needed to be generated * @throws CDKException coordinates could not be generated */ private boolean ensure2dLayout(IAtomContainer container) throws CDKException { if (!GeometryUtil.has2DCoordinates(container)) { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.generateCoordinates(container); return true; } return false; }
/** * 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); } }
public static IAtomContainer layout(IAtomContainer mol) throws Exception { SDG.setMolecule(mol, false); SDG.generateCoordinates(); return mol; }
/** * 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); } }
/** * * @param AtomContainer * @return */ protected IAtomContainer layout(IAtomContainer AtomContainer) { try { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setMolecule(AtomContainer, true); sdg.generateCoordinates(); return sdg.getMolecule(); } catch (CDKException e) { return AtomContainer; } }
public IAtomContainer layout(IAtomContainer molecule) { sdg.setMolecule(molecule); try { sdg.generateCoordinates(); } catch (Exception e) { System.err.println(e); } return sdg.getMolecule(); }
/** * @param structures * @return */ private boolean everythingOk(Vector structures) throws Exception { StructureDiagramGenerator sdg; IAtomContainer mol; if (debug) System.out.println("number of structures in vector: " + structures.size()); for (int f = 0; f < structures.size(); f++) { sdg = new StructureDiagramGenerator(); mol = (IAtomContainer) structures.elementAt(f); sdg.setMolecule(mol); sdg.generateCoordinates(new Vector2d(0, 1)); } return true; }
/** * {@code SMILES: CN(C)(C)=CC} */ @Test public void noWavyBondForCisTransNv5() throws CDKException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("CN(C)(C)=CC"); StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.generateCoordinates(mol); for (IBond bond : mol.bonds()) { assertThat(bond.getStereo(), is(not(IBond.Stereo.UP_OR_DOWN))); assertThat(bond.getStereo(), is(not(IBond.Stereo.UP_OR_DOWN_INVERTED))); } }
private boolean showIt(IAtomContainer molecule, String name) throws Exception { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setMolecule((IAtomContainer) molecule.clone()); sdg.generateCoordinates(new Vector2d(0, 1)); return true; }
/** * {@code SMILES: O=C4C=C2[C@]([C@@]1([H])CC[C@@]3([C@@]([H])(O)CC[C@@]3([H])[C@]1([H])CC2)C)(C)CC4} */ @Test public void testosterone() throws CDKException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("O=C4C=C2[C@]([C@@]1([H])CC[C@@]3([C@@]([H])(O)CC[C@@]3([H])[C@]1([H])CC2)C)(C)CC4"); StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.generateCoordinates(mol); int wedgeCount = 0; for (IBond bond : mol.bonds()) if (bond.getStereo() == IBond.Stereo.UP || bond.getStereo() == IBond.Stereo.DOWN) wedgeCount++; assertThat(wedgeCount, is(7)); }
@Test(expected = IllegalArgumentException.class) public void inconsistentStereoState() throws CDKException { final String smi = "O[C@]([H])(C)CCC"; SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles(smi); mol.removeBond(1); mol.removeAtomOnly(2); // unsafe-removes StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.generateCoordinates(mol); }
@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()); }