0
$\begingroup$

Suppose, I want to find the neighboring Hydrogen atoms of a specific C-alpha atom.

The following was my effort. However, it produces a bunch of empty lists.

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


def get_hydrogen_atoms(c_alpha_atom):
    ns = NeighborSearch([c_alpha_atom])
    return ns.search_all(190.0, "A")

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

c_alpha_list = [atom for atom in structure.get_atoms()]

for c_alpha in c_alpha_list:
    if c_alpha.name == "CA":
        hydrogen_list = get_hydrogen_atoms(c_alpha)
        print(hydrogen_list)

How can I correct this?

$\endgroup$
1
  • 1
    $\begingroup$ hydrogen_list = get_hydrogen_atoms(c_alpha) should be hydrogen_list.append(get_hydrogen_atoms(c_alpha)). Also your structure needs to be protonated —most crystal structures are not. radius is in Å, not pm. Cα atoms are no hydrogen bond donors/acceptors. Why no search for nearby N atomnames to the atomname O, which are donor - acceptor pairs... $\endgroup$ Commented Oct 22, 2021 at 15:24

1 Answer 1

2
$\begingroup$

You posted similar question here: https://stackoverflow.com/questions/69676943/how-can-i-get-a-list-of-neighboring-hydrogen-atoms-of-an-alpha-carbon/69815509#69815509

ok got some code :

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(),'\n')

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

print('hydrogen_list : \n',hydrogen_list)

print('\nSelection (po) : \n', po)

had to use a different PDB file because I needed the H atoms,

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

output :

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>]

the selection list contains both ATOM and HETATM

have a look at : https://www.biostars.org/p/269579/ How to use biopython neighborsearch?

and Bio.PDB.NeighborSearch module :https://biopython.org/docs/1.75/api/Bio.PDB.NeighborSearch.html ;

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.