当前位置:网站首页>Rdkit common commands/parameter settings
Rdkit common commands/parameter settings
2022-08-08 00:21:00 【Wei Gongcun Ouyang Nana】
rdkit
1.查看sdf

""" 查看sdf """
mols = Chem.SDMolSupplier('file_path')
for mol in mols:
#隐藏属性,Be the first line
ID = mol.GetProp('_Name')
#Get all the molecular properties
mol_keys = mol.GetPropsAsDict().keys()
2.Draw the visual images
可以highlightThe structure of reactants and products in the same
绘制带id的mol文件
""" Draw reaction visual images """
def draw_mol(mol_file, save_mol_path):
opts = DrawingOptions()
opts.includeAtomNumbers = True
opts.includeAtomNumbers = True
opts.bondLineWidth = 2.8
Draw.MolToFile(
mol_file, # mol对象
save_mol_path, # 图片存储地址
size=(4000, 2000),
kekulize=True,
wedgeBonds=True,
imageType=None,
fitImage=False,
options=opts,
)
""" high light """
def draw_highlight(reaction, save_reaction_path):
d2d = Draw.MolDraw2DCairo(4000, 2000)
d2d.DrawReaction(reaction, highlightByReactant=True)
png = d2d.GetDrawingText()
open(save_reaction_path, 'wb+').write(png)
""" 从molFile map labeled atom """
def mol_with_atom_index(mol_file):
atoms = mol_file.GetNumAtoms()
for idx in range(atoms):
mol_file.GetAtomWithIdx(idx).SetProp('molAtomMapNumber',
str(mol.GetAtomWithIdx(idx).GetIdx()))
def draw_mol(mol_file, save_mol_path):
opts = DrawingOptions()
opts.includeAtomNumbers = True
opts.includeAtomNumbers = True
opts.bondLineWidth = 2.8
Draw.MolToFile(
mol_file, # mol对象
save_mol_path, # 图片存储地址
size=(4000, 2000),
kekulize=True,
wedgeBonds=True,
imageType=None,
fitImage=False,
options=opts,
)
完整代码:github(Draw.py)
3.According to the reactionaamIdentification of reaction sites
aam = '[CH3:1][CH:28]([CH:26]([CH:25]=[CH:24][CH:23]([CH3:19])[C:20]1([C:17]2([C:2]([H:30])([C:3](=[CH:4][CH:5]=[C:6]3[C:7](=[CH2:8])[CH2:9][CH2:10][CH:11]([OH:12])[CH2:13]3)[CH2:14][CH2:15][CH2:16]2)[CH2:22][CH2:21]1)[CH3:18])[H:31])[CH3:27])[CH3:29]>>[CH3:1][CH:28]([CH3:29])[CH:26]([CH:25]=[CH:24][CH:23]([CH3:19])[C:20]1([C:17]2([C:2]([H:30])([C:3](=[CH:4][CH:5]=[C:6]3[C:7](=[CH2:8])[CH2:9][CH2:10][CH:11]([OH:12])[CH2:13]3)[CH2:14][CH2:15][CH2:16]2)[CH2:22][CH2:21]1)[CH3:18])[H:31])[CH3:27]'
rxn = AllChem.ReactionFromSmarts(aam)
sub_mol = Chem.MolFromSmiles(aam.split('>>')[0])
products = rxn.RunReactants([sub_mol])
print(rxn.GetReactingAtoms())
4.关于mol文件的一些参数
1.MolFromSmiles
sanitize,The molecular structure of check,默认值是True.This option will list some explicitH原子(同下面的mergeHs=True),这样的molFile some software can't identify
smi = 'xxxxxxxx'
mol = Chem.MolFromSmiles(smi, sanitize=True/False)
2.MolFromSmarts
mergeHs默认值为False,当值为True时,‘C[H]’ becomes ‘[C;!H0]’
smart = 'xxxxxxxx'
mol = Chem.MolFromSmarts(smi, mergeHs=True/False)
3.SDMolSupplier
removeHs默认值是True.是否忽略H原子
suppl = Chem.SDMolSupplier(sdf_file,removeHs=True)
4.MolToSmiles
isomericSmiles: Stereochemistry information.Defaults to true.
kekuleSmiles: No aromatic key.Defaults to false.
rootedAtAtom: smilesStarting from the particular atoms. Defaults to -1.
canonical:是否规范化.Defaults to true.
allBondsExplicit: Clear all the key.G Defaults to false.
allHsExplicit: 显示所有H.Defaults to false.
5.MolFromSmarts与MolFromSmiles

边栏推荐
猜你喜欢
随机推荐
D. Tournament Countdown(交互题)
最小公倍数三种方法(附代码)
[QNX Hypervisor 2.2用户手册]10.11 vdev progress
BOSS直聘再爆情色招聘丑闻,面试官行为不堪入目
visual studio code中rust代码debug时中文乱码的处理【win10平台】
C语言:打印水仙花数
pnpm简介和用法
论文翻译:2021_LACOPE: Latency-Constrained Pitch Estimation for Speech Enhancement
SVG基本图形
Seaborn调用load_dataset时,出现错误。 urllib.error.URLError: urlopen error [WinError 10054] 远程主机强迫关闭了
Failed to initialize NVML: Driver/library version mismatch
使用jmh框架进行benchmark测试
MYSQL高级篇-----索引优化分析
部署spark2.2集群(standalone模式)
kaggle小白必看:小白常见的2个错误解决方案
进制转换数学函数构造_GET之[CISCN 2019 初赛]Love Math
没有操作的思考
I want to open an account for stock trading, is it safe to open an account?
同花顺上面可以开户吗?开户安全吗
Shell脚本,打包文件压缩到指定目录,每天定时任务运行脚本







![LeetCode weeks checking]](/img/9e/a09e0ebec985341f972ccc6b15aa53.png)

