Package Chem :: Module AvailDescriptors
[hide private]
[frames] | no frames]

Source Code for Module Chem.AvailDescriptors

 1  # $Id: AvailDescriptors.py 455 2007-12-18 06:37:48Z glandrum $ 
 2  # 
 3  # Copyright (C) 2001-2006 greg Landrum and Rational Discovery LLC 
 4  # 
 5  #   @@ All Rights Reserved  @@ 
 6  # 
 7  """ constructs the list of available descriptors 
 8   
 9  """ 
10  import types 
11  from Chem import GraphDescriptors,MolSurf,Lipinski,Fragments,Crippen,Descriptors 
12  from Chem.EState import EState_VSA 
13  mods = [GraphDescriptors,MolSurf,EState_VSA,Lipinski,Descriptors,Crippen,Fragments] 
14   
15  import Numeric,Chem 
16  otherMods = [Numeric,Chem] 
17   
18  others = [] 
19  for mod in otherMods: 
20    tmp = dir(mod) 
21    for name in tmp: 
22      if name[0] != '_': 
23        thing = getattr(mod,name) 
24        if type(thing)==types.FunctionType: 
25          others.append(name) 
26   
27  descList = [] 
28  descDict = {} 
29  for mod in mods: 
30    tmp = dir(mod) 
31   
32    for name in tmp: 
33      if name[0] != '_' and name[-1] != '_' and name not in others: 
34        thing = getattr(mod,name) 
35        if type(thing)==types.FunctionType: 
36          # we need to store the name too, just in case 
37          #  the function is a lambda 
38          descList.append((name,thing)) 
39          descDict[name] = thing 
40   
41 -def Desensitize():
42 """ puts in all upper and all lower case versions of each 43 descriptor name 44 """ 45 ks = descDict.keys() 46 for k in ks: 47 fn = descDict[k] 48 descDict[k.upper()]=fn 49 descDict[k.lower()]=fn
50 51 52 if __name__ == '__main__': 53 import Chem 54 55 m = Chem.MolFromSmiles('CCOC') 56 for name,fn in descs: 57 print name,fn(m) 58