def nuc_sample_array(): """ Sample structure. """ nuc_sample_array = strucio.load_structure( join(data_dir("structure"), "4p5j.cif") ) return nuc_sample_array[struc.filter_nucleotides(nuc_sample_array)]
def plot_rna(pdb_id, axes): # Download the PDB file and read the structure pdb_file_path = rcsb.fetch(pdb_id, "pdb", gettempdir()) pdb_file = pdb.PDBFile.read(pdb_file_path) atom_array = pdb.get_structure(pdb_file)[0] nucleotides = atom_array[struc.filter_nucleotides(atom_array)] # Compute the base pairs and their pseudoknot order base_pairs = struc.base_pairs(nucleotides) base_pairs = struc.get_residue_positions( nucleotides, base_pairs.flatten() ).reshape(base_pairs.shape) pseudoknot_order = struc.pseudoknots(base_pairs)[0] # Set the linestyle according to the pseudoknot order linestyles = np.full(base_pairs.shape[0], '-', dtype=object) linestyles[pseudoknot_order == 1] = '--' linestyles[pseudoknot_order == 2] = ':' # Indicate canonical nucleotides with an upper case one-letter-code # and non-canonical nucleotides with a lower case one-letter-code base_labels = [] for base in struc.residue_iter(nucleotides): one_letter_code, exact = struc.map_nucleotide(base) if exact: base_labels.append(one_letter_code) else: base_labels.append(one_letter_code.lower()) # Color canonical Watson-Crick base pairs with a darker orange and # non-canonical base pairs with a lighter orange colors = np.full(base_pairs.shape[0], biotite.colors['brightorange']) for i, (base1, base2) in enumerate(base_pairs): name1 = base_labels[base1] name2 = base_labels[base2] if sorted([name1, name2]) in [["A", "U"], ["C", "G"]]: colors[i] = biotite.colors["dimorange"] # Plot the secondary structure graphics.plot_nucleotide_secondary_structure( axes, base_labels, base_pairs, struc.get_residue_count(nucleotides), pseudoknot_order=pseudoknot_order, bond_linestyle=linestyles, bond_color=colors, # Margin to compensate for reduced axis limits in shared axis border=0.13 ) # Use the PDB ID to label each plot axes.set_title(pdb_id, loc="left")
# License: BSD 3 clause from tempfile import gettempdir import biotite import biotite.structure.io.pdb as pdb import biotite.database.rcsb as rcsb import biotite.structure as struc import biotite.structure.graphics as graphics import matplotlib.pyplot as plt import numpy as np # Download the PDB file and read the structure pdb_file_path = rcsb.fetch("6ZYB", "pdb", gettempdir()) pdb_file = pdb.PDBFile.read(pdb_file_path) atom_array = pdb.get_structure(pdb_file)[0] nucleotides = atom_array[struc.filter_nucleotides(atom_array)] # Compute the base pairs and the Leontis-Westhof nomenclature base_pairs = struc.base_pairs(nucleotides) glycosidic_bonds = struc.base_pairs_glycosidic_bond(nucleotides, base_pairs) edges = struc.base_pairs_edge(nucleotides, base_pairs) base_pairs = struc.get_residue_positions( nucleotides, base_pairs.flatten()).reshape(base_pairs.shape) # Get the one-letter-codes of the bases base_labels = [] for base in struc.residue_iter(nucleotides): base_labels.append(base.res_name[0]) # Color canonical Watson-Crick base pairs with a darker orange and # non-canonical base pairs with a lighter orange
# Code source: Patrick Kunzmann # License: BSD 3 clause import numpy as np import matplotlib.pyplot as plt import biotite.structure as struc import biotite.structure.io.mmtf as mmtf import biotite.structure.graphics as graphics import biotite.database.rcsb as rcsb # Structure of a DNA double helix mmtf_file = mmtf.MMTFFile.read(rcsb.fetch("1qxb", "mmtf")) structure = mmtf.get_structure(mmtf_file, model=1, include_bonds=True) nucleotides = structure[struc.filter_nucleotides(structure)] # Choose one adenine-thymine and one guanine-cytosine base pair base_pairs = struc.base_pairs(nucleotides) for i, j in base_pairs: if (nucleotides.res_name[i], nucleotides.res_name[j]) == ("DG", "DC"): guanine, cytosine = [nucleotides[mask] for mask in struc.get_residue_masks(nucleotides, [i, j])] break for i, j in base_pairs: if (nucleotides.res_name[i], nucleotides.res_name[j]) == ("DA", "DT"): adenine, thymine = [nucleotides[mask] for mask in struc.get_residue_masks(nucleotides, [i, j])] break pairs = [(guanine, cytosine), (adenine, thymine)]
# 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) ######################################################################## 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")