/** * * @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; } }
/** * This method uses generateCoordinates, but it removes the hydrogens first, * lays out the structure and then adds them again. * * @throws CDKException if an error occurs * @see #generateCoordinates * @deprecated use {@link #generateCoordinates()} */ @Deprecated public void generateExperimentalCoordinates() throws CDKException { generateExperimentalCoordinates(DEFAULT_BOND_VECTOR); }
/** * 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); } }
/** * <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(); }
/** * * @param mol * @return */ public static IAtomContainer getMoleculeWithLayoutCheck(IAtomContainer mol) { if (!has2DCoordinates(mol)) { try { StructureDiagramGenerator sdg = new StructureDiagramGenerator(new AtomContainer(mol)); sdg.generateCoordinates(); mol = sdg.getMolecule(); } catch (Exception e) { e.printStackTrace(); } } return mol; }
/** * 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; }
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; }
public IAtomContainer layout(IAtomContainer molecule) { sdg.setMolecule(molecule); try { sdg.generateCoordinates(); } catch (Exception e) { System.err.println(e); } return sdg.getMolecule(); }
@Test public void pyrroleWithoutIdentityTemplate() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); String smiles = "C1=CNC=C1"; StructureDiagramGenerator generator = new StructureDiagramGenerator(); generator.setUseIdentityTemplates(false); IAtomContainer mol = sp.parseSmiles(smiles); generator.setMolecule(mol, false); generator.generateCoordinates(); double minY = Double.MAX_VALUE; int i = -1; // note if the SDG changes the nitrogen might be at // the bottom by chance when generated ab initio for (int j = 0; j < mol.getAtomCount(); j++) { IAtom atom = mol.getAtom(j); if (atom.getPoint2d().y < minY) { minY = atom.getPoint2d().y; i = j; } } // N is at index 2 assertThat(i, not(2)); }
private void generateFragmentCoordinates(IAtomContainer mol, List<IAtomContainer> frags) throws CDKException { final List<IBond> ionicBonds = makeIonicBonds(frags); for (IBond bond : ionicBonds) mol.addBond(bond); frags = toList(ConnectivityChecker.partitionIntoMolecules(mol)); setMolecule(fragment, false, afix, bfix); generateCoordinates(DEFAULT_BOND_VECTOR, true, true); lengthenIonicBonds(ionicBonds, fragment); limits.add(getAprxBounds(fragment)); assignStereochem(mol); finalizeLayout(mol);
generateCoordinates(mol); for (IAtomContainer mol : reaction.getAgents().atomContainers()) generateCoordinates(mol); Map<Integer, IAtom> reference = select(refmap.get(idx)); for (IAtom atom : largest.atoms()) { idx = atom.getProperty(CDKConstants.ATOM_ATOM_MAPPING); setMolecule(mol, false, afix.keySet(), bfix); generateCoordinates(); generateCoordinates(mol);
/** * 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); }
/** * Assings a molecule to be layed out. Call generateCoordinates() to do the * actual layout. * * @param molecule the molecule for which coordinates are to be generated. */ public void setMolecule(IAtomContainer molecule) { setMolecule(molecule, true); }
/** * * @param params * @param forceRelayout */ public SingleMoleculeLayout(Params params, boolean forceRelayout) { setParams(params); sdg = new StructureDiagramGenerator(); this.forceRelayout = forceRelayout; }
@Test(expected = UnsupportedOperationException.class) public void setBondLength() { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setBondLength(2); }
/** * Tests case where calling generateExperimentalCoordinates threw an NPE. * * @cdk.bug 1269 */ @Test(timeout = 5000) public void testBug1269() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); String smiles = "O=C(O)[C@H](N)C"; // L-alanine, but any [C@H] will do IAtomContainer mol = sp.parseSmiles(smiles); SDG.setMolecule(mol); SDG.generateExperimentalCoordinates(new Vector2d(0, 1)); }
/** * Returns moecule with cleaned Layout * * @return cleaned Layout molecule */ public IAtomContainer getMoleculeWithLayoutCheck() { if (!has2DCoordinates(molecule)) { try { StructureDiagramGenerator sdg = new StructureDiagramGenerator(new AtomContainer(molecule)); sdg.generateCoordinates(); molecule = sdg.getMolecule(); } catch (Exception e) { e.printStackTrace(); } } return molecule; }
/** * 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; }
/** * @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; }
/** * <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(); }