如何相互转换 InChI 和 InChIKey? [英] How to interconvert InChI and InChIKey?

查看:73
本文介绍了如何相互转换 InChI 和 InChIKey?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 InChI 作为输入从多个数据库中检索 ID,例如

I would like to retrieve IDs from several databases using InChI as an input, e.g.

InChI=1S/C6H14N2O2/c7-4-2-1-3-5(8)6(9)10/h5H,1-4,7-8H2,(H,9,10)/t5-/m0/s1

可以使用 bioservices 中的 unichem然而,为此,这些函数都需要 InChIKey 作为输入,例如

One can use unichem from bioservices for this, however, these functions all require the InChIKey as input, e.g.

KDXKERNSBIXSRK-YFKPBYRVSA-N

是否可以使用 bioservices 将两者相互转换,如果不能,是否可以以某种方式使用 unichem 中的函数与 InChI 而不是InChIKey?

Is it possible to interconvert the two using bioservices and if not is it possible to somehow use the functions in unichem with InChI rather than the InChIKey?

我试过了:

from bioservices import *
u = UniChem()
u.get_src_compound_ids_from_inchikey('KDXKERNSBIXSRK-YFKPBYRVSA-N')

不过效果很好,

u.get_src_compound_ids_from_inchikey('InChI=1S/C6H14N2O2/c7-4-2-1-3-5(8)6(9)10/h5H,1-4,7-8H2,(H,9,10)/t5-/m0/s1')

不起作用并返回 400.

推荐答案

不确定是否可以直接在 bioservices 中使用,但可以使用 chemspider:

Not sure if directly possible in bioservices but one can do the following workaround using chemspider:

import requests

host = "http://www.chemspider.com"
getstring = "/InChI.asmx/InChIToInChIKey?inchi="
inchi = 'InChI=1S/C6H14N2O2/c7-4-2-1-3-5(8)6(9)10/h5H,1-4,7-8H2,(H,9,10)/t5-/m0/s1'

r = requests.get('{}{}{}'.format(host, getstring, inchi))
if r.ok:
    res = str(r.text.replace('<?xml version="1.0" encoding="utf-8"?>\r\n<string xmlns="http://www.chemspider.com/">', '').replace('</string>', '').strip())
else:
    print "provide a valid inchi!"

这将提供所需的 InChIKey

This will give the desired InChIKey

'KDXKERNSBIXSRK-YFKPBYRVSA-N'

可以在unichem中使用.

这篇关于如何相互转换 InChI 和 InChIKey?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆