Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions src/metal_dock/docking.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ def run(self):
os.chdir(dock_dir_path)
self._run_autogrid(autogrid_logfile, gpf_path)
self._run_autodock(autodock_logfile, dpf_path)
self._write_conformations(dlg_path, dock_dir_path)
# self._adding_and_optimizing_hydrogens()
self._clean_dummy_atoms()
self._write_pdbqt_to_xyz()
self._write_pose_to_pdb()
if not self.par.score_only:
self._write_conformations(dlg_path, dock_dir_path)
# self._adding_and_optimizing_hydrogens()
self._clean_dummy_atoms()
self._write_pdbqt_to_xyz()
self._write_pose_to_pdb()

def _write_pdbqt_to_xyz(self):
"""
Expand Down Expand Up @@ -121,18 +122,22 @@ def analyze_results(self):
self.logger.info('Ligand Efficiency = (binding energy) / (number of heavy atoms in metal complex)')
self.logger.info('Interacting Residues = residues within 4 Angstrom of the metal complex\n')

for i in range(self.par.num_poses):
self.logger.info(f"Pose {i+1}:")
self.logger.info("-------------")
pose_path = self.par.output_dir / 'results' / f'pose_{i+1}' / f'{self.par.name_ligand}_{i+1}.xyz'
pdb_path = self.par.output_dir / 'results' / f'clean_{self.par.name_protein}.pdb'
pose_residues = self._extract_interacting_residues(pose_path, pdb_path)
self.logger.info(f'Binding Energy: {binding_energies[i]:7.4f} kcal/mol')
self.logger.info(f'Ligand Efficiency: {binding_efficiencies[i]:7.4f} kcal/mol')
self.logger.info(f'Interacting Residues:')
for residue in pose_residues:
self.logger.info(f'Residue: {residue[0]}, ID: {residue[1]:>3}')
if self.par.score_only:
self.logger.info(f'Binding Energy: {binding_energies[0]:7.4f} kcal/mol')
self.logger.info('\n')
else:
for i in range(self.par.num_poses):
self.logger.info(f"Pose {i+1}:")
self.logger.info("-------------")
pose_path = self.par.output_dir / 'results' / f'pose_{i+1}' / f'{self.par.name_ligand}_{i+1}.xyz'
pdb_path = self.par.output_dir / 'results' / f'clean_{self.par.name_protein}.pdb'
pose_residues = self._extract_interacting_residues(pose_path, pdb_path)
self.logger.info(f'Binding Energy: {binding_energies[i]:7.4f} kcal/mol')
self.logger.info(f'Ligand Efficiency: {binding_efficiencies[i]:7.4f} kcal/mol')
self.logger.info(f'Interacting Residues:')
for residue in pose_residues:
self.logger.info(f'Residue: {residue[0]}, ID: {residue[1]:>3}')
self.logger.info('\n')

if self.par.rmsd:
rmsd_path = self.par.output_dir / 'file_prep' / f'{self.par.name_ligand}_c.xyz'
Expand Down Expand Up @@ -435,6 +440,9 @@ def _create_dpf_file(self, dpf_path, gpf_path, parameter_path):

dpf_file.write('# Activate SA\n')
dpf_file.write('simanneal '+str(self.par.num_poses)+' # run this many SA docking\n')

elif self.par.score_only == True:
dpf_file.write('epdb # used to calculate the energy of a particular ligand conformation')

dpf_file.write('analysis # perforem a ranked cluster analysis\n')

Expand Down
1 change: 1 addition & 0 deletions src/metal_dock/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def docking(par: DockParser):
par (DockParser): The parser object.
"""
input_dir = Path.cwd()
par.input_dir = input_dir
par.output_dir = input_dir / 'output'
#=== OUTPUT DIRECTORY ===#
par.output_dir.mkdir(exist_ok=True)
Expand Down
5 changes: 4 additions & 1 deletion src/metal_dock/metal_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def create_mol_graph(self,
run_type (str): The type of run.
"""
mg = MolGraph()
mg.read_xyz(self.par.output_dir / 'QM' / run_type / 'output.xyz')
if self.par.score_only:
mg.read_xyz(self.par.input_dir / f'{self.par.name_ligand}.xyz')
else:
mg.read_xyz(self.par.output_dir / 'QM' / run_type / 'output.xyz')
self.graph = to_networkx_graph(mg)

def add_charges_to_graph(self):
Expand Down
13 changes: 10 additions & 3 deletions src/metal_dock/parser_metal_dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
'temp_reduction_factor': 0.90,
'number_of_runs': 50,
'max_cycles': 50,
'mc_steps': 250
'mc_steps': 250,
'score_only': False
}

# e_NA, e_OA, e_SA, e_HD,
Expand Down Expand Up @@ -154,8 +155,12 @@ def _validate_docking_algorithm(self):
if self.sa_dock:
self.dock_algorithm = [self.temp_reduction_factor, self.number_of_runs, self.max_cycles]

if not self.ga_dock and not self.sa_dock:
self.logger.info('At least ga_dock or sa_dock must be set to True for MetalDock to run properly')
if self.score_only and (self.ga_dock or self.sa_dock):
self.logger.info('ga_dock and/or sa_dock must be set to False when performing score_only')
sys.exit()

if not self.ga_dock and not self.sa_dock and not self.score_only:
self.logger.info('At least ga_dock or sa_dock or score_only must be set to True for MetalDock to run properly')
sys.exit()


Expand Down Expand Up @@ -285,6 +290,8 @@ def _initialize_parameters(self):
self.number_of_runs = self.get_config_value('DOCKING', 'number_of_runs', STANDARD_DEFAULTS['number_of_runs'], int)
self.max_cycles = self.get_config_value('DOCKING', 'max_cycles', STANDARD_DEFAULTS['max_cycles'], int)

self.score_only = self.get_config_value('DOCKING', 'score_only', STANDARD_DEFAULTS['score_only'], bool)

self._validate_docking_algorithm()

# heavy atoms
Expand Down