RDKitXL_server.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:rdkit4excel 作者: janholstjensen 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号