.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery/nucleotide_contacts.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_nucleotide_contacts.py: Contacts between nucleotides in a tetracycline aptamer ====================================================== This example reproduces a figure from the publication *"StreAM-Tg: algorithms for analyzing coarse grained RNA dynamics based on Markov models of connectivity-graphs"* [1]_. The figure displays a coarse grained model of a tetracycline aptamer and highlights interacting nucleotides based on a cutoff distance. .. [1] S Jager, B Schiller, P Babel, M Blumenroth, T Strufe and K Hamacher, "StreAM-Tg: algorithms for analyzing coarse grained RNA dynamics based on Markov models of connectivity-graphs." Algorithms Mol Biol 12 (2017). .. GENERATED FROM PYTHON SOURCE LINES 17-30 .. code-block:: default # Code source: Patrick Kunzmann # License: CC0 import numpy as np import biotite.structure as struc import biotite.structure.io.mmtf as mmtf import biotite.database.rcsb as rcsb import ammolite PNG_SIZE = (800, 800) .. GENERATED FROM PYTHON SOURCE LINES 31-60 .. code-block:: default mmtf_file = mmtf.MMTFFile.read(rcsb.fetch("3EGZ", "mmtf")) structure = mmtf.get_structure(mmtf_file, model=1) aptamer = structure[struc.filter_nucleotides(structure)] # Coarse graining: Represent each nucleotide using its C3' atom aptamer = aptamer[aptamer.atom_name == "C3'"] # Connect consecutive nucleotides indices = np.arange(aptamer.array_length()) aptamer.bonds = struc.BondList( aptamer.array_length(), np.stack((indices[:-1], indices[1:]), axis=-1) ) pymol_obj = ammolite.PyMOLObject.from_structure(aptamer) pymol_obj.show("sticks") pymol_obj.show("spheres") pymol_obj.color("black") ammolite.cmd.set("stick_color", "red") ammolite.cmd.set("stick_radius", 0.5) ammolite.cmd.set("sphere_scale", 1.0) ammolite.cmd.set("sphere_quality", 4) # Adjust camera pymol_obj.orient() pymol_obj.zoom(buffer=10) ammolite.cmd.rotate("z", 90) ammolite.show(PNG_SIZE) .. image-sg:: /examples/gallery/images/sphx_glr_nucleotide_contacts_001.png :alt: nucleotide contacts :srcset: /examples/gallery/images/sphx_glr_nucleotide_contacts_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 61-78 .. code-block:: default CUTOFF = 13 # Find contacts within cutoff distance adjacency_matrix = struc.CellList(aptamer, CUTOFF) \ .create_adjacency_matrix(CUTOFF) for i, j in zip(*np.where(adjacency_matrix)): pymol_obj.distance("", i, j, show_label=False, gap=0) ammolite.cmd.set("dash_color", "firebrick") # Add black outlines ammolite.cmd.bg_color("white") ammolite.cmd.set("ray_trace_mode", 1) ammolite.cmd.set("ray_trace_disco_factor", 0.5) ammolite.show(PNG_SIZE) # sphinx_gallery_thumbnail_number = 2 .. image-sg:: /examples/gallery/images/sphx_glr_nucleotide_contacts_002.png :alt: nucleotide contacts :srcset: /examples/gallery/images/sphx_glr_nucleotide_contacts_002.png :class: sphx-glr-single-img .. _sphx_glr_download_examples_gallery_nucleotide_contacts.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: nucleotide_contacts.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: nucleotide_contacts.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_