【问题标题】:how the multiple pdbs can be written in single pdb file using biopython libraries如何使用 biopython 库将多个 pdb 写入单个 pdb 文件
【发布时间】:2015-03-16 07:44:21
【问题描述】:

我想知道如何使用biopython 库将多个 pdb 写入单个 pdb 文件。对于读取多个pdb,例如NMR结构,documentation中有内容,但对于写作,我没有找到。有人对此有想法吗?

【问题讨论】:

    标签: biopython


    【解决方案1】:

    是的,你可以。它记录在here。 图片您有一个结构对象列表,我们将其命名为structures。您可能想尝试:

    from bio import PDB
    
    pdb_io = PDB.PDBIO()
    
    target_file = 'all_struc.pdb'
    with pdb_file as open_file:
        for struct in structures:
            pdb_io.set_structure(struct[0])
            pdb_io.save(open_file)
    

    这是解决此问题的最简单方法。一些重要的事情:

    • 不同的蛋白质晶体结构有不同的坐标系,那你可能需要superimpose他们。或者应用一些转换函数进行比较。
    • 在 pdb_io.set_structure 中,您可以选择一个实体或一个链,甚至是一堆原子。
    • 在 pdb_io.save 中有一个辅助参数,它是一个 Select 类实例。它将帮助您去除水、杂原子、不需要的链......

    请注意,NMR 结构包含多个实体。您可能想选择一个。希望对您有所帮助。

    【讨论】:

    • 谢谢mithrado,但这并不能解决我的问题。
    【解决方案2】:

    Mithrado 的解决方案实际上可能无法实现您想要的。使用他的代码,您确实可以将所有结构写入一个文件。但是,它以其他软件可能无法读取的方式这样做。它在每个结构之后添加一个“END”行。许多软件会在此时停止读取文件,因为这是指定 PDB 文件格式的方式。

    一个更好但仍不完美的解决方案是从一个结构中删除一个链并将其作为不同的链添加到第二个结构中。你可以这样做:

    # Get a list of the chains in a structure
    chains = list(structure2.get_chains())
    # Rename the chain (in my case, I rename from 'A' to 'B')
    chains[0].id = 'B'
    # Detach this chain from structure2
    chains[0].detach_parent()
    # Add it onto structure1
    structure1[0].add(chains[0])
    

    请注意,您必须小心,您要添加的链的名称在 structure1 中尚不存在。

    在我看来,Biopython 库在许多方面结构不佳或不直观,这只是一个例子。如果可以,请使用其他东西。

    【讨论】:

    • 理想情况下,这可能会提供解决问题的洞察力。谢谢内特。
    【解决方案3】:

    受 Nate 解决方案的启发,但将多个模型添加到一个结构,而不是多个链到一个模型:

    ms = PDB.Structure.Structure("master")
    
    i=0
    for structure in structures:
        for model in list(structure):
            new_model=model.copy()
            new_model.id=i
            new_model.serial_num=i+1
            i=i+1
            ms.add(new_model)
    
    pdb_io = PDB.PDBIO()
    pdb_io.set_structure(ms)
    pdb_io.save("all.pdb")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 2010-09-09
      • 1970-01-01
      • 2012-09-08
      • 1970-01-01
      相关资源
      最近更新 更多