|
Package rdkit ::
Package DataStructs
|
|
1
2
3
4
5
6
7 from rdkit import rdBase
8 import cDataStructs
9 __doc__=cDataStructs.__doc__
10 from cDataStructs import *
11
12
13 similarityFunctions=[
14 ('Tanimoto',TanimotoSimilarity,''),
15 ("Dice",DiceSimilarity,''),
16 ("Cosine",CosineSimilarity,''),
17 ("Sokal",SokalSimilarity,''),
18 ("Russel",RusselSimilarity,''),
19 ("Kulczynski",KulczynskiSimilarity,''),
20 ("McConnaughey",McConnaugheySimilarity,''),
21 ("Asymmetric",AsymmetricSimilarity,''),
22 ("BraunBlanquet",BraunBlanquetSimilarity,''),
23 ]
24
26 """ returns the calculated similarity between two fingerprints,
27 handles any folding that may need to be done to ensure that they
28 are compatible
29
30 """
31 sz1 = fp1.GetNumBits()
32 sz2 = fp2.GetNumBits()
33 if sz1<sz2:
34 fp2 = FoldFingerprint(fp2,sz2/sz1)
35 elif sz2<sz1:
36 fp1 = FoldFingerprint(fp1,sz1/sz2)
37 return metric(fp1,fp2)
38
43
44 ExplicitBitVect.ToBitString = BitVectToText
45 SparseBitVect.ToBitString = BitVectToText
46