samirelanduk / atomium

Python macromolecular parsing (with .pdb/.cif/.mmtf parsing and production)
https://atomium.bio
MIT License
103 stars 19 forks source link

getting the residue details from an atom #33

Closed rbf22 closed 3 years ago

rbf22 commented 3 years ago

it would be great if while iterating over nearby atoms it was possible to access the chain and residues for these atoms. Is there a way to do this?

for example:

for atom_i in model.atoms():
  for atom_j in atom_i.nearby(6.):
    print(atom_j.chain, atom_j.residue_name, atom_j.residue_number)
samirelanduk commented 3 years ago

The following works for me:

for atom_i in model.atoms():
    for atom_j in atom_i.nearby_atoms(6.):
        print(atom_j.chain, atom_j.het.name, atom_j.het.id.split(".")[1])

The residue number is a bit convoluted because residues currently just have an ID of the form A.123 - I think I should make the number a separate property in future.

rbf22 commented 3 years ago

Is there a way to get the residue type, i.e. THR, SER etc?

samirelanduk commented 3 years ago

atom.het.name returns the residue type.