Trees | Indices | Help |
|
---|
|
1 # $Id$ 2 # 3 # Copyright (C) 2002-2010 greg Landrum and Rational Discovery LLC 4 # 5 # @@ All Rights Reserved @@ 6 # This file is part of the RDKit. 7 # The contents are covered by the terms of the BSD license 8 # which is included in the file license.txt, found at the root 9 # of the RDKit source tree. 10 # 11 """ functions to match a bunch of fragment descriptors from a file 12 13 No user-servicable parts inside. ;-) 14 15 """ 16 import os 17 from rdkit import RDConfig 18 from rdkit import Chem 19 20 21 defaultPatternFileName = os.path.join(RDConfig.RDDataDir,'FragmentDescriptors.csv') 22 25 26 fns = []28 if fileName is None: 29 fileName = defaultPatternFileName 30 try: 31 with open(fileName,'r') as inF: 32 for line in inF.readlines(): 33 if len(line) and line[0] != '#': 34 splitL = line.split('\t') 35 if len(splitL)>=3: 36 name = splitL[0] 37 descr = splitL[1] 38 sma = splitL[2] 39 descr=descr.replace('"','') 40 patt = Chem.MolFromSmarts(sma) 41 if not patt or patt.GetNumAtoms()==0: 42 raise ImportError('Smarts %s could not be parsed'%(repr(sma))) 43 fn = lambda mol,countUnique=True,pattern=patt:_CountMatches(mol,pattern,unique=countUnique) 44 fn.__doc__ = descr 45 name = name.replace('=','_') 46 name = name.replace('-','_') 47 fns.append((name,fn)) 48 except IOError: 49 pass50 51 _LoadPatterns() 52 for name,fn in fns: 53 exec('%s=fn'%(name)) 54 fn=None 55
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Aug 25 09:15:56 2016 | http://epydoc.sourceforge.net |