public void ParseTest() { Assert.IsNotNull(RDKitMol.Parse("C")); const string InvalidValue = "qwertyuop"; Assert.IsNull(RDKitMol.Parse(InvalidValue)); }
public static object RDKit_HasSubstructMatch( [ExcelArgument(Description = "SMILES to match.")] string smiles, [ExcelArgument(Description = "SMARTS of substructure.")] string smarts) { var key = new Tuple <string, string>(smiles, smarts); var result = HasSubstructMatchCache.GetOrAdd(key, tuple => { string a_smiles = tuple.Item1; string a_smarts = tuple.Item2; var mol = RDKitMol.Parse(a_smiles); if (mol == null) { return(null); } var query = RDKitSmarts.Parse(a_smarts); if (query == null) { return(null); } return(mol.HasSubstructMatch(query)); }); return(result); }
public static string RDKit_RunReactionSmiles(string rxnIdent, string reactantsIdent) { var key = new Tuple <string, string>(rxnIdent, reactantsIdent); var result = RunReactionCache.GetOrAdd(key, tuple => { var a_rxnIdent = tuple.Item1; var a_reactantsIdent = tuple.Item2; try { var rxn = RDKitChemicalReaction.Parse(a_rxnIdent); var mols = new List <ROMol>(); foreach (var reactant_smiles in a_reactantsIdent.Split('.')) { var mol = RDKitMol.Parse(reactant_smiles); if (mol == null) { return(null); } mol = mol.AddHs(); mols.Add(mol); } if (rxn.getNumReactantTemplates() != mols.Count) { return(null); } var reactants = new ROMol_Vect(mols); var products_candidate_list = rxn.runReactants(reactants); if (products_candidate_list.Count == 0) { return(null); } return(string.Join(".", products_candidate_list.First().Select(mol => Chem.MolToSmiles(Chem.RemoveHs(mol))))); } catch (Exception ex) { return(ex.Message); } }); return(result); }
public static string RDKit_StripMol(string smiles) { var stripped = Chem.StaticSaltRemover.StripMol(RDKitMol.Parse(smiles)); return(Chem.MolToSmiles(stripped)); }