/// <summary> /// Calculate Tanimoto similarity between two compounds /// </summary> /// <param name="fp1"></param> /// <param name="rp2"></param> /// <returns></returns> double CalculateSimilarity( CompoundStructureActivityData cd1, CompoundStructureActivityData cd2) { int l1 = -1, l2 = -1; if (cd1.BitsetFingerprint == null || cd2.BitsetFingerprint == null) return 0; if (Debug) { if ((cd1.Cid == "111" && cd2.Cid == "222") || (cd2.Cid == "222" && cd1.Cid == "111")) { DebugLog.Message("Before: " + cd1.Cid + ": " + String.Join(", ", CdkMolUtil.GetBitSet(cd1.BitsetFingerprint))); DebugLog.Message("Before: " + cd2.Cid + ": " + String.Join(", ", CdkMolUtil.GetBitSet(cd2.BitsetFingerprint))); } } double sim = MoleculeMx.CalculateBitSetFingerprintSimilarity(cd1.BitsetFingerprint, cd2.BitsetFingerprint); if (Debug) { if ((cd1.Cid == "111" && cd2.Cid == "222") || (cd2.Cid == "222" && cd1.Cid == "111")) { DebugLog.Message(cd1.Cid + ": " + String.Join(", ", CdkMolUtil.GetBitSet(cd1.BitsetFingerprint))); DebugLog.Message(cd2.Cid + ": " + String.Join(", ", CdkMolUtil.GetBitSet(cd2.BitsetFingerprint))); DebugLog.Message(cd1.Cid + ", " + cd2.Cid + " Similarity: " + sim); } } return sim; }