码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 关于rdkit 错误2w08_ligand: warning - O.co2 with non C.2 or S.o2 neighbor.


    1 问题:

    读取 PDBBindv2019的数据集,尝试把所有配体的mol2文件转换成对应smiles表达式。大约超过1千个出现问题。

    在这里插入图片描述
    主要问题就是‘warning - O.co2 with non C.2 or S.o2 neighbor’。

    2 原因:

    Phosphate group - warning O.co2 with non C.2 or S.o2 neighbor
    [Rdkit-discuss] Phosphate containing mol2 files

    Since the mol2 format is a bit of an inconsistent mess, where different toolkits/packages use different dialects of the format (or different meanings for the atom types), we chose to support the dialect generated by corina.

    简单来说,mol2的格式不止一种,而RDKit采用了其中一种:corina。

    from rdkit import Chem
    Chem.MolFromMol2File():文档信息

    Docstring:
    MolFromMol2File( (str)molFileName [, (bool)sanitize=True [, (bool)removeHs=True [, 		(bool)cleanupSubstructures=True]]]) -> Mol :
    Construct a molecule from a Tripos Mol2 file.
    
      NOTE:
        The parser expects the atom-typing scheme used by Corina.
        Atom types from Tripos' dbtranslate are less supported.
        Other atom typing schemes are unlikely to work.
    
      ARGUMENTS:
                                      
        - fileName: name of the file to read
    
        - sanitize: (optional) toggles sanitization of the molecule.
          Defaults to true.
    
        - removeHs: (optional) toggles removing hydrogens from the molecule.
          This only make sense when sanitization is done.
          Defaults to true.
    
        - cleanupSubstructures: (optional) toggles standardizing some 
          substructures found in mol2 files.
          Defaults to true.
    
      RETURNS:
    
        a Mol object, None on failure.
    
    
    
    C++ signature :
        class RDKit::ROMol * __ptr64 MolFromMol2File(char const * __ptr64 [,bool=True [,bool=True [,bool=True]]]) Type:      function
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    3 解决方法

    找了半天,直接换成openbabei来读取。

    from openbabel import pybel
    pybel.readfile () 文档

    Required parameters:
       format - see the informats variable for a list of available
                input formats
       filename
    
    Optional parameters:
       opt    - a dictionary of format-specific options
                For format options with no parameters, specify the
                value as None.
    
    You can access the first molecule in a file using the next() method
    of the iterator (or the next() keyword in Python 3):
        mol = readfile("smi", "myfile.smi").next() # Python 2
        mol = next(readfile("smi", "myfile.smi"))  # Python 3
    
    You can make a list of the molecules in a file using:
        mols = list(readfile("smi", "myfile.smi"))
    
    You can iterate over the molecules in a file as shown in the
    following code snippet:
    >>> atomtotal = 0
    >>> for mol in readfile("sdf", "head.sdf"):
    ...     atomtotal += len(mol.atoms)
    ...
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    4 相关代码:

    import tqdm
    import numpy as np
    path = './v2019-other-PL/'
    def process_chunk(chunk):
        for i, row in chunk.iterrows():
            file_name = path + row["id"] + "/" + row["id"] + "_ligand.sdf"
            try:
                for mol in pybel.readfile('sdf', file_name):
                    chunk.at[i, 'Smiles'] = str(mol).split()[0]
                    print(row["id"],":",str(mol).split()[0])
            except:
                pass
        return chunk
    # df_pro 之前已经处理过的pdframe
    df_imputation = df_pro.copy()
    chunks = np.array_split(df_imputation, 100)
    out_smiles = []
    for chunk in tqdm(chunks):
        out_chunks = process_chunk(chunk)
        out_smiles.append(out_chunks)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    参考链接:
    rdkit 读取各种小分子
    批量转换.sdf文件为smiles到结构化数据表格的python脚本

  • 相关阅读:
    Spring Boot Actuator介绍
    AI绘画的崛起与多平台对比
    LeetCode --- 1365. How Many Numbers Are Smaller Than the Current Number 解题报告
    python实战故障诊断之CWRU数据集(一):数据集初识
    基于SpringBoot的学生网上请假系统
    90、00后严选出的数据可视化工具:奥威BI工具
    数据分表Mybatis Plus动态表名最优方案的探索
    半监督学习介绍(为什么半监督学习是机器学习的未来)
    将爱心代码设为电脑屏保,俘获少女芳心,还能假装黑客,在酷炫的界面中保护隐私
    轻量且强大的 uni-app http 网络库 - 掘金
  • 原文地址:https://blog.csdn.net/Tanqy1997/article/details/132956585
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号