/// <summary>
        /// Tries to parses text as SMILES, InChI, or MolBlock and returns RDKit ROMol.
        /// </summary>
        /// <param name="molIdent">Text expression of molecule like SMILES, InChI, or MolBlock.</param>
        /// <returns>RDKit ROMol.</returns>
        public static ROMol Parse(string molIdent)
        {
            if (molIdent == null)
            {
                throw new ArgumentNullException(nameof(molIdent));
            }

            var mol = MolecularCache.GetOrAdd(molIdent, a_ident =>
            {
                string notationType = null;
                ROMol a_mol;

                a_mol = RWMol.MolFromSmiles(molIdent);
                if (a_mol != null)
                {
                    notationType = "SMILES";
                    goto L_Found;
                }

                using (var rv = new ExtraInchiReturnValues())
                {
                    a_mol = RDKFuncs.InchiToMol(molIdent, rv);
                    if (a_mol != null)
                    {
                        notationType = "InChI";
                        goto L_Found;
                    }
                }

                a_mol = RWMol.MolFromMolBlock(molIdent);
                if (a_mol != null)
                {
                    RDKFuncs.assignStereochemistryFrom3D(a_mol);
                    notationType = "MolBlock";
                    goto L_Found;
                }

                L_Found:
                if (a_mol == null)
                {
                    a_mol = nullMol;
                }
                else
                {
                    if (notationType != null)
                    {
                        a_mol.setProp("source", notationType);
                    }
                }

                return(a_mol);
            });

            if (object.ReferenceEquals(mol, nullMol))
            {
                return(null);
            }

            return(mol);
        }
 public static string RDKit_InChI(string text, string options)
 {
     return(RDKit_CalcDesc(text, "RDKit_InChI", mol =>
     {
         using (var rv = new ExtraInchiReturnValues())
         {
             return RDKit.Chem.MolToInchi(mol, options, rv);
         }
     }));
 }
示例#3
0
 public static string MolToInchi(ROMol mol, string options = "", ExtraInchiReturnValues ex = null)
 {
     return(RDKFuncs.MolToInchi(mol, ex ?? new ExtraInchiReturnValues(), options));
 }
示例#4
0
 public static string MolBlockToInchi(string molblock, string options = "", ExtraInchiReturnValues ex = null)
 {
     return(RDKFuncs.MolBlockToInchi(molblock, ex ?? new ExtraInchiReturnValues(), options));
 }
示例#5
0
 public static RWMol InchiToMol(string inchi, bool sanitize = true, bool removeHs = true, ExtraInchiReturnValues ex = null)
 {
     return(RDKFuncs.InchiToMol(inchi, ex ?? new ExtraInchiReturnValues(), sanitize, removeHs));
 }