Skip to content

Commit

Permalink
Merge pull request #22 from calpolyccg/development
Browse files Browse the repository at this point in the history
MD-SAPT 1.1.0
  • Loading branch information
ALescoulie authored Feb 4, 2022
2 parents bd2780e + 899468a commit a7340bc
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 21 deletions.
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

# -- Project information -----------------------------------------------------

project = 'mdsapt'
copyright = ("2021, Alia Lescoulie. Project structure based on the "
project = 'MD-SAPT'
copyright = ("2021, Alia Lescoulie, Astrid Yu, and Ashley Ringer McDonald. Cal Poly Computational Chemistry Group. Project structure based on the "
"Computational Molecular Science Python Cookiecutter version 1.6")
author = 'Alia Lescoulie'

# The short X.Y version
version = ''
version = '1.1'
# The full version, including alpha/beta/rc tags
release = ''
release = '1.1.0'


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -154,7 +154,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'mdsapt', 'mdsapt Documentation',
(master_doc, 'MD-SAPT', 'mdsapt Documentation',
[author], 1)
]

Expand Down
8 changes: 5 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
MDSAPT Documentation
MD-SAPT Documentation
=========================================================

**MDSAPT** is a Python package and `MDAnalysis <https://www.mdanalysis.org>`_ Kit for preforming
**MD-SAPT** is a Python package and `MDAnalysis <https://www.mdanalysis.org>`_ Kit for preforming
Symmetry Adapted Perturbation Theory (SAPT) calculations on molecular dynamics (MD) simulation
trajectories using `Psi4 <https://psicode.org>`_.

Currently MDSAPT is installable via GitHub and supports measuring interactions between ligands and
Currently MD-SAPT is installable via GitHub and supports measuring interactions between ligands and
standard amino acids.



.. toctree::
:maxdepth: 4
:numbered:
Expand Down
13 changes: 10 additions & 3 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
Installation
============

Currently MD-SAPT is not available via any packaging system. It must be installed
by cloning the GitHub repository.
MD-SAPT can be installed by cloning the GitHub repository.

.. code-block:: bash
git clone https://github.com/ALescoulie/MDSAPT.git
git clone https://github.com/calpolyccg/MDSAPT.git
pip install ./MDSAPT
MD-SAPT can also be installed from conda.

.. code-block:: bash
conda install -c psi4 MDSAPT
2 changes: 1 addition & 1 deletion docs/quick.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following steps describe how to set up the input yaml file
Running SAPT
____________

With the input done MDSAPT is ready to be run. The settings are read using :class:`mdsapt.reader.InputReader` which is then passed into :class:`mdsapt.reader.Optimizer` which handles preparing residues. Finally :class:`mdsapt.reader.TrajectorySAPT` is used to run SAPT over the MD data. The results are stored in a :class:`Pandas.DataFrame`.
With the input done MD-SAPT is ready to be run. The settings are read using :class:`mdsapt.reader.InputReader` which is then passed into :class:`mdsapt.reader.Optimizer` which handles preparing residues. Finally :class:`mdsapt.reader.TrajectorySAPT` is used to run SAPT over the MD data. The results are stored in a :class:`Pandas.DataFrame`.

.. code-block:: Python
Expand Down
2 changes: 2 additions & 0 deletions docs/scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _____________________
Usage

.. code-block:: bash
python mdsapt_get_runinput.py filename
`mdsapt_run_sapt`
Expand All @@ -17,5 +18,6 @@ _________________
Usage

.. code-block:: bash
python mdsapt_run_sapt.py input.yaml results.out
18 changes: 14 additions & 4 deletions mdsapt/sapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TrajectorySAPT(AnalysisBase):
_basis: str
_settings: Dict[str, str]
results: pd.DataFrame
_mht_to_kcalmol: float = 627529
_mht_to_kcalmol: float = 627.509

def __init__(self, config: InputReader, optimizer: Optimizer, **universe_kwargs) -> None:
"""Sets up Trajectory and residue selections.
Expand Down Expand Up @@ -88,7 +88,8 @@ def __init__(self, config: InputReader, optimizer: Optimizer, **universe_kwargs)
super(TrajectorySAPT, self).__init__(self._unv.trajectory)

def _prepare(self) -> None:
self._col = ['residues', 'time', 'energy']
self._col = ['residues', 'time', 'total', 'electrostatic',
'exchange', 'induction', 'dispersion']
self.results = pd.DataFrame(columns=self._col)
self._res_dict = {x: [] for x in self._col}

Expand All @@ -108,15 +109,24 @@ def _single_frame(self) -> None:
dimer = psi4.geometry(coords)
psi4.set_options(self._settings)
psi4.set_memory(self._mem)
psi4.set_num_threads(self._cfg.ncpus)

logger.info(f'Starting SAPT for {pair}')

if self._save_psi_out:
psi4.set_output_file(f'sapt_{pair[0]}-{pair[1]}_{self._ts.time}.out') # Saves output file

# Calculating SAPT
psi4.energy(f'{self._method}/{self._basis}', molecule=dimer)
sapt = psi4.variable('SAPT TOTAL ENERGY')
result = [f'{pair[0]}-{pair[1]}', self._ts.time, sapt*self._mht_to_kcalmol]

# Getting results
sapt_tot = psi4.variable('SAPT TOTAL ENERGY')*self._mht_to_kcalmol
sapt_col = psi4.variable('SAPT ELST ENERGY')*self._mht_to_kcalmol
sapt_exh = psi4.variable('SAPT EXCH ENERGY')*self._mht_to_kcalmol
sapt_ind = psi4.variable('SAPT IND ENERGY')*self._mht_to_kcalmol
sapt_dsp = psi4.variable('SAPT DISP ENERGY')*self._mht_to_kcalmol

result = [f'{pair[0]}-{pair[1]}', self._ts.time, sapt_tot, sapt_col, sapt_exh, sapt_ind, sapt_dsp]
for r in range(len(result)):
self._res_dict[self._col[r]].append(result[r])

Expand Down
4 changes: 2 additions & 2 deletions mdsapt/tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class TestInputReader(object):
'step': 1
},
'system_settings': {
'ncpus': 4,
'memory': '12GB',
'ncpus': 16,
'memory': '48GB',
'time': '24:00:00'
},
'opt_settings': {
Expand Down
7 changes: 6 additions & 1 deletion mdsapt/tests/test_sapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ def setup(self):

def test_run_sapt(self):
SAPT12 = TrajectorySAPT(self.settings, self.opt)
SAPT12.run(self.settings.trj_settings['start'], self.settings.trj_settings['stop'], self.settings.trj_settings['step'])
SAPT12.run(self.settings.trj_settings['start'], self.settings.trj_settings['stop'], self.settings.trj_settings['step'])
cols_act = SAPT12.results.columns
cols_exp = ['residues', 'time', 'total', 'electrostatic', 'exchange', 'induction', 'dispersion']
assert (len(cols_act) == len(cols_exp))
assert all([cols_act[i] == cols_exp[i] for i in range(len(cols_act))])
SAPT12.results.to_csv('sapt_test.csv')
4 changes: 2 additions & 2 deletions mdsapt/tests/testing_resources/test_input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ trajectory_settings:
stop: 2
step: 1
system_settings:
ncpus: 4
memory: 12GB
ncpus: 16
memory: 48GB
time: '24:00:00'
opt_settings:
pH: 7.0
Expand Down

0 comments on commit a7340bc

Please sign in to comment.