Skip to content

Commit

Permalink
Added the keep_files argument to get_solv()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas van Beek committed Jun 20, 2019
1 parent 152cb6c commit 3e661d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CAT/analysis/ligand_solvation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
__all__ = ['init_solv']

import os
import shutil
from itertools import product
from os.path import (join, dirname)

Expand Down Expand Up @@ -95,7 +96,7 @@ def get_surface_charge(mol, job=None, s=None):
return get_coskf(results)


def get_solv(mol, solvent_list, coskf, job=None, s=None):
def get_solv(mol, solvent_list, coskf, job=None, s=None, keep_files=True):
""" Calculate the solvation energy of *mol* in various *solvents*. """
# Return 2x np.nan if no coskf is None (i.e. the COSMO-surface construction failed)
if coskf is None:
Expand Down Expand Up @@ -129,6 +130,13 @@ def get_solv(mol, solvent_list, coskf, job=None, s=None):
E_solv.append(np.nan)
Gamma.append(np.nan)

# Delete all mopac and cosmo-rs files if keep_files=False
if not keep_files:
mopac = dirname(s.input.Compound._h)
shutil.rmtree(mopac)
for job in jobs:
shutil.rmtree(job.path)

# Return the solvation energies and activity coefficients as dict
return E_solv, Gamma

Expand Down

0 comments on commit 3e661d7

Please sign in to comment.