Skip to content

Commit

Permalink
HTF migration (#24)
Browse files Browse the repository at this point in the history
* WIP -- Starting HTF migration

* remove flatten torsions option

* reinclude fix from openfe #675 (perses #1230)

* HTF: simplify _add_nonbonded_force_terms

* port openfe version of LambdaProtocol into feflow

perses version hasn't been touched since April '22

* fixup attempt to be clever...

* port tests from perses to feflow

and modernise to pytest

* Upgraded badges and acknowledgements

* Removing non-relevant tests (protein mut., REST, etc.). Style formatting.

* using gufe tests path fixture

* Comments on why lists objs are needed

* Start of organized module for HTF testing -- WIP

* Renaming to lambda_protocol.py

* Ingesting tests/utils from perses

* Need openeye for testing

* old positions with old system. Fix callable.

* Utility function to extract HTF data from perses top proposal

* Adapt HTF signature. Skipping difficult ones.

* Need to pin minimum openfe version for CI

* Testing convergence difficult overlap

* Modular testing. Software vs science test modules.

* Skip hard to converge test.

* Fix proposal from perses obj

* fixup lambdaprotocol tests

* Migrate tests for "new" HTF features (#32)

* Vsites tests

* temporarily try to get CI working

* Add lambda schedule tests

* add basic tests for mdt and omm topology attributes

* try to fix scope issues

* more scope limiting

* fix lambda_schedule check

* missing self entry

* make gufe_data_dir session scoped

* fix to_openmm calls

* Add gitignore and fix tests

* Update ci.yaml

---------

Co-authored-by: richard gowers <richardjgowers@gmail.com>
Co-authored-by: Richard Gowers <richardjgowers+github@gmail.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 8, 2024
1 parent e01057c commit 2e300ed
Show file tree
Hide file tree
Showing 14 changed files with 4,485 additions and 36 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: "CI"
on:
pull_request:
branches:
- main
push:
branches:
- main
Expand Down Expand Up @@ -36,6 +35,8 @@ jobs:
include:
- os: "macos"
python-version: "3.11"
env:
OE_LICENSE: ${{ github.workspace }}/oe_license.txt

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -66,6 +67,14 @@ jobs:
micromamba info
micromamba list
- name: Decrypt OpenEye license
shell: bash -l {0}
env:
OE_LICENSE_TEXT: ${{ secrets.OE_LICENSE }}
run: |
echo "${OE_LICENSE_TEXT}" > ${OE_LICENSE}
python -c "import openeye; assert openeye.oechem.OEChemIsLicensed(), 'OpenEye license checks failed!'"
- name: "Run tests"
env:
# Set the OFE_SLOW_TESTS to True if running a Cron job
Expand Down
171 changes: 171 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# custom ignores
.duecredit.p
.xxrun
.idea/
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*~

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
_version.py

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/reference/api/generated

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# vim
*.swp

# vscode
.vscode/

# Rever
rever/

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
FE Flow
==============================
[//]: # (Badges)
[![GitHub Actions Build Status](https://github.com/REPLACE_WITH_OWNER_ACCOUNT/feflow/workflows/CI/badge.svg)](https://github.com/REPLACE_WITH_OWNER_ACCOUNT/feflow/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/feflow/branch/main/graph/badge.svg)](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/feflow/branch/main)
[![GitHub Actions Build Status](https://github.com/choderalab/feflow/actions/workflows/ci.yaml/badge.svg)](https://github.com/choderalab/feflow/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/choderalab/feflow/branch/main/graph/badge.svg)](https://codecov.io/gh/choderalab/feflow/branch/main)


Recipes and protocols for molecular free energy calculations using the openmmtools/perses and Open Free Energy toolkits
Recipes, utilities, and protocols for molecular free energy calculations using the openmmtools/perses and Open Free Energy toolkits

### Copyright

Copyright (c) 2023, ChoderaLab


#### Acknowledgements

[Choderalab -- Perses](https://github.com/choderalab/perses)
[Open Free energy Consortium](https://openfree.energy/)
Project based on the
[Computational Molecular Science Python Cookiecutter](https://github.com/molssi/cookiecutter-cms) version 1.1.
6 changes: 5 additions & 1 deletion devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: feflow-test
channels:
- conda-forge
- openeye
dependencies:
# Base depends
- gufe >=0.9.5
- numpy
- openfe # TODO: Remove once we don't depend on openfe
- openfe >=0.15 # TODO: Remove once we don't depend on openfe
- openff-units
- openmm
- pymbar <4
- pydantic=1 # TODO: Modify when we support pydantic 2
- python

# Testing
- openeye-toolkits
- openmoltools # TODO: Remove once we refactor tests
- perses # TODO: Remove once we don't depend on perses for tests
- pytest
- pytest-cov
- pytest-xdist
Expand Down
3 changes: 2 additions & 1 deletion feflow/protocols/nonequilibrium_cycling.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ def _execute(self, ctx, *, state_a, state_b, mapping, settings, **inputs):
"""
# needed imports
import openmm
import numpy as np
from openff.units.openmm import ensure_quantity
from openmmtools.integrators import PeriodicNonequilibriumIntegrator
from gufe.components import SmallMoleculeComponent
from openfe.protocols.openmm_rfe import _rfe_utils
from feflow.utils.hybrid_topology import HybridTopologyFactoryModded as HybridTopologyFactory
from feflow.utils.hybrid_topology import HybridTopologyFactory

# Check compatibility between states (same receptor and solvent)
self._check_states_compatibility(state_a, state_b)
Expand Down
18 changes: 12 additions & 6 deletions feflow/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
from gufe.mapping import LigandAtomMapping


@pytest.fixture
def benzene_modifications():
source = files("gufe.tests.data").joinpath("benzene_modifications.sdf")
@pytest.fixture(scope='session')
def gufe_data_dir():
path = files("gufe.tests.data")
return path


@pytest.fixture(scope='session')
def benzene_modifications(gufe_data_dir):
source = gufe_data_dir.joinpath("benzene_modifications.sdf")
with as_file(source) as f:
supp = Chem.SDMolSupplier(str(f), removeHs=False)
mols = list(supp)
Expand All @@ -23,12 +29,12 @@ def solvent_comp():
yield gufe.SolventComponent(positive_ion="Na", negative_ion="Cl")


@pytest.fixture
@pytest.fixture(scope='session')
def benzene(benzene_modifications):
return gufe.SmallMoleculeComponent(benzene_modifications["benzene"])


@pytest.fixture
@pytest.fixture(scope='session')
def toluene(benzene_modifications):
return gufe.SmallMoleculeComponent(benzene_modifications["toluene"])

Expand Down Expand Up @@ -130,7 +136,7 @@ def production_settings(short_settings):

# Mappings fixtures

@pytest.fixture
@pytest.fixture(scope='session')
def mapping_benzene_toluene(benzene, toluene):
"""Mapping from toluene to benzene"""
mapping_toluene_to_benzene = {0: 4, 1: 5, 2: 6, 3: 7, 4: 8, 5: 9, 6: 10, 7: 11, 8: 12, 9: 13, 11: 14}
Expand Down
Loading

0 comments on commit 2e300ed

Please sign in to comment.