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 @staticmethod5835 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 @staticmethod44 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 words47 48 @staticmethod50 words = LayeredOptions.GetWords(mol, query=query) 51 colqs = [] 52 for idx, word in enumerate(words): 53 if not word: 54 continue 55 idx = idx + 1 56 colqs.append('%(word)d&Col_%(idx)d=%(word)d' % locals()) 57 return ' and '.join(colqs)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 sigFactory7376 from rdkit.Chem.AtomPairs import Pairs 77 fp = Pairs.GetAtomPairFingerprintAsIntVect(mol) 78 fp._sumCache = fp.GetTotalVal() 79 return fp8083 from rdkit.Chem.AtomPairs import Torsions 84 fp = Torsions.GetTopologicalTorsionFingerprintAsIntVect(mol) 85 fp._sumCache = fp.GetTotalVal() 86 return fp87 9295 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 fp103106 from rdkit.Chem import rdMolDescriptors 107 fp = rdMolDescriptors.GetMorganFingerprint(mol, 2) 108 fp._sumCache = fp.GetTotalVal() 109 return fp110113 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 fp119122 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 fp132
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Mar 26 11:18:47 2018 | http://epydoc.sourceforge.net |