User API examples
Setup python environment and install posebusters to run this notebook.
conda create -n posebusters python=3.10 jupyter notebook
conda activate posebusters
pip install posebusters --upgrade
[1]:
from pathlib import Path
pred_file = Path("inputs/generated_molecules.sdf") # predicted or generated molecules
true_file = Path("inputs/crystal_ligand.sdf") # "ground truth" molecules
cond_file = Path("inputs/protein.pdb") # conditioning molecule
PoseBusters default configs
[2]:
from posebusters import PoseBusters
redock
The `redock’ mode is for ligands docked into their cognate receptor crystal structures.
[3]:
# by default only the binary test report columns are returned
buster = PoseBusters(config="redock")
df = buster.bust([pred_file], true_file, cond_file)
print(df.shape)
df
[19:23:56] WARNING: Problems/mismatches: Mobile-H( Hydrogens: Number; Mobile-H groups: Falsely present, Attachment points; Charge(s): Do not match)
(3, 28)
[3]:
| mol_pred_loaded | mol_true_loaded | mol_cond_loaded | sanitization | inchi_convertible | all_atoms_connected | no_radicals | molecular_formula | molecular_bonds | double_bond_stereochemistry | ... | protein-ligand_maximum_distance | minimum_distance_to_protein | minimum_distance_to_organic_cofactors | minimum_distance_to_inorganic_cofactors | minimum_distance_to_waters | volume_overlap_with_protein | volume_overlap_with_organic_cofactors | volume_overlap_with_inorganic_cofactors | volume_overlap_with_waters | rmsd_≤_2å | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| file | molecule | position | |||||||||||||||||||||
| inputs/generated_molecules.sdf | molecule_1 | 0 | True | True | True | True | True | True | False | False | False | True | ... | False | True | True | True | True | True | True | True | True | False |
| molecule_2 | 1 | True | True | True | True | True | True | False | False | False | True | ... | False | True | True | True | True | True | True | True | True | False | |
| molecule_3 | 2 | True | True | True | True | True | True | False | False | False | True | ... | False | True | True | True | True | True | True | True | True | False |
3 rows × 28 columns
dock
The dock mode is for de-novo generated molecules for a given receptor or for ligands docked into a non-cognate receptor.
[4]:
buster = PoseBusters(config="dock")
df = buster.bust([pred_file], true_file, cond_file)
print(df.shape)
df
(3, 22)
[4]:
| mol_pred_loaded | mol_cond_loaded | sanitization | inchi_convertible | all_atoms_connected | no_radicals | bond_lengths | bond_angles | internal_steric_clash | aromatic_ring_flatness | ... | internal_energy | protein-ligand_maximum_distance | minimum_distance_to_protein | minimum_distance_to_organic_cofactors | minimum_distance_to_inorganic_cofactors | minimum_distance_to_waters | volume_overlap_with_protein | volume_overlap_with_organic_cofactors | volume_overlap_with_inorganic_cofactors | volume_overlap_with_waters | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| file | molecule | position | |||||||||||||||||||||
| inputs/generated_molecules.sdf | molecule_1 | 0 | True | True | True | True | True | False | False | False | True | True | ... | True | False | True | True | True | True | True | True | True | True |
| molecule_2 | 1 | True | True | True | True | True | False | True | True | True | True | ... | True | False | True | True | True | True | True | True | True | True | |
| molecule_3 | 2 | True | True | True | True | True | False | True | True | True | True | ... | True | False | True | True | True | True | True | True | True | True |
3 rows × 22 columns
mol
The mol mode is for de-novo generated molecules or for generated molecular conformations.
[5]:
buster = PoseBusters(config="mol")
df = buster.bust([pred_file], None, None)
print(df.shape)
df
(3, 12)
[5]:
| mol_pred_loaded | sanitization | inchi_convertible | all_atoms_connected | no_radicals | bond_lengths | bond_angles | internal_steric_clash | aromatic_ring_flatness | non-aromatic_ring_non-flatness | double_bond_flatness | internal_energy | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| file | molecule | position | ||||||||||||
| inputs/generated_molecules.sdf | molecule_1 | 0 | True | True | True | True | False | False | False | True | True | True | True | True |
| molecule_2 | 1 | True | True | True | True | False | True | True | True | True | True | True | True | |
| molecule_3 | 2 | True | True | True | True | False | True | True | True | True | True | True | True |
Output formatting
full report
The full_report option of bust will return all columns of the test reports, not only the binary columns. This is useful for debugging and for further analysis of the results.
[6]:
buster = PoseBusters(config="mol")
df = buster.bust([pred_file], None, None, full_report=True)
print(df.shape)
df
(3, 44)
[6]:
| mol_pred_loaded | sanitization | inchi_convertible | all_atoms_connected | no_radicals | bond_lengths | bond_angles | internal_steric_clash | aromatic_ring_flatness | non-aromatic_ring_non-flatness | ... | number_non-aromatic_rings_checked | number_non-aromatic_rings_pass | non-aromatic_ring_maximum_distance_from_plane | number_double_bonds_checked | number_double_bonds_pass | double_bond_maximum_distance_from_plane | num_h_added | mol_pred_energy | ensemble_avg_energy | energy_ratio | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| file | molecule | position | |||||||||||||||||||||
| inputs/generated_molecules.sdf | molecule_1 | 0 | True | True | True | True | False | False | False | True | True | True | ... | 0 | 0 | NaN | 0 | 0 | NaN | 25 | 1571.008943 | 524.648778 | 2.994401 |
| molecule_2 | 1 | True | True | True | True | False | True | True | True | True | True | ... | 0 | 0 | NaN | 0 | 0 | NaN | 28 | 370.156998 | 56.014875 | 6.608191 | |
| molecule_3 | 2 | True | True | True | True | False | True | True | True | True | True | ... | 0 | 0 | NaN | 0 | 0 | NaN | 22 | 530.291287 | 76.236353 | 6.955885 |
3 rows × 44 columns