Esempio n. 1
0
        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}'");
            }
        }
Esempio n. 2
0
        void Main()
        {
            IAtomContainer m = TestMoleculeFactory.MakeBenzene();

            // converter is thread-safe and can be used by multiple threads
            CDKToBeam c2g = new CDKToBeam();

            Beam.Graph g = c2g.ToBeamGraph(m);

            // get the SMILES notation from the Beam graph
            string smi = g.ToSmiles();
        }