Skip to content

Commit

Permalink
Merge branch 'master' into support_point_mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesKarwou authored May 25, 2023
2 parents 3acaaff + 8eb4ceb commit 58191de
Show file tree
Hide file tree
Showing 26 changed files with 493 additions and 243 deletions.
4 changes: 3 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ coverage:
project:
default:
threshold: 50%
ignore:
- "transformato/testsystems.py" # ignore folders and all its contents
comment:
layout: "header"
require_changes: false
branches: null
behavior: default
flags: null
paths: null
paths: null
40 changes: 31 additions & 9 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,24 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: [3.8, 3.9]
# os: [macOS-latest, ubuntu-latest]
os: [ubuntu-latest]
python-version: [3.9]
include:
- os: ubuntu-latest
label: linux-64
# prefix: /usr/share/miniconda3/envs/openmm7.6
environment-file: devtools/conda-envs/fep_env.yaml
miniforge-variant: Mambaforge
miniforge-version: 4.9.2-4
#- os: macos-latest
# label: osx-64
# # prefix: /Users/runner/miniconda3/envs/openmm7.6
# environment-file: devtools/conda-envs/openmm7.6.yaml
# miniforge-variant: Mambaforge-pypy3

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Additional info about the build
shell: bash
Expand All @@ -50,7 +63,7 @@ jobs:

- name: Make Cache (no worflow_dispatch)
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir # ${{ matrix.prefix }}
# Increase the last number (0) to reset cache manually
Expand All @@ -70,12 +83,17 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/conda-envs/fep_env.yaml

condarc-file: ${{ matrix.condarc-file }}
environment-file: ${{ matrix.environment-file }}
miniforge-variant: ${{ matrix.miniforge-variant }}
miniforge-version: ${{ matrix.miniforge-version }}
use-mamba: true
# mamba-version: "*"
# environment-file: devtools/conda-envs/fep_env.yaml
channels: conda-forge,defaults

activate-environment: test
auto-update-conda: false
# channel-priority: true
activate-environment: fep
#auto-update-conda: false
auto-activate-base: false
#show-channel-urls: true
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
Expand All @@ -89,7 +107,11 @@ jobs:
shell: bash -l {0}
run: |
python -m pip install . --no-deps
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Run tests
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/lint_python.yml → .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: lint_python
name: Black Formatter

on: [pull_request, workflow_dispatch]

Expand All @@ -8,7 +8,7 @@ permissions:

jobs:
run-linters:
name: Run linters
name: Black Formatting
runs-on: ubuntu-latest

steps:
Expand All @@ -23,9 +23,10 @@ jobs:
- name: Install Python dependencies
run: pip install black

- name: Run linters
- name: Run Black formatting
uses: wearerequired/lint-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
black: true
black_dir: "transformato/"
black_args: '--extend-exclude="(bin/*|scripts/*|_version.py)"'
Expand All @@ -35,12 +36,12 @@ jobs:
# flake8_args: "--exclude=scripts,bin,_version.py --max-line-length=88 --extend-ignore=E203 --exit-zero"


#- name: Setup flake8 annotations
# uses: rbialon/flake8-annotations@v1
#- name: Lint with flake8
# run: |
# pip install flake8 pep8-naming
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Setup flake8 annotations
# uses: rbialon/flake8-annotations@v1
# - name: Lint with flake8
# run: |
# pip install flake8 pep8-naming
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics


2 changes: 2 additions & 0 deletions devtools/conda-envs/fep_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ dependencies:
- matplotlib
- networkx
- tqdm
- pip
- seaborn
# Testing
- pytest
- pytest-cov
- codecov
- pip:
- git+https://github.com/wiederm/tf_routes.git
- git+https://github.com/ParmEd/ParmEd.git
- git+https://github.com/wiederm/transformato_testsystems.git
12 changes: 5 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to the documentation for |trafo|!
Welcome to the documentation for transformato!
=========================================================

The python package |trafo| is an implementation of the Common Core / Serial-Atom-Insertion
(CC-SAI) approach\ [1]_ for calculating free energy differences\.
The python package transformato (**T**\ ool **R**\ unning MD **A**\ g\ **N**\ o\ **S**\ tic Calculations **FOR** **M**\ ultistate Serial **ATO**\ m Insertion) is an implementation of the Common Core / Serial-Atom-Insertion
(CC-SAI) approach [1]_ for calculating free energy differences\.
It does so by connecting the physical endstates of two molecules via alchemical pathways.

It requires very little set-up time and is designed to work directly with output from
`CHARMM - GUI <http://www.charmm-gui.org>`_\. Currently either **relative solvation free energies** (RSFE) [2]_
or **relative binding free energies** (RBFE) [3]_ can be calculated. For the production runs either
`CHARMM <https://academiccharmm.org/>`_\ or `openMM <https://openmm.org/>`_\ are required.
`CHARMM <https://academiccharmm.org/>`_\ or `openMM <https://openmm.org/>`_\ are required.

If you'd like to take a look at the code,
head over to our `github repository <https://github.com/wiederm/transformato>`_\ .

Das ist jetzt aber der letzte test


.. toctree::
:maxdepth: 2
Expand All @@ -41,7 +39,7 @@ Das ist jetzt aber der letzte test
.. [2] Wieder, M., Fleck, M., Braunsfeld, B., and Boresch, S. (2022). *Alchemical free energy simulations without speed limits. A generic framework to calculate free energy differences independent of the underlying molecular dynamics program.* J. Comput. Chem. 43, 1151–1160, `DOI ⤶ <https://doi.org/10.1002/jcc.26877>`_
.. [3] Karwounopoulos, J., Wieder, M., and Boresch, S. (2022). *Relative binding free energy calculations with Transformato: a molecular dynamics engine-independent tool.* Front. Mol. Biosic., *submitted*.
.. [3] Karwounopoulos, J., Wieder, M., and Boresch, S. (2022). *Relative binding free energy calculations with Transformato: a molecular dynamics engine-independent tool.* Front. Mol. Biosic. 9:954638, `DOI ⤶ <https://doi.org/10.3389/fmolb.2022.954638>`_
.. rubric:: Maintainers

Expand Down
10 changes: 2 additions & 8 deletions transformato/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def _parse_CHARMM_energy_output(path: str, env: str) -> list:
return pot_energies

def calculate_dG_using_mbar(self, u_kn: np.array, N_k: dict, env: str):

logger.debug("#######################################")
logger.debug("Pairwise Free Energy Estimate")
logger.debug("#######################################")
Expand Down Expand Up @@ -453,7 +452,6 @@ def energy_at_lambda(
energies = []

for lambda_state in range(1, self.nr_of_states + 1):

if not multiple_runs:
dcd_path = f"{self.base_path}/intst{lambda_state}/{conf_sub['intermediate-filename']}.dcd"
else:
Expand Down Expand Up @@ -518,7 +516,6 @@ def _analyse_results_using_mda(
multiple_runs: int,
in_memory: bool = False,
):

logger.info(f"Evaluating with {engine}, using {num_proc} CPUs")
if not os.path.isdir(self.base_path):
sys.exit(f"{self.base_path} does not exist")
Expand Down Expand Up @@ -579,7 +576,6 @@ def _analyse_results_using_mdtraj(
save_results: bool,
engine: str,
):

logger.debug(f"Evaluating with {engine}")

if engine == "openMM":
Expand All @@ -599,7 +595,7 @@ def _analyse_results_using_mdtraj(
elif engine == "CHARMM":
confs = []
# write out traj in self.base_path
for (dcd, psf) in self.traj_files[env]:
for dcd, psf in self.traj_files[env]:
traj = mdtraj.load(
f"{dcd}",
top=f"{psf}",
Expand Down Expand Up @@ -801,7 +797,7 @@ def plot_free_energy_overlap(self, env: str):
plt.close()

def plot_free_energy(self, env: str):
plt.figure(figsize=[4, 4], dpi=300)
plt.figure(figsize=[8, 8], dpi=300)
if env == "vacuum":
x = [
a
Expand Down Expand Up @@ -865,7 +861,6 @@ def end_state_free_energy_difference(self):
raise RuntimeError()

def show_summary(self):

if (
self.configuration["simulation"]["free-energy-type"] == "rsfe"
or self.configuration["simulation"]["free-energy-type"] == "asfe"
Expand All @@ -886,7 +881,6 @@ def show_summary(self):
)

def detailed_overlap(self, env):

mbar_matrix = self.free_energy_overlap(env=env)
upper = np.diagonal(mbar_matrix, offset=1)
lower = np.diagonal(mbar_matrix, offset=-1)
Expand Down
2 changes: 0 additions & 2 deletions transformato/annihilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def calculate_order_of_LJ_mutations_asfe(central_atoms: list, G: nx.Graph) -> list:

ordered_LJ_mutations = []
root = central_atoms[0]

Expand All @@ -18,7 +17,6 @@ def calculate_order_of_LJ_mutations_asfe(central_atoms: list, G: nx.Graph) -> li
G_dummy = G.copy()

while len(G_dummy.nodes()) > 0:

G_origweights = G_dummy.copy()

# dijkstra
Expand Down
3 changes: 0 additions & 3 deletions transformato/charmm_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CharmmFactory:
"""Class to build the string needed to create a CHARMM input and streaming file"""

def __init__(self, configuration: dict, structure: str) -> None:

self.configuration = configuration
self.structure = structure
prms = self._get_simulations_parameters()
Expand All @@ -24,7 +23,6 @@ def _get_simulations_parameters(self):
return prms

def generate_CHARMM_postprocessing_files(self, env: str) -> str:

charmm_postprocessing_script = self._get_CHARMM_postprocessing_header(env)
if env == "vacuum":
charmm_postprocessing_script += self._get_CHARMM_vacuum_postprocessing_body(
Expand Down Expand Up @@ -499,7 +497,6 @@ def _get_CHARMM_waterbox_production_body(self, env):
return body

def _get_CHARMM_postprocessing_header(self, env: str) -> str:

intermediate_filename = self.configuration["system"][self.structure][env][
"intermediate-filename"
]
Expand Down
2 changes: 0 additions & 2 deletions transformato/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def initialize_NUM_PROC(n_proc):


def change_platform_to_test_platform(configuration: dict, engine: str):

if engine == "openMM":
change_to = test_platform_openMM
elif engine == "CHARMM":
Expand All @@ -51,7 +50,6 @@ def change_platform_to_test_platform(configuration: dict, engine: str):


def change_platform_to(configuration: dict, change_to: str):

if change_to.upper() == "GPU":
configuration["simulation"]["GPU"] = True
print("Setting platform to GPU")
Expand Down
Loading

0 comments on commit 58191de

Please sign in to comment.