Recommand · October 22, 2021 0

How can I get a list of neighboring Hydrogen atoms of an alpha-carbon?

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

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)

Error Output

C:\ProgramData\Miniconda3\python.exe C:/Users/pc/source/repos/_3_extended_features/_dataset_generation.py
Traceback (most recent call last):
  File "C:\Users\pc\source\repos\_3_extended_features\_dataset_generation.py", line 35, in <module>
    hydrogen_list = get_hydrogen_atoms(c_alpha_list[0])
  File "C:\Users\pc\source\repos\_3_extended_features\_dataset_generation.py", line 28, in get_hydrogen_atoms
    ns = NeighborSearch(c_alpha_atom)
  File "C:\ProgramData\Miniconda3\lib\site-packages\Bio\PDB\NeighborSearch.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

How can I correct this?

Edit:

Passing a list to NeighborSearch() gives out a different error:

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

Error Output

C:\ProgramData\Miniconda3\python.exe C:/Users/pc/source/repos/_3_extended_features/_dataset_generation.py
Traceback (most recent call last):
  File "C:\Users\pc\source\repos\_3_extended_features\_dataset_generation.py", line 35, in <module>
    hydrogen_list = get_hydrogen_atoms(c_alpha_list[0])
  File "C:\Users\pc\source\repos\_3_extended_features\_dataset_generation.py", line 29, in get_hydrogen_atoms
    return ns.search_all(10.0, "H")
  File "C:\ProgramData\Miniconda3\lib\site-packages\Bio\PDB\NeighborSearch.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