def rdkit_descriptor(self, smiles, descriptor=u'MolLogP'):
try:
self.rdkit_info_num_calls = self.rdkit_info_num_calls + 1
# win32api.OutputDebugString(str(type(smiles)) + " " + str(type(descriptor)))
smiles = dispatch_to_str(smiles)
descriptor = dispatch_to_str(descriptor)
myfunction = getattr(Descriptors, descriptor)
mol = Chem.MolFromSmiles(smiles)
if mol != None:
return myfunction(mol)
else:
# OK, so you are wondering how on Earth a function that is marked up
# as out:float can return a string ?! Me too, but it works :-), and
# makes it possible to show a decent error to the end user.
# Apparently COM returns the value as a variant regardless of the
# specified IDL retval type (?)...
return 'ERROR: Cannot parse SMILES input.'
except Exception as e:
return "ERROR: " + str(e)
# Generates a molfile with 2D coordinates from SMILES input. Useful for depiction.
#RDKITXL: in:smiles:str, out:str
评论列表
文章目录