private IAtomContainer ParseSmiles(string smiles, bool isRxnPart) { try { // create the Beam object from the SMILES Beam.Graph g = Beam.Graph.FromSmiles(smiles); // convert the Beam object model to the CDK - note exception thrown // if a kekule structure could not be assigned. var mol = beamToCDK.ToAtomContainer(Kekulise ? g.Kekule() : g, Kekulise); if (!isRxnPart) { try { // CXSMILES layer ParseMolCXSMILES(g.Title, mol); } catch (Exception e) { // e.StackTrace throw new InvalidSmilesException($"Error parsing CXSMILES: {e.Message}"); } } return(mol); } catch (IOException e) { throw new InvalidSmilesException($"could not parse '{smiles}', {e.Message}"); } catch (Exception) { throw new InvalidSmilesException($"could not parse '{smiles}'"); } }
IAtomContainer Convert(string smi) { BeamToCDK g2c = new BeamToCDK(CDK.Builder); Graph g = Graph.FromSmiles(smi); return(g2c.ToAtomContainer(g, false)); }
private IAtomContainer ParseSmiles(string smiles, bool isRxnPart) { try { // create the Beam object from parsing the SMILES var warnings = new HashSet <string>(); var g = Beam.Graph.Parse(smiles, Strict, warnings); foreach (var warning in warnings) { Trace.TraceWarning(warning); } // convert the Beam object model to the CDK - note exception thrown // if a kekule structure could not be assigned. var mol = beamToCDK.ToAtomContainer(Kekulise ? g.Kekule() : g, Kekulise); if (!isRxnPart) { try { // CXSMILES layer ParseMolCXSMILES(g.Title, mol); } catch (Exception e) { // e.StackTrace throw new InvalidSmilesException($"Error parsing CXSMILES: {e.Message}", e); } } return(mol); } catch (IOException e) { throw new InvalidSmilesException($"could not parse '{smiles}', {e.Message}", e); } catch (Exception e) { throw new InvalidSmilesException($"could not parse '{smiles}'", e); } }