.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery/structure/contacts/domain_hbonds.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_structure_contacts_domain_hbonds.py: Hydrogen bonds between protein domains ====================================== In this example we will identify the hydrogen bonds between the p-Helix and the selecivity filter of the channel protein KcsA (PDB: 2KB1). The structure was resolved using NMR, so multiple models are present in the structure. Hence, we can also calculate the frequency of each bond. .. GENERATED FROM PYTHON SOURCE LINES 11-56 .. image-sg:: /examples/gallery/structure/contacts/images/sphx_glr_domain_hbonds_001.png :alt: domain hbonds :srcset: /examples/gallery/structure/contacts/images/sphx_glr_domain_hbonds_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /usr/share/miniconda3/envs/test/lib/python3.11/site-packages/biotite/structure/hbond.py:270: UserWarning: Input structure has no associated 'BondList', Hydrogen atoms bonded to donors are detected by distance warnings.warn( | .. code-block:: Python # Code source: Daniel Bauer # License: BSD 3 clause from tempfile import gettempdir import matplotlib.pyplot as plt import biotite import biotite.database.rcsb as rcsb import biotite.structure as struc import biotite.structure.io as strucio file_name = rcsb.fetch("2KB1", "bcif", gettempdir()) stack = strucio.load_structure(file_name) # Four identical chains, consider only chain A chain_a = stack[:, stack.chain_id == "A"] # Selection for p-helix p_helix = (chain_a.res_id >= 40) & (chain_a.res_id <= 52) # Selection for selectivity filter sf = (chain_a.res_id >= 53) & (chain_a.res_id <= 58) # Calculate the hydrogen bonds and the frequency of each bond triplets, mask = struc.hbond(chain_a, selection1=p_helix, selection2=sf) freq = struc.hbond_frequency(mask) # Create names of bonds label = "{d_resid}{d_resnm}-{d_a} -- {a_resid}{a_resnm}-{a_a}" names = [ label.format( d_resid=chain_a.res_id[donor], d_resnm=chain_a.res_name[donor], d_a=chain_a.atom_name[donor], a_resid=chain_a.res_id[acceptor], a_resnm=chain_a.res_name[acceptor], a_a=chain_a.atom_name[acceptor], ) for donor, _, acceptor in triplets ] plt.subplots(figsize=(11, 4.5)) plt.bar(names, freq, color=biotite.colors["orange"]) plt.xlabel("Hydrogen bond") plt.ylabel("Hydrogen bond frequency") plt.xticks(rotation=45) plt.tight_layout() plt.show() .. _sphx_glr_download_examples_gallery_structure_contacts_domain_hbonds.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: domain_hbonds.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: domain_hbonds.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_