private IAtomContainer parseSmiles(String smiles, boolean isRxnPart) throws InvalidSmilesException { try { // create the Beam object from parsing the SMILES Set<String> warnings = new HashSet<>(); Graph g = Graph.parse(smiles, strict, warnings); for (String warning : warnings) logger.warn(warning); // convert the Beam object model to the CDK - note exception thrown // if a kekule structure could not be assigned. IAtomContainer mol = beamToCDK.toAtomContainer(kekulise ? g.kekule() : g, kekulise); if (!isRxnPart) { try { // CXSMILES layer parseMolCXSMILES(g.getTitle(), mol); } catch (Exception e) { e.printStackTrace(); throw new InvalidSmilesException("Error parsing CXSMILES:" + e.getMessage()); } } return mol; } catch (IOException e) { throw new InvalidSmilesException("could not parse '" + smiles + "', " + e.getMessage()); } catch (Exception e) { throw new InvalidSmilesException("could not parse '" + smiles + "'"); } }
throw new InvalidSmilesException("Not a reaction SMILES: " + smiles); throw new InvalidSmilesException("Invalid reaction SMILES:" + smiles); } catch (Exception e) { e.printStackTrace(); throw new InvalidSmilesException("Error parsing CXSMILES:" + e.getMessage());
@Test public void testInvalidSmilesException_String() { final String EXPLANATION = "No, CDK cannot compute the multidollar ligand you search for target X."; InvalidSmilesException exception = new InvalidSmilesException(EXPLANATION); Assert.assertNotNull(exception); Assert.assertEquals(EXPLANATION, exception.getMessage()); } }