<jupyter_start><jupyter_text>PDBProp - Working With a Single PDB StructureThis notebook gives a tutorial of the **PDBProp object**, specifically how chains are handled and how to map a sequence to it.**Input:** PDB ID**Output:** PDBProp object  Imports<jupyter_code>from ssbio.databases.pdb import PDBProp
from ssbio.databases.uniprot import UniProtProp
import sys
import logging
# Create logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)  # SET YOUR LOGGING LEVEL HERE #
# Other logger stuff for Jupyter notebooks
handler = logging.StreamHandler(sys.stderr)
formatter = logging.Formatter('[%(asctime)s] [%(name)s] %(levelname)s: %(message)s', datefmt="%Y-%m-%d %H:%M")
handler.setFormatter(formatter)
logger.handlers = [handler]<jupyter_output><empty_output><jupyter_text>Basic methods<jupyter_code>my_structure = PDBProp(ident='5T4Q', description='E. coli ATP synthase')<jupyter_output><empty_output><jupyter_text>Download the structure Downloading will:- Download the file type of choice to the specific output directory- Parse the PDB header file to fill out the metadata fields<jupyter_code>import tempfile
my_structure.download_structure_file(outdir=tempfile.gettempdir(), file_type='mmtf')<jupyter_output><empty_output><jupyter_text>View all attributes<jupyter_code>my_structure.get_dict()<jupyter_output><empty_output><jupyter_text>Set chains that we are interested in (if any) The `mapped_chains` attribute allows us to limit sequence analyses to specified chains (see the later section where we [align a sequence to this structure](Aligning-a-sequence-to-the-structure)). For this example, the ATP synthase is a complex of a number of protein chains, and if we are interested in a specific gene transcript, we can set those.<jupyter_code># Chains A, B, and C make up ATP synthase subunit alpha - from the gene b3734 (UniProt ID P0ABB0)
my_structure.add_mapped_chain_ids(['A', 'B', 'C'])<jupyter_output><empty_output><jupyter_text>Parse the structure to work with the Biopython Structure object Parsing the structure will parse the sequences of each chain, and store those in the `chains` attribute. It will also return a Biopython Structure object which opens up all methods available for structures in Biopython.<jupyter_code>parsed_structure = my_structure.parse_structure()
print(type(parsed_structure.structure))
print(type(parsed_structure.first_model))<jupyter_output><empty_output><jupyter_text>Clean the structure and save the structure Cleaning a structure does the following:- Add missing chain identifiers to a PDB file- Select a single chain if noted- Remove alternate atom locations- Add atom occupancies- Add B (temperature) factors (default Biopython behavior)In the example below, we will clean the structure so it only includes our mapped chains.<jupyter_code>cleaned_structure = my_structure.clean_structure(outdir='/tmp', keep_chains=my_structure.mapped_chains, force_rerun=True)
cleaned_structure<jupyter_output><empty_output><jupyter_text>Viewing the structure<jupyter_code># The original structure
my_structure.view_structure(recolor=False)
# The cleaned structure
import nglview
nglview.show_structure_file(cleaned_structure)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08299531981279251, 'fraction_numerical': 0.0024960998439937598, 'mean_word_length': 7.618279569892473, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '292057', 'license': 'MIT', 'n_tokens_mistral': 966, 'n_tokens_neox': 934, 'n_words': 309, 'path': 'docs/notebooks/PDBProp - Working With a Single PDB Structure.ipynb', 'repo_name': 'JoshuaMeyers/ssbio', 'size': '3205'}