コード例 #1
0
def test_connect_via_distances():
    """
    Test whether the created bond list is equal to the bonds deposited
    in the MMTF file.
    """
    file = mmtf.MMTFFile.read(join(data_dir("structure"), "1l2y.mmtf"))
    atoms = mmtf.get_structure(file, include_bonds=True, model=1)
    # Remove termini to solve the issue that the reference bonds do not
    # contain proper bonds for the protonated/deprotonated termini
    atoms = atoms[(atoms.res_id > 1) & (atoms.res_id < 20)]

    ref_bonds = atoms.bonds
    # Convert all bonds to BondType.ANY
    ref_bonds = struc.BondList(ref_bonds.get_atom_count(),
                               ref_bonds.as_array()[:, :2])

    test_bonds = struc.connect_via_distances(atoms)

    assert test_bonds == ref_bonds
コード例 #2
0
import numpy as np
from matplotlib.colors import to_rgb
import biotite
import biotite.structure as struc
import ammolite

PNG_SIZE = (1000, 300)

# Define colors
for color_name, color_value in biotite.colors.items():
    ammolite.cmd.set_color("biotite_" + color_name, to_rgb(color_value))

# Convert to PyMOL
atom_array.bonds = struc.connect_via_distances(atom_array)
pymol_obj = ammolite.PyMOLObject.from_structure(atom_array)

# Visualize as stick model
pymol_obj.show_as("sticks")
pymol_obj.color("biotite_lightgreen",
                (atom_array.res_id % 2 == 0) & (atom_array.element == "C"))
pymol_obj.color("biotite_dimgreen",
                (atom_array.res_id % 2 != 0) & (atom_array.element == "C"))
ammolite.cmd.set("depth_cue", 0)

# Adjust camera
pymol_obj.orient()
pymol_obj.zoom(buffer=-9)

# Save image
ammolite.cmd.ray(*PNG_SIZE)
ammolite.cmd.png(__image_destination__)
コード例 #3
0
import ammolite

PNG_SIZE = (1000, 700)

# General configuration
ammolite.cmd.set("sphere_scale", 1.5)
ammolite.cmd.set("depth_cue", 0)

# Define colors
for color_name, color_value in biotite.colors.items():
    ammolite.cmd.set_color("biotite_" + color_name, to_rgb(color_value))

# Remove hydrogen and water and convert to PyMOL
structure = structure[(structure.element != "H")
                      & (structure.res_name != "TIP")]
structure.bonds = struc.connect_via_distances(structure)
pymol_obj = ammolite.PyMOLObject.from_structure(structure)

# Configure lipid tails
pymol_obj.color("biotite_lightgreen", structure.chain_id == "A")
pymol_obj.color("biotite_brightorange", structure.chain_id == "B")
pymol_obj.show("sticks", np.isin(structure.chain_id, ("A", "B")))

# Configure lipid heads
pymol_obj.color("biotite_darkgreen",
                (structure.chain_id == "A") & (structure.atom_name == "P"))
pymol_obj.color("biotite_dimorange",
                (structure.chain_id == "B") & (structure.atom_name == "P"))
pymol_obj.show(
    "spheres",
    np.isin(structure.chain_id, ("A", "B")) & (structure.atom_name == "P"))