File size: 1,728 Bytes
5b2e6c5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # THIS SCRIPT USES A LIGHTWEIGHT EXAMPLE MODEL FOR DEMONSTRATION. TO OBTAIN GOOD ENSEMBLES, CHANGE THE MODEL TAG TO 'LATEST' BELOW.
#%%
from bbflow.deployment.bbflow import BBFlow
from pathlib import Path
rootdir = Path(__file__).parent.parent
# Download a small test model into ./models/bbflow-mini-0.1,
bbflow_sampler = BBFlow.from_tag('bbflow-mini-0.1') # use 'latest' to download a heavier, more accurate model
# Alternatively, you can specify a ckpt path directly
# ckpt_path = './ckpt/bbflow.ckpt'
# bbflow_sampler = BBFlow(ckpt_path)
# %%
# Sample conformations from the protein specified
# by the PDB file of the equilibrium structure
pdb_path = rootdir/'test_data/test_pdbs/equilibrium.pdb'
#%%
# Sample 50 conformations and save them to the output path
# with a fixed batch size of 10
bbflow_sampler.sample(
input_path=pdb_path, output_path=rootdir/'test_data/test_pdbs/ensemble.pdb',
num_samples=50, batch_size=10
)
#%%
# Sample 50 conformations and save them to the output path where
# the batch size is estimated based on the VRAM of the GPU
bbflow_sampler.sample(
input_path=pdb_path, output_path=rootdir/'test_data/test_pdbs/ensemble.pdb',
num_samples=50, cuda_memory_GB=6
)
# %%
# Analyze the generated ensemble against the reference MD trajectory
from scripts.analysis_script import calc_metrics
calc_metrics(
paths=[
(
"test_data/test_pdbs/ensemble.pdb",
"test_data/test_pdbs/equilibrium.pdb",
"test_data/test_pdbs/MD_trajectory.xtc",
)
],
print_metrics=True,
analysis_data_path="test_data/test_pdbs/analysis_data.pkl",
analysis_metrics_path="test_data/test_pdbs/metrics_summary.csv",
num_workers=1,
)
|