我怎样才能得到一个α-碳的相邻氢原子的列表呢?

How can I get a list of neighboring Hydrogen atoms of an alpha-carbon?(我怎样才能得到一个α-碳的相邻氢原子的列表呢?)

本文介绍了我怎样才能得到一个α-碳的相邻氢原子的列表呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设,我想找到特定C-α原子的邻近氢原子。

from typing import List
from Bio.PDB import Chain, Atom, NeighborSearch, PDBParser


def get_hydrogen_atoms(c_alpha_atom: Atom.Atom):
    ns = NeighborSearch(c_alpha_atom)
    return ns.search_all(10.0, "H")

p = PDBParser()
structure = p.get_structure('16pk', '16pk.pdb')

c_alpha_list = [atom for atom in structure.get_atoms() if atom.name == 'CA']
hydrogen_list = get_hydrogen_atoms(c_alpha_list[0])

print(hydrogen_list)

错误输出

C:ProgramDataMiniconda3python.exe C:/Users/pc/source/repos/_3_extended_features/_dataset_generation.py
Traceback (most recent call last):
  File "C:Userspcsource
epos\_3_extended_features\_dataset_generation.py", line 35, in <module>
    hydrogen_list = get_hydrogen_atoms(c_alpha_list[0])
  File "C:Userspcsource
epos\_3_extended_features\_dataset_generation.py", line 28, in get_hydrogen_atoms
    ns = NeighborSearch(c_alpha_atom)
  File "C:ProgramDataMiniconda3libsite-packagesBioPDBNeighborSearch.py", line 45, in __init__
    coord_list = [a.get_coord() for a in atom_list]
TypeError: 'Atom' object is not iterable

Process finished with exit code 1

我如何更正此错误?

编辑:

将列表传递给NeighborSearch()会产生不同的错误:

def get_hydrogen_atoms(c_alpha_atom: Atom.Atom):
    ns = NeighborSearch([c_alpha_atom])
    return ns.search_all(10.0, "H")

错误输出

C:ProgramDataMiniconda3python.exe C:/Users/pc/source/repos/_3_extended_features/_dataset_generation.py
Traceback (most recent call last):
  File "C:Userspcsource
epos\_3_extended_features\_dataset_generation.py", line 35, in <module>
    hydrogen_list = get_hydrogen_atoms(c_alpha_list[0])
  File "C:Userspcsource
epos\_3_extended_features\_dataset_generation.py", line 29, in get_hydrogen_atoms
    return ns.search_all(10.0, "H")
  File "C:ProgramDataMiniconda3libsite-packagesBioPDBNeighborSearch.py", line 113, in search_all
    raise PDBException("%s: Unknown level" % level)
Bio.PDB.PDBExceptions.PDBException: H: Unknown level

Process finished with exit code 1

推荐答案

OK获得一些代码:

from Bio.PDB import Chain, Atom, NeighborSearch, PDBParser, Selection


def get_hydrogen_atoms(c_alpha_atom: Atom.Atom, po):
    ns = NeighborSearch(po)
    return [h for h in ns.search( c_alpha_atom.get_coord(), 10.0, 'A') if h.element == 'H']

p = PDBParser()
# structure = p.get_structure('16pk', '16pk.pdb')
structure = p.get_structure('16pk', 'pH8_5_1bq9_short.pdb')

c_alpha_list = [atom for atom in structure.get_atoms() if atom.name == "CA"]

print('c_alpha_list[0]  : ', c_alpha_list[0], c_alpha_list[0].id , c_alpha_list[0].get_serial_number(),'
')

po = Selection.unfold_entities(structure, 'A')
                               
hydrogen_list = get_hydrogen_atoms(c_alpha_list[0], po)

print('hydrogen_list : 
',hydrogen_list)

print('
Selection (po) : 
', po)

必须使用不同的PDB文件,因为我需要H原子,

pH8_5_1bq9_Short.pdb:

HETATM    1  N   FME A   1      23.447  -5.765   5.119  1.00 19.07           N
HETATM    2  CN  FME A   1      23.308  -6.776   4.291  1.00 20.46           C
HETATM    3  O1  FME A   1      22.504  -6.713   3.357  1.00 24.75           O
HETATM    4  CA  FME A   1      22.488  -4.745   5.410  1.00 18.15           C
HETATM    5  CB  FME A   1      22.433  -4.342   6.827  1.00 21.15           C
HETATM    6  CG  FME A   1      22.198  -5.618   7.751  1.00 22.84           C
HETATM    7  SD  FME A   1      20.445  -6.032   7.772  1.00 23.40           S
HETATM    8  CE  FME A   1      20.476  -7.587   8.656  1.00 28.76           C
HETATM    9  C   FME A   1      22.699  -3.530   4.487  1.00 17.12           C
HETATM   10  O   FME A   1      23.804  -3.248   4.077  1.00 20.25           O
HETATM    0 3HE  FME A   1      19.574  -7.938   8.726  1.00 28.76           H   new
HETATM    0 2HG  FME A   1      22.713  -6.369   7.418  1.00 22.84           H   new
HETATM    0 2HE  FME A   1      21.032  -8.221   8.177  1.00 28.76           H   new
HETATM    0 2HB  FME A   1      23.260  -3.901   7.077  1.00 21.15           H   new
HETATM    0 1HG  FME A   1      22.508  -5.438   8.652  1.00 22.84           H   new
HETATM    0 1HE  FME A   1      20.838  -7.447   9.545  1.00 28.76           H   new
HETATM    0 1HB  FME A   1      21.717  -3.701   6.961  1.00 21.15           H   new
HETATM    0  HN  FME A   1      24.199  -5.711   5.532  1.00 19.07           H   new
HETATM    0  HCN FME A   1      23.841  -7.577   4.415  1.00 20.46           H   new
HETATM    0  HA  FME A   1      21.619  -5.138   5.231  1.00 18.15           H   new
ATOM     11  N   ALA A   2      21.633  -2.939   4.043  1.00 15.50           N
ATOM     12  CA  ALA A   2      21.644  -1.884   3.062  1.00 15.08           C
ATOM     13  C   ALA A   2      20.899  -0.661   3.519  1.00 13.72           C
ATOM     14  O   ALA A   2      20.278  -0.702   4.584  1.00 13.49           O
ATOM     15  CB  ALA A   2      21.083  -2.339   1.710  1.00 17.86           C
ATOM      0  H   ALA A   2      20.842  -3.144   4.312  1.00 15.50           H   new
ATOM      0  HA  ALA A   2      22.579  -1.652   2.951  1.00 15.08           H   new
ATOM      0  HB1 ALA A   2      21.110  -1.599   1.083  1.00 17.86           H   new
ATOM      0  HB2 ALA A   2      21.618  -3.072   1.368  1.00 17.86           H   new
ATOM      0  HB3 ALA A   2      20.166  -2.634   1.823  1.00 17.86           H   new
ATOM     16  N   LYS A   3      21.005   0.412   2.774  1.00 12.48           N
ATOM     17  CA  LYS A   3      20.341   1.658   3.029  1.00 12.61           C
ATOM     18  C   LYS A   3      19.415   1.991   1.879  1.00 11.53           C
ATOM     19  O   LYS A   3      19.784   1.753   0.701  1.00 11.66           O
ATOM     20  CB  LYS A   3      21.338   2.806   3.273  1.00 13.38           C
ATOM     21  CG  LYS A   3      22.062   2.721   4.593  1.00 16.70           C
ATOM     22  CD  LYS A   3      23.062   3.847   4.814  1.00 18.05           C
ATOM     23  CE  LYS A   3      23.806   3.576   6.136  1.00 20.42           C
ATOM     24  NZ  LYS A   3      24.878   4.503   6.403  1.00 22.91           N
ATOM      0  H   LYS A   3      21.494   0.433   2.067  1.00 12.48           H   new
ATOM      0  HA  LYS A   3      19.821   1.557   3.842  1.00 12.61           H   new
ATOM      0  HB2 LYS A   3      21.992   2.812   2.556  1.00 13.38           H   new
ATOM      0  HB3 LYS A   3      20.862   3.650   3.230  1.00 13.38           H   new
ATOM      0  HG2 LYS A   3      21.411   2.732   5.312  1.00 16.70           H   new
ATOM      0  HG3 LYS A   3      22.527   1.871   4.644  1.00 16.70           H   new
ATOM      0  HD2 LYS A   3      23.689   3.892   4.076  1.00 18.05           H   new
ATOM      0  HD3 LYS A   3      22.606   4.702   4.851  1.00 18.05           H   new
ATOM      0  HE2 LYS A   3      23.170   3.611   6.868  1.00 20.42           H   new
ATOM      0  HE3 LYS A   3      24.166   2.676   6.116  1.00 20.42           H   new
ATOM      0  HZ1 LYS A   3      25.266   4.294   7.176  1.00 22.91           H   new
ATOM      0  HZ2 LYS A   3      25.479   4.458   5.748  1.00 22.91           H   new
ATOM      0  HZ3 LYS A   3      24.551   5.330   6.449  1.00 22.91           H   new
ATOM     25  N   TRP A   4      18.274   2.598   2.165  1.00 10.75           N
ATOM     26  CA  TRP A   4      17.283   3.019   1.181  1.00 10.69           C
ATOM     27  C   TRP A   4      16.875   4.472   1.502  1.00 11.37           C
ATOM     28  O   TRP A   4      16.812   4.872   2.651  1.00 17.19           O
ATOM     29  CB  TRP A   4      16.012   2.143   1.352  1.00 11.20           C
ATOM     30  CG  TRP A   4      16.164   0.734   0.997  1.00 11.80           C
ATOM     31  CD1 TRP A   4      16.913  -0.218   1.669  1.00 12.50           C
ATOM     32  CD2 TRP A   4      15.535   0.036  -0.079  1.00 11.53           C
ATOM     33  NE1 TRP A   4      16.806  -1.435   1.050  1.00 12.76           N
ATOM     34  CE2 TRP A   4      15.959  -1.302  -0.013  1.00 12.61           C
ATOM     35  CE3 TRP A   4      14.642   0.421  -1.079  1.00 11.88           C
ATOM     36  CZ2 TRP A   4      15.531  -2.258  -0.929  1.00 13.18           C
ATOM     37  CZ3 TRP A   4      14.217  -0.527  -1.989  1.00 12.54           C
ATOM     38  CH2 TRP A   4      14.668  -1.858  -1.894  1.00 14.26           C

输出:

c_alpha_list[0]  :  <Atom CA> CA 4 

hydrogen_list : 
 [<Atom HB1>, <Atom HB3>, <Atom H>, <Atom 2HE>, <Atom 3HE>, <Atom 1HE>, <Atom HB3>, <Atom HA>, <Atom HG2>, <Atom HB2>, <Atom HCN>, <Atom HA>, <Atom HN>, <Atom 1HB>, <Atom 2HB>, <Atom 2HG>, <Atom 1HG>, <Atom H>, <Atom HB2>, <Atom HA>, <Atom HD2>, <Atom HG3>, <Atom HD3>, <Atom HZ2>, <Atom HE3>, <Atom HE2>, <Atom HZ1>]

Selection (po) : 
 [<Atom N>, <Atom CN>, <Atom O1>, <Atom CA>, <Atom CB>, <Atom CG>, <Atom SD>, <Atom CE>, <Atom C>, <Atom O>, <Atom 3HE>, <Atom 2HG>, <Atom 2HE>, <Atom 2HB>, <Atom 1HG>, <Atom 1HE>, <Atom 1HB>, <Atom HN>, <Atom HCN>, <Atom HA>, <Atom N>, <Atom CA>, <Atom C>, <Atom O>, <Atom CB>, <Atom H>, <Atom HA>, <Atom HB1>, <Atom HB2>, <Atom HB3>, <Atom N>, <Atom CA>, <Atom C>, <Atom O>, <Atom CB>, <Atom CG>, <Atom CD>, <Atom CE>, <Atom NZ>, <Atom H>, <Atom HA>, <Atom HB2>, <Atom HB3>, <Atom HG2>, <Atom HG3>, <Atom HD2>, <Atom HD3>, <Atom HE2>, <Atom HE3>, <Atom HZ1>, <Atom HZ2>, <Atom HZ3>, <Atom N>, <Atom CA>, <Atom C>, <Atom O>, <Atom CB>, <Atom CG>, <Atom CD1>, <Atom CD2>, <Atom NE1>, <Atom CE2>, <Atom CE3>, <Atom CZ2>, <Atom CZ3>, <Atom CH2>]

选择列表同时包含ATOM和HETATM

了解一下:https://www.biostars.org/p/269579/如何使用生物搜索?

和Bio.PDB.NeighborSearch模块:https://biopython.org/docs/1.75/api/Bio.PDB.NeighborSearch.html;

Bio.PDB.Atom模块:https://biopython.org/docs/1.75/api/Bio.PDB.Atom.html

这篇关于我怎样才能得到一个α-碳的相邻氢原子的列表呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:我怎样才能得到一个α-碳的相邻氢原子的列表呢?

基础教程推荐