Utils

Setup

Copy files

Using list(Path('files').rglob('*.pdb')) will get all the pdb files of subfolders. Here we define a function that can limit the depth of search.


source

rglob

 rglob (path, pattern, max_depth)

Get a file list given folder depths

file_list = list(rglob('files','*.pdb',1))
file_list
[PosixPath('/teamspace/studios/this_studio/kdock/nbs/core/files/7OFF_receptor.pdb'),
 PosixPath('/teamspace/studios/this_studio/kdock/nbs/core/files/7OFF_lig.pdb'),
 PosixPath('/teamspace/studios/this_studio/kdock/nbs/core/files/7OFF.pdb')]

source

copy_files

 copy_files (file_list, dest_dir)

Copy a list of files to the destination directory, or zip them if dest_dir ends with .zip.

# copy_files(file_list,'files/protein.zip') # support zip
copy_files(file_list,'files/protein')
Copied 3 files to files/protein

Get receptor and ligand from pdb


source

get_rec_lig

 get_rec_lig (pdb_id:str, lig_id:str, out_dir='.')

Download pdb and extract receptor and ligand from a PDB ID.

Type Default Details
pdb_id str pdb id for download
lig_id str ligand id shown on the protein page
out_dir str . directory path to save pdb files
rec_path,lig_path = get_rec_lig('7OFF','VCB','files')
rec_path,lig_path
7OFF.pdb is detected!
('/teamspace/studios/this_studio/kdock/nbs/core/files/7OFF_receptor.pdb',
 '/teamspace/studios/this_studio/kdock/nbs/core/files/7OFF_lig.sdf')

Get ligand box


source

get_box

 get_box (sdf_file, autobox_add=4.0, tolist=False)

Get the box coordinates of ligand.sdf; mimic GNINA’s –autobox_ligand behavior.

box = get_box(lig_path)
box
{'center_x': 38.848,
 'center_y': -26.77,
 'center_z': 10.419,
 'size_x': 14.652,
 'size_y': 8.942,
 'size_z': 12.509}
box_list = get_box(lig_path,tolist=True)
box_list
[38.848, -26.77, 10.419, 14.652, 8.942, 12.509]

Visualize mol


source

view_mol

 view_mol (file)

Visualize pdb or sdf file

Details
file sdf or pdb file
view_mol('files/7OFF_receptor.pdb')

3Dmol.js failed to load for some reason. Please check your browser console for error messages.


source

view_complex

 view_complex (receptor, ligand, ori_ligand=None, box=None)

Visualize the receptor, ligand, optional original ligand, and optional box via py3Dmol.

Type Default Details
receptor protein file
ligand ligand (green), or docked ligand
ori_ligand NoneType None original ligand (yellow)
box NoneType None optional box: [x, y, z, sizeX, sizeY, sizeZ]
box_list = get_box('files/7OFF_lig.sdf',tolist=True)
box_list
[38.848, -26.77, 10.419, 14.652, 8.942, 12.509]
view_complex('files/7OFF.pdb','files/7OFF_lig.sdf',box=box_list)

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

End