Package rdkit ::
Package DataStructs
|
|
1
2
3
4
5
6
7
8
9
10
11 from __future__ import division
12 from rdkit import rdBase
13 from rdkit.DataStructs import cDataStructs
14 from rdkit.DataStructs.cDataStructs import *
15
16 __doc__ = cDataStructs.__doc__
17
18 similarityFunctions = [
19 ('Tanimoto', TanimotoSimilarity, ''),
20 ("Dice", DiceSimilarity, ''),
21 ("Cosine", CosineSimilarity, ''),
22 ("Sokal", SokalSimilarity, ''),
23 ("Russel", RusselSimilarity, ''),
24 ("RogotGoldberg", RogotGoldbergSimilarity, ''),
25 ("AllBit", AllBitSimilarity, ''),
26 ("Kulczynski", KulczynskiSimilarity, ''),
27 ("McConnaughey", McConnaugheySimilarity, ''),
28 ("Asymmetric", AsymmetricSimilarity, ''),
29 ("BraunBlanquet", BraunBlanquetSimilarity, ''),
30 ]
31
32
34 """ returns the calculated similarity between two fingerprints,
35 handles any folding that may need to be done to ensure that they
36 are compatible
37
38 """
39 sz1 = fp1.GetNumBits()
40 sz2 = fp2.GetNumBits()
41 if sz1 < sz2:
42 fp2 = FoldFingerprint(fp2, sz2 // sz1)
43 elif sz2 < sz1:
44 fp1 = FoldFingerprint(fp1, sz1 // sz2)
45 return metric(fp1, fp2)
46
47
49 while fp.GetNumOnBits() / len(fp) > density and len(fp) // 2 > minLength:
50 fp = FoldFingerprint(fp, 2)
51 return fp
52
53
54 ExplicitBitVect.ToBitString = BitVectToText
55 SparseBitVect.ToBitString = BitVectToText
56