-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated Solvation Shell Analysis #227
Open
cadeduckworth
wants to merge
115
commits into
develop
Choose a base branch
from
automated-solvation-shell
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
115 commits
Select commit
Hold shift + click to select a range
e71456d
developing back end run methods
cadeduckworth 6c67ec1
condensed backend run methods
cadeduckworth 9914675
Initial adding of automation functionality to dihedral.py
cadeduckworth f9b6646
moved directory_paths function to reside within the DihedralAnalysis …
cadeduckworth 7bcdf49
Addressed change requests by Oliver
cadeduckworth a87cb11
fixed indentation error for _single_frame() block
cadeduckworth 7edde0d
reverting previous tab issue, necessary for normal function
cadeduckworth 48016c5
fixed errors previously reverted for testing
cadeduckworth 59c819c
Merge branch 'develop' into ensemble_run_update
cadeduckworth 6b1be1b
restored original dihedral.py file
cadeduckworth 2ddea0e
created automation/dihedral subdirectory under mdpow/analysis/ to hou…
cadeduckworth ad6db6e
updated docstrings and added examples for directory_paths.py
cadeduckworth 848dd87
added docstrings and examples for directory_iteration.py
cadeduckworth 6394d7a
added initial draft of docstrings and examples for all functions cont…
cadeduckworth d8f3ca3
added the option to save the DihedralAnalysis results DataFrame as cs…
cadeduckworth d8137cb
removed redundant DataFrame saving pattern from automated_dihedral_an…
cadeduckworth 29477ab
Merge remote-tracking branch 'origin/ensemble_run_update' into automa…
cadeduckworth 642e87e
merged updates from PR #216 and PR #218
cadeduckworth 4814376
Merge branch 'develop' into automated-dihedral-analysis
orbeckst f333ee8
Merge branch 'develop' into automated-dihedral-analysis
orbeckst 6f16b84
resolved conflicts to merge updates in from develop from PR#216
cadeduckworth ddffbdf
adding data for testing automated dihedral analysis
cadeduckworth c850448
added starting framework for testing automated dihedral analysis
cadeduckworth 69b0351
reorganized automation directory into workflows directory
cadeduckworth 4cf176d
added preliminary simple core tests for automated dihedral analysis
cadeduckworth 97c4a73
initial reformatting of existing docs for sphinx markup compatibility
cadeduckworth 930d54e
fix errors in docs for workflows
cadeduckworth 84536ff
added imports for automated dihedral analysis tests
cadeduckworth f01b2a4
added init file for workflows module
cadeduckworth 61ff494
added logging functionality for workflows modules
cadeduckworth f7b3f53
sphinx markup corrections for workflow modules
cadeduckworth d16dc7d
redo of reduced testing data for GAFF SM25 from original full dataset…
cadeduckworth bcfa10f
sphinx docs automodule test
cadeduckworth b8c309d
sphinx docs test base.txt
cadeduckworth 837f53e
docs
cadeduckworth 44db567
docs
cadeduckworth e53dfb6
docs
cadeduckworth 5f28b46
edit docs
cadeduckworth e58703a
edit docs
cadeduckworth bbcb5de
edit docs
cadeduckworth 45892b6
edit docs
cadeduckworth eaf767a
edit docs
cadeduckworth f19f32e
update py.path to pathlib in test_automated_dihedral_analysis
cadeduckworth 41166a4
update reference testing values for new reduced dataset, test_automat…
cadeduckworth 1de662e
change syntax in test_automated_dihedral_analysis to compare objects …
cadeduckworth 4eafa23
update assert_almost_equal to pytest.approx
cadeduckworth 4833a45
bounce redundant function calls to a pytest.fixture for use with mult…
cadeduckworth 5be6684
add bz2 compression for dataframe storage of automated dihedral analy…
cadeduckworth ef750f1
Update ci.yaml
cadeduckworth 4c9251b
added functionality for user input of alternative SMARTS string selec…
cadeduckworth 187632b
Merge branch 'automated-dihedral-analysis' of github.com:Becksteinlab…
cadeduckworth 7abb0bc
add tests for automated directory iteration of dihedral analysis, wor…
cadeduckworth 372a205
add tests for saving dataframes and saving figures, which covers the …
cadeduckworth 39518c2
add test for directory iteration of fully automated dihedral analysis
cadeduckworth 37eb085
moved location of rdkit install used for testing/pytest
cadeduckworth 85b54f3
remove misplaced hbonds documentation
cadeduckworth 1e5aadc
relocate test data for workflows and change test scripts accordingly
cadeduckworth edc0a9a
removed unnecessary .ipynb, .lock, and .npz files
cadeduckworth eb41100
simplified keyword specification for default and user input of SMARTS…
cadeduckworth b91240e
fixed plotting issue for solvents (name and order)
cadeduckworth fbca70d
variable name issue in testing module, user_SMARTS -> SMARTS
cadeduckworth b0081ef
Delete dir.csv
cadeduckworth 0520ffa
import syntax
cadeduckworth 77df0ee
sphinx docs
cadeduckworth 17a0b4a
Merge branch 'automated-dihedral-analysis' of github.com:Becksteinlab…
cadeduckworth 7359319
docs
cadeduckworth 8f8f26c
docs
cadeduckworth c452475
docs
cadeduckworth 3dd1b31
docs
cadeduckworth cecd928
docs
cadeduckworth 5b87e83
docs
cadeduckworth 86804d8
docs
cadeduckworth 0ab0299
docs
cadeduckworth 3964a44
docs
cadeduckworth dfb7e8e
docs
cadeduckworth be86754
docs
cadeduckworth f6330cb
docs
cadeduckworth ab6800e
docs
cadeduckworth 6bdc521
docs
cadeduckworth 0a7963d
docs
cadeduckworth 1866d43
docs
cadeduckworth 495546c
docs
cadeduckworth 956b359
docs
cadeduckworth 0ad73db
docs
cadeduckworth f6beebb
docs
cadeduckworth 036d939
docs
cadeduckworth 58f33c3
docs
cadeduckworth d704f95
moving workflows location, subsequent doc changes
cadeduckworth 02e10e5
import changed to reflect moving workflows module
cadeduckworth 891782e
docs
cadeduckworth 148e56f
add requirements for sphinx build
cadeduckworth a03951c
add requirements for sphinx build
cadeduckworth 31291f1
add requirements for sphinx build
cadeduckworth 652e788
add requirements for sphinx build
cadeduckworth 48c7e88
add requirements for sphinx build
cadeduckworth ba17ceb
docs
cadeduckworth 68cbc9c
docs
cadeduckworth 8c5c2ec
docs structure
cadeduckworth 8d29f91
consistent keyword names in tests
cadeduckworth 24f6c00
imports and docs
cadeduckworth 63e3de4
imports
cadeduckworth 104bf93
imports
cadeduckworth 1ad6b8c
generalizing automation base module for use with other analyses
cadeduckworth 3f65e28
initialize PR for automated-solvation-shell module
cadeduckworth 80c641c
initial script for automated solvation shell analysis
cadeduckworth 09721c7
updated automated solvation module, incomplete, issue with compression
cadeduckworth 68c0b1e
fixed automated solvation shell analysis module
cadeduckworth 7181017
docs and func names
cadeduckworth e3ef88f
cleanup and remove workflows base module/move to new PR
cadeduckworth 36be611
resolving conflicts
cadeduckworth b876ad1
add new version of testing resources
cadeduckworth 1f62fa6
correct module name
cadeduckworth 77f7054
start test module for solvations
cadeduckworth 041c6ed
change data obtained by SolvationAnalysis
cadeduckworth 61f53b9
name top-level automated solvation function and complete addition to …
cadeduckworth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ dependencies: | |
- pytest | ||
- pytest-pep8 | ||
- pytest-cov | ||
- codecov | ||
- codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
================================== | ||
Automated Solvation Shell Analysis | ||
================================== | ||
|
||
.. versionadded:: 0.9.0 | ||
|
||
.. automodule:: mdpow.workflows.solvations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import sys | ||
import yaml | ||
import pybol | ||
import pytest | ||
import pathlib | ||
import logging | ||
|
||
import scipy | ||
import numpy as np | ||
import pandas as pd | ||
|
||
import rdkit | ||
from rdkit import Chem | ||
|
||
import seaborn | ||
|
||
from numpy.testing import assert_almost_equal | ||
|
||
from . import RESOURCES | ||
|
||
import py.path | ||
|
||
from ..workflows import solvations | ||
|
||
from pkg_resources import resource_filename | ||
|
||
# ^review and update these as necessary, currently copied from test_ada | ||
|
||
RESOURCES = pathlib.PurePath(resource_filename(__name__, 'testing_resources')) | ||
MANIFEST = RESOURCES / "manifest.yml" | ||
|
||
@pytest.fixture(scope="function") | ||
def molname_workflows_directory(tmp_path, molname='SM25'): | ||
m = pybol.Manifest(str(MANIFEST)) | ||
m.assemble('workflows', tmp_path) | ||
return tmp_path / molname | ||
|
||
class TestAutomatedSolvationShellAnalysis(object): | ||
|
||
@pytest.fixture(scope="function") | ||
def SM25_tmp_dir(self, molname_workflows_directory): | ||
dirname = molname_workflows_directory | ||
return dirname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# MDPOW: solvations.py | ||
# 2022 Cade Duckworth | ||
|
||
""" | ||
:mod:`mdpow.workflows.solvations` --- Automation for :class:`SolvationAnalysis` | ||
============================================================================== | ||
:mod:`~mdpow.workflows.solvations` module with functions | ||
useful for automated use of | ||
:class:`~mdpow.analysis.solvation.SolvationAnalysis`. | ||
See each function for usage, output, and examples. | ||
Most functions can be used as standalone or in combination | ||
depending on the desired results. Complete automation encompassed in | ||
:func:`~mdpow.workflows.solvations.automated_solvation_shell_analysis`. | ||
|
||
.. autofunction:: solvation_ensemble | ||
.. autofunction:: solvation_analysis | ||
.. autofunction:: asa_save_df | ||
.. autofunction:: automated_solvation_shell_analysis | ||
""" | ||
|
||
import os | ||
import numpy as np | ||
import pandas as pd | ||
|
||
import mdpow | ||
from mdpow.analysis.solvation import SolvationAnalysis | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('mdpow.workflows.solvations') | ||
|
||
def solvation_ensemble(dirname, resname, solvents=('water', 'octanol'), | ||
interactions=('Coulomb', 'VDW')): | ||
|
||
ens = mdpow.analysis.ensemble.Ensemble(dirname=dirname, | ||
interactions=interactions, | ||
solvents=solvents) | ||
solute = ens.select_atoms(f'resname {resname}') | ||
solvent = ens.select_atoms(f'not resname {resname}') | ||
return solute, solvent | ||
|
||
def solvation_analysis(solute=None, solvent=None, distances=None, | ||
start=None, stop=None, step=None): | ||
|
||
solv = SolvationAnalysis(solute=solute, solvent=solvent, distances=distances) | ||
ds = solv.run(start=start, stop=stop, step=step) | ||
df = solv.results | ||
return df | ||
|
||
def asa_save_df(df, df_save_dir=None, resname=None, molname=None): | ||
'''Takes a :class:`pandas.DataFrame` of results from | ||
:class:`~mdpow.analysis.solvation.SolvationAnalysis` | ||
as input to optionaly save the data. | ||
Given a parent directory, creates subdirectory | ||
for molecule, saves fully sampled csv. | ||
:keywords: | ||
*df* | ||
results :class:`pandas.DataFrame` from | ||
:class:`~mdpow.analysis.solvation.SolvationAnalysis` | ||
*df_save_dir* | ||
path to parent directory to create | ||
subdirectory for saving the .csv files | ||
''' | ||
|
||
if molname is None: | ||
molname = resname | ||
|
||
if df_save_dir is not None: | ||
subdir = molname | ||
newdir = os.path.join(df_save_dir, subdir) | ||
os.mkdir(newdir) | ||
|
||
df = df.sort_values(by=["solvent", | ||
"interaction", | ||
"lambda"]).reset_index(drop=True) | ||
|
||
if df_save_dir is not None: | ||
df.to_csv(f'{newdir}/{molname}_full_df.csv', index=False, compression='bz2') | ||
# this part might need some work | ||
return | ||
|
||
def automated_solvation_shell_analysis(dirname, df_save_dir=None, resname=None, molname=None, | ||
solvents=('water', 'octanol'), interactions=('Coulomb', 'VDW'), | ||
distances=[1.2, 2.4], figdir=None, | ||
start=None, stop=None, step=None, | ||
SMARTS=None, padding=None, width=None): | ||
# figure out kwargs for each analysis type | ||
"""Measures the number of solvent molecules withing the given distances | ||
in an :class:`~mdpow.analysis.ensemble.Ensemble` . | ||
|
||
:Parameters: | ||
|
||
*solute* | ||
An :class:`~mdpow.analysis.ensemble.EnsembleAtom` containing the solute | ||
used to measure distance. | ||
|
||
*solvent* | ||
An :class:`~mdpow.analysis.ensemble.EnsembleAtom` containing the solvents | ||
counted in by the distance measurement. Each solvent atom is counted by the | ||
distance calculation. | ||
|
||
*distances* | ||
Array like of the cutoff distances around the solute measured in Angstroms. | ||
|
||
The data is returned in a :class:`pandas.DataFrame` with observations sorted by | ||
distance, solvent, interaction, lambda, time. | ||
""" | ||
|
||
components = solvation_ensemble(dirname=dirname, resname=resname, solvents=solvents) | ||
df = solvation_analysis(solute=components[0], solvent=components[1], | ||
distances=distances, start=start, stop=stop, step=step) | ||
if df_save_dir is not None: | ||
asa_save_df(df, df_save_dir=df_save_dir, resname=resname, molname=molname) | ||
|
||
return df |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you now returning distances? If so, better write a new class and leave the old one as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orbeckst
I agree, because they are doing different things. Can they both exist as separate classes within the same module?