<jupyter_start><jupyter_text>CrossDocked Summary Statistics<jupyter_code>import os
from rdkit import Chem
#from explore_utils import *
import torch
import matplotlib.pyplot as plt
summary = torch.load('summary_stats.pt')
pockets = summary['pockets']
ligands = summary['ligands']
print('Number of bad pockets: ', len(summary["bad_proteins"]))
print('Number of bad ligands: ', len(summary["bad_ligands"]))
num_pockets = len(summary["pockets"])
num_ligands = len(summary["ligands"])
print('Number of unique pockets: ', num_pockets)
print('Number of unique ligands: ', num_ligands)
print('pocket residues (mean, std): ', get_stats(pockets, 'residues')[1:])
print('pocket atoms (mean, std): ', get_stats(pockets, 'atoms')[1:])
print('ligand atoms (mean, std): ', get_stats(ligands, 'atoms')[1:])
print('pocket bonds (mean, std): ', get_stats(pockets, 'bonds')[1:])
print('ligand bonds (mean, std): ', get_stats(ligands, 'bonds')[1:])
print('pocket heavy atoms (mean, std): ', get_stats(pockets, 'heavy')[1:])
print('ligand heavy atoms (mean, std): ', get_stats(ligands, 'heavy')[1:])
hist = plt.hist(get_stats(ligands,'atoms')[0], bins='auto')  
def get_big_pockets(ligands, threshold):
    
    big_pocket_smiles = []
    for ligand in ligands:
        if ligands[ligand]['atoms'] >= threshold:
            for protein_smile in ligands[ligand]['pockets']:
                big_pocket_smiles.append(protein_smile)
    
    return set(big_pocket_smiles)
big_pockets = get_big_pockets(ligands, 60)
len(big_pockets)<jupyter_output><empty_output><jupyter_text>SBDD-3D Samples<jupyter_code>from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPDF
import torch
import os
import numpy as np
import matplotlib.pyplot as plt<jupyter_output>/data/scratch/draygoza/.conda/envs/SBDD/lib/python3.8/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm<jupyter_text>Summary Stats<jupyter_code>summary = torch.load('pathological_stats.pt')
ligands = summary['stats']
print('Number of bad ligands: ', len(summary["bad_ligands"]))
print('ligand atoms (mean, std): ', get_stats(ligands, 'atoms')[1:])
print('ligand bonds (mean, std): ', get_stats(ligands, 'bonds')[1:])
print('ligand heavy atoms (mean, std): ', get_stats(ligands, 'heavy')[1:])
hist = plt.hist(get_stats(ligands,'atoms')[0], bins='auto')  
os.listdir('outputs')
supplier = Chem.SDMolSupplier('outputs/sample-11441_2022_04_20__03_43_06/SDF/0.sdf', sanitize=False, removeHs=False)
mol = supplier[0]
mol
#smiles = data['mol_smiles'][idx]
#m = Chem.MolFromSmiles(smiles)

def moltosvg(mol, molSize = (300,300), kekulize = True):
    mc = Chem.Mol(mol.ToBinary())
    if kekulize:
        try:
            Chem.Kekulize(mc)
        except:
            mc = Chem.Mol(mol.ToBinary())
    if not mc.GetNumConformers():
        rdDepictor.Compute2DCoords(mc)
    drawer = rdMolDraw2D.MolDraw2DSVG(molSize[0],molSize[1])
    drawer.SetFontSize(30)
    drawer.DrawMolecule(mc)
    drawer.FinishDrawing()
    svg = drawer.GetDrawingText()
    return svg.replace('svg:','')

SVG(moltosvg(mol))
with open('./test.svg', 'w') as f:
    f.write(moltosvg(mol))

drawing = svg2rlg('./test.svg')
renderPDF.drawToFile(drawing, f"test.pdf")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15002820078962212, 'fraction_numerical': 0.015792442188381276, 'mean_word_length': 5.769083969465649, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '257664', 'license': 'MIT', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1291, 'n_words': 255, 'path': 'exploratory.ipynb', 'repo_name': 'Dieg0Alejandr0/3D-Generative-SBDD', 'size': '3546'}