/// <summary> /// Get the enum & text of the selected method /// </summary> /// <param name="simSearchType"></param> /// <param name="simSearchTypeName"></param> void GetSelectedMethod(out SimilaritySearchType simSearchType, out string simSearchTypeName) { simSearchType = SimilaritySearchType.Normal; simSearchTypeName = "Normal"; if (Normal.Checked) { } else if (Sub.Checked) { simSearchType = SimilaritySearchType.Sub; simSearchTypeName = "Sub"; } else if (Super.Checked) { simSearchType = SimilaritySearchType.Super; simSearchTypeName = "Super"; } else if (ECFP4.Checked) { simSearchType = SimilaritySearchType.ECFP4; simSearchTypeName = "ECFP4"; } }
/// <summary> /// Calculate similarity score /// </summary> /// <param name="query"></param> /// <param name="target"></param> /// <returns></returns> public double Molsim( MoleculeMx query, MoleculeMx target, SimilaritySearchType type) { FingerprintType fpType = FingerprintType.Undefined; if (type == SimilaritySearchType.Normal) { fpType = FingerprintType.MACCS; } else if (type == SimilaritySearchType.ECFP4) { fpType = FingerprintType.Circular; } else { throw new Exception("Similarity type not supported in this context: " + type); } bool newQuery = (QueryMol == null || QueryMol.PrimaryValue != query.PrimaryValue); if (newQuery) // recalc query keys if query has changed { QueryMol = query.Clone(); QueryFingerprint = query.BuildBitSetFingerprint(fpType); } object targetFingerprint = target.BuildBitSetFingerprint(fpType); double score = MoleculeMx.CalculateBitSetFingerprintSimilarity(QueryFingerprint, targetFingerprint); return(score); }