<jupyter_start><jupyter_text>KLIFS data explorationWe explore the KLIFS dataset used to generate `kissim` fingerprints.- Load filtered structures from `prepare_dataset.ipynb` by structure KLIFS IDs.- Explore kinases in dataset- Explore structures in dataset<jupyter_code>%load_ext autoreload
%autoreload 2
from pathlib import Path

import pandas as pd
from opencadd.databases.klifs import setup_remote
from kissim.definitions import ANCHOR_RESIDUES

from src.data.structures import explorer
pd.set_option("display.max_columns", 50)
SPECIES = "Human"
DFG_CONFORMATION = "in"
RESOLUTION_MAX = 4

HERE = Path(_dh[-1])  # noqa: F821
DATA = HERE / "../../data/processed/"<jupyter_output><empty_output><jupyter_text>Load structures (metadata) from KLIFS structure IDs<jupyter_code>remote = setup_remote()
structure_klifs_ids = pd.read_csv(
    DATA / "structure_klifs_ids_all.txt", squeeze=True, header=None
).to_list()
print(f"Number of structures: {len(structure_klifs_ids)}")
structures = remote.structures.by_structure_klifs_id(structure_klifs_ids)
structures[structures["structure.alternate_model"] != "A"]<jupyter_output><empty_output><jupyter_text>Explore kinases in dataset<jupyter_code>n_structures = len(structures)
n_kinases = len(structures["kinase.klifs_id"].unique())
print(f"Number of structures in dataset: {n_structures}")
print(f"Number of kinases in dataset: {n_kinases}")<jupyter_output>Number of structures in dataset: 4690
Number of kinases in dataset: 279<jupyter_text>Number structures per kinase<jupyter_code>explorer.plot_number_of_structures_per_kinase(structures);
structures.groupby("kinase.klifs_name").size().sort_values(ascending=False).head()
n_structures_per_kinase = structures.groupby("kinase.klifs_name").size()
for i in [1, 2, 3, 4, 5]:
    print(f"Number of kinase with {i} structure: {sum(n_structures_per_kinase == i)}")
for i in [5, 10]:
    print(f"Number of kinase with > {i} structures: {sum(n_structures_per_kinase > i)}")<jupyter_output>Number of kinase with 1 structure: 56
Number of kinase with 2 structure: 43
Number of kinase with 3 structure: 22
Number of kinase with 4 structure: 22
Number of kinase with 5 structure: 14
Number of kinase with > 5 structures: 122
Number of kinase with > 10 structures: 90<jupyter_text>Number of kinases per kinase group<jupyter_code>explorer.plot_number_of_kinases_per_kinase_group(structures, remote);<jupyter_output><empty_output><jupyter_text>Explore structures in dataset  Species, DFG/aC-helix conformations, ligand<jupyter_code>explorer.plot_important_categories(structures);<jupyter_output><empty_output><jupyter_text>Number of structures per DFG/aC-helix conformation:<jupyter_code>structures.groupby(["structure.dfg", "structure.ac_helix"]).size().unstack()<jupyter_output><empty_output><jupyter_text>Percentage of structures per DFG/aC-helix conformation:<jupyter_code>round(
    structures.groupby(["structure.dfg", "structure.ac_helix"]).size().unstack()
    / len(structures)
    * 100,
    1,
)<jupyter_output><empty_output><jupyter_text>Percentage of ligand-bound structures:<jupyter_code>round(len(structures[structures["ligand.expo_id"] != "-"]) / len(structures) * 100, 1)<jupyter_output><empty_output><jupyter_text>Resolution vs. quality score<jupyter_code>explorer.plot_resolution_vs_qualityscore(structures);<jupyter_output><empty_output><jupyter_text>Explore pockets in final dataset  Missing residues in the kinase binding site<jupyter_code>fig, ax = explorer.plot_missing_residues(structures, remote, ANCHOR_RESIDUES)
fig.savefig("../figures/missing_residues.pdf", format="pdf", bbox_inches="tight")
ax = structures["structure.pocket"].str.count("_").value_counts().sort_index().plot(kind="bar")
ax.set_xlabel("Number of missing pocket residues per structure")
ax.set_ylabel("Number of structures");<jupyter_output><empty_output><jupyter_text>Number of structures that will have no subpocket centers... because the subpockets' anchor residues are missing (gaps in the structure).<jupyter_code>explorer.plot_missing_subpockets(structures, ANCHOR_RESIDUES);<jupyter_output>Percentage of structures with missing subpocket:
dfg_region      0.66
front_pocket    0.60
hinge_region    0.32
dtype: float64<jupyter_text>Modified residues<jupyter_code>explorer.plot_modified_residues(structures, remote, ANCHOR_RESIDUES);
structures[structures["structure.pocket"].str.contains("X")]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11098502042669088, 'fraction_numerical': 0.0147526100771675, 'mean_word_length': 8.317124735729386, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '621719', 'license': 'MIT', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1436, 'n_words': 307, 'path': 'notebooks/002_structures/002_explore_dataset.ipynb', 'repo_name': 'volkamerlab/kissim_app', 'size': '4406'}