/// <summary> /// Calculates the Crippen SLogP VSA contributions from each atom /// </summary> /// <param name="mol"></param> /// <returns></returns> public static double[] CrippenSLogPVsaContributions(this OBMol mol, bool includeHydrogens) { var newMol = includeHydrogens ? mol.AddExplicitHydrogens() : mol; var result = new List <double>(); foreach (var atom in newMol.Atoms()) { var key = atom.GetCrippenKey(); if (!string.IsNullOrEmpty(key)) { result.Add(CrippenConstants.GetLogP(key)); } } return(result.ToArray()); }
/// <summary> /// Retrieves first relevant atom type based on SMARTS pattern that matches atom /// </summary> /// <param name="atom"></param> /// <returns>Crippen Atom Type key if atom matches a pattern, otherwise empty string.</returns> public static string GetCrippenKey(this OBAtom atom) { var element = atom.GetCrippenAtomType(); if (string.IsNullOrEmpty(element)) { throw new Exception(string.Format("Crippen atom type could not be determined for {0}", atom.GetAtomicNum())); } var keys = CrippenConstants.CrippenContributions.Where(g => g.Key.Contains(element)).Select(g => g.Key); foreach (var key in keys) { foreach (var pattern in CrippenConstants.GetSmarts(key)) { if (atom.MatchesSMARTS(pattern)) { return(key); } } } return(string.Empty); }