/** * Load an IChemModel from an InChI. * * @param url location * @return InChI instance * @throws CDKException InChI could not be generated */ public static IChemModel readInChI(URL url) throws CDKException { IChemModel chemModel = new ChemModel(); try { IAtomContainerSet moleculeSet = new AtomContainerSet(); chemModel.setMoleculeSet(moleculeSet); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line; while ((line = in.readLine()) != null) { if (line.toLowerCase().startsWith("inchi=")) { moleculeSet.addAtomContainer(parseInChI(line)); } } in.close(); } catch (Exception e) { e.printStackTrace(); throw new CDKException(e.getMessage()); } return chemModel; } }
try { IAtomContainer atomContainer = InChITool.parseInChI(text); molecule = atomContainer.getBuilder().newInstance(IAtomContainer.class, atomContainer);
try{ if (content.toLowerCase().indexOf("inchi")>-1 ) { toPaste = InChITool.parseInChI(content);