Skip to content

Commit

Permalink
Better error messages with error chains
Browse files Browse the repository at this point in the history
  • Loading branch information
bieniekmateusz committed Aug 20, 2023
1 parent c56571b commit 4987266
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions ties/ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,18 @@ def antechamber_prepare_mol2(self, **kwargs):
with open(log_filename, 'w') as LOG:
try:
subprocess.run([self.config.ambertools_antechamber,
'-i', self.current, '-fi', self.current.suffix[1:],
'-o', mol2_target, '-fo', 'mol2',
'-at', self.config.ligand_ff_name, '-nc', str(self.config.ligand_net_charge),
'-dr', str(self.config.antechamber_dr)] + self.config.antechamber_charge_type,
cwd=mol2_cwd,
stdout=LOG, stderr=LOG,
check=True, text=True,
timeout=60 * 30 # 30 minutes
)
except subprocess.CalledProcessError as E:
print('ERROR: occured when creating the input .mol2 file with antechamber. ')
print(f'ERROR: The output was saved in the directory: {mol2_cwd}')
print(f'ERROR: can be found in the file: {log_filename}')
raise E
'-i', self.current, '-fi', self.current.suffix[1:],
'-o', mol2_target, '-fo', 'mol2',
'-at', self.config.ligand_ff_name, '-nc', str(self.config.ligand_net_charge),
'-dr', str(self.config.antechamber_dr)] + self.config.antechamber_charge_type,
cwd=mol2_cwd,
stdout=LOG, stderr=LOG,
check=True, text=True,
timeout=60 * 30 # 30 minutes
)
except subprocess.CalledProcessError as ProcessError:
raise Exception(f'Could not convert the input into .mol2 file with antechamber. '
f'See the log and its directory: {log_filename}') from ProcessError
print(f'Converted {self.original_input} into .mol2, Log: {log_filename}')
else:
print(f'File {mol2_target} already exists. Skipping. ')
Expand Down

0 comments on commit 4987266

Please sign in to comment.