| Trees | Indices | Help |
|
|---|
|
|
1 # $Id$
2 #
3 # Copyright (C) 2009 Greg Landrum
4 # All Rights Reserved
5 #
6 from __future__ import print_function
7 from rdkit.six.moves import cPickle
8 from rdkit.six import iterkeys
9 from rdkit import DataStructs, Chem
10 from rdkit import Chem
11
12 similarityMethods = {
13 'RDK': DataStructs.ExplicitBitVect,
14 'AtomPairs': DataStructs.IntSparseIntVect,
15 'TopologicalTorsions': DataStructs.LongSparseIntVect,
16 'Pharm2D': DataStructs.SparseBitVect,
17 'Gobbi2D': DataStructs.SparseBitVect,
18 'Morgan': DataStructs.UIntSparseIntVect,
19 'Avalon': DataStructs.ExplicitBitVect,
20 }
21 supportedSimilarityMethods = list(iterkeys(similarityMethods))
25 loadLayerFlags = 0xFFFFFFFF
26 searchLayerFlags = 0x7
27 minPath = 1
28 maxPath = 6
29 fpSize = 1024
30 wordSize = 32
31 nWords = fpSize // wordSize
32
33 @staticmethod
35 if query:
36 flags = LayeredOptions.searchLayerFlags
37 else:
38 flags = LayeredOptions.loadLayerFlags
39 return Chem.LayeredFingerprint(mol, layerFlags=flags, minPath=LayeredOptions.minPath,
40 maxPath=LayeredOptions.maxPath, fpSize=LayeredOptions.fpSize)
41
42 @staticmethod
44 txt = LayeredOptions.GetFingerprint(mol, query=query).ToBitString()
45 words = [int(txt[x:x + 32], 2) for x in range(0, len(txt), 32)]
46 return words
47
48 @staticmethod
58
59
60 -def BuildSigFactory(options=None, fdefFile=None,
61 bins=[(2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 100)],
62 skipFeats=('LumpedHydrophobe', 'ZnBinder')):
63 if options:
64 fdefFile = options.fdefFile
65 if not fdefFile:
66 raise ValueError('bad fdef file')
67 from rdkit.Chem import ChemicalFeatures
68 from rdkit.Chem.Pharm2D import SigFactory
69 featFactory = ChemicalFeatures.BuildFeatureFactory(fdefFile)
70 sigFactory = SigFactory.SigFactory(featFactory, skipFeats=skipFeats, trianglePruneBins=False)
71 sigFactory.SetBins(bins)
72 return sigFactory
73
76 from rdkit.Chem.AtomPairs import Pairs
77 fp = Pairs.GetAtomPairFingerprintAsIntVect(mol)
78 fp._sumCache = fp.GetTotalVal()
79 return fp
80
83 from rdkit.Chem.AtomPairs import Torsions
84 fp = Torsions.GetTopologicalTorsionFingerprintAsIntVect(mol)
85 fp._sumCache = fp.GetTotalVal()
86 return fp
87
92
95 global sigFactory
96 from rdkit.Chem.Pharm2D import Generate
97 try:
98 fp = Generate.Gen2DFingerprint(mol, sigFactory)
99 except IndexError:
100 print('FAIL:', Chem.MolToSmiles(mol, True))
101 raise
102 return fp
103
106 from rdkit.Chem import rdMolDescriptors
107 fp = rdMolDescriptors.GetMorganFingerprint(mol, 2)
108 fp._sumCache = fp.GetTotalVal()
109 return fp
110
113 from rdkit.Avalon import pyAvalonTools
114 if smiles is None:
115 fp = pyAvalonTools.GetAvalonFP(mol)
116 else:
117 fp = pyAvalonTools.GetAvalonFP(smiles, True)
118 return fp
119
122 if not isinstance(pkl, (bytes, str)):
123 pkl = str(pkl)
124 try:
125 klass = similarityMethods[similarityMethod]
126 fp = klass(pkl)
127 except Exception:
128 import traceback
129 traceback.print_exc()
130 fp = cPickle.loads(pkl)
131 return fp
132
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Oct 8 11:32:04 2017 | http://epydoc.sourceforge.net |