Has hydrogens#

Checking whether a molecular system or selection contains hydrogen atoms.

The function molsysmt.build.has_hydrogens() evaluates whether hydrogen atoms are present in a molecular system or within a specific selection, returning True or False.

Added in version 1.0.0.

Basic usage#

Let’s show how this function works using T4 lysozyme (PDB ID: 181L):

import molsysmt as msm
molsys = msm.convert(msm.systems['T4 lysozyme L99A']['181l.h5msm'], to_form='molsysmt.MolSys')

Let’s check the number of hydrogen atoms using molsysmt.basic.get():

msm.get(molsys, selection='atom_type=="H"', n_atoms=True)
0

We check if the system contains hydrogen atoms using molsysmt.build.has_hydrogens():

msm.build.has_hydrogens(molsys)
False

We can also restrict the check to a specific selection (such as protein molecules):

msm.build.has_hydrogens(molsys, selection='molecule_type=="protein"')
False

Now let’s complete terminal cappings, heavy atoms, and add hydrogen atoms to the system:

molsys = msm.build.add_missing_terminal_cappings(molsys)
molsys = msm.build.add_missing_heavy_atoms(molsys)
molsys = msm.build.add_missing_hydrogens(molsys)

We check again to confirm that hydrogen atoms are now present:

msm.build.has_hydrogens(molsys)
True
msm.build.has_hydrogens(molsys, selection='molecule_type=="protein"')
True