| 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 defaultPatternFileName = os.path.join(RDConfig.RDDataDir, 'FragmentDescriptors.csv') 21 22 25 26 27 fns = [] 28 2931 if fileName is None: 32 fileName = defaultPatternFileName 33 try: 34 with open(fileName, 'r') as inF: 35 for line in inF.readlines(): 36 if len(line) and line[0] != '#': 37 splitL = line.split('\t') 38 if len(splitL) >= 3: 39 name = splitL[0] 40 descr = splitL[1] 41 sma = splitL[2] 42 descr = descr.replace('"', '') 43 patt = Chem.MolFromSmarts(sma) 44 if not patt or patt.GetNumAtoms() == 0: 45 raise ImportError('Smarts %s could not be parsed' % (repr(sma))) 46 fn = lambda mol, countUnique=True, pattern=patt: _CountMatches(mol, pattern, unique=countUnique) 47 fn.__doc__ = descr 48 name = name.replace('=', '_') 49 name = name.replace('-', '_') 50 fns.append((name, fn)) 51 except IOError: 52 pass53 54 55 _LoadPatterns() 56 for name, fn in fns: 57 exec('%s=fn' % (name)) 58 fn = None 59
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Oct 8 11:32:02 2017 | http://epydoc.sourceforge.net |