
OMG,我最近这么懒散,公众号放养状态,竟然今天新增了6个人,各位观众老爷,你们这样子让我这个几十天不更新的人很惶恐啊。

看一个好东西,pubchem,业界很有名的分子数据库。
有很多分子数据可以从上面下载,

主页:https://pubchem.ncbi.nlm.nih.gov/
基本上输入分子就可以查询信息,还有2d,3d结构文件可以下载。
今天不说使用,其实你自己上手看看就应该会的。
看一个pubchem的python 包
官网信息:https://pubchempy.readthedocs.io/en/latest/
#安装:
pip install pubchempy
conda install -c mcs07 pubchempy
#上述两者均可
#使用
import pubchempy as pcp
#查看帮助文档
help(pcp)
#使用cid号获取信息
c = pcp.Compound.from_cid(5090)
#获取帮助信息,关于c的
help(c)
#查看c的信息
#inchi码
c.inchi
'InChI=1S/C17H14O4S/c1-22(19,20)14-9-7-12(8-10-14)15-11-21-17(18)16(15)13-5-3-2-4-6-13/h2-10H,11H2,1H3'
#原子
c.atoms
[Atom(1, S), Atom(2, O), Atom(3, O), Atom(4, O), Atom(5, O), Atom(6, C), Atom(7, C), Atom(8, C), Atom(9, C), Atom(10, C), Atom(11, C), Atom(12, C), Atom(13, C), Atom(14, C), Atom(15, C), Atom(16, C), Atom(17, C), Atom(18, C), Atom(19, C), Atom(20, C), Atom(21, C), Atom(22, C), Atom(23, H), Atom(24, H), Atom(25, H), Atom(26, H), Atom(27, H), Atom(28, H), Atom(29, H), Atom(30, H), Atom(31, H), Atom(32, H), Atom(33, H), Atom(34, H), Atom(35, H), Atom(36, H)]
#或者不知道名字
#使用同源名来进行搜索
a=pcp.get_synonyms('Aspirin', 'name')
#返回了一个列表,列表中的元素是字典
#额,不懂的去补习一下python
#查看一下
a[0]
#输出
['CID']2244
#然后,再完整输出所有信息
#查看全部属性
dir(c)
#输出全部属性信息
for attr in dir(c):
if '_' not in attr:
print(eval('c.%s'%attr))
#你忘掉了了python之禅了吗,那么不好看肯定不是最优
import this
The Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability counts.Special cases aren't special enough to break the rules.Although practicality beats purity.Errors should never pass silently.Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.There should be one-- and preferably only one --obvious way to do it.Although that way may not be obvious at first unless you're Dutch.Now is better than never.Although never is often better than *right* now.If the implementation is hard to explain, it's a bad idea.If the implementation is easy to explain, it may be a good idea.Namespaces are one honking great idea -- let's do more of those!
#启动pandas
import pandas as pd
#重新获取信息
df = pcp.compounds_to_frame(c, properties=['isomeric_smiles', 'xlogp', 'rotatable_bond_count'])
#输出
df
#好看多了
jupyter-notebook 文件在这里:
https://github.com/luskyqi1995/pubchem/blob/master/pubchem.ipynb
小tip:
https://pubchem.ncbi.nlm.nih.gov/compound/57-27-2
等于
https://pubchem.ncbi.nlm.nih.gov/compound/5288826