Skip to content

Commit cc32b2b

Browse files
authored
Merge pull request #31 from michellab/release/0.3.0
Release 0.3.0, with OpenFF as the default strategy
2 parents 9933375 + 33da460 commit cc32b2b

13 files changed

Lines changed: 203 additions & 140 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 125 additions & 108 deletions
Large diffs are not rendered by default.

‎README.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pip install -e .
2020
```
2121

2222
The core needs only OpenMM, NumPy and networkx. Sire, OpenFF, the ML packages and EMLE are optional
23-
extras (`pip install -e ".[openff,ml]"`); see [Installation](docs/installation.md).
23+
extras (`pip install -e ".[openff,ml]"`); see [Installation](https://michellab.github.io/fes-ml/installation/).
2424

2525
## Quick start
2626

@@ -39,9 +39,9 @@ lambda_schedule = {
3939
fes = FES(output_prefix="benzene_water")
4040
fes.create_alchemical_states(
4141
lambda_schedule=lambda_schedule,
42-
alchemical_atoms=list(range(12)),
43-
top_file="benzene_water.prm7",
44-
crd_file="benzene_water.rst7",
42+
alchemical_atoms=list(range(12)), # benzene is the first molecule: atoms 0 to 11
43+
smiles_ligand="c1ccccc1",
44+
smiles_solvent="O",
4545
)
4646
fes.minimize(max_iterations=1000)
4747
fes.equilibrate(100_000)
@@ -50,12 +50,12 @@ np.save("U_kln.npy", np.asarray(U_kln))
5050
```
5151

5252
More in the user guide:
53-
[λ schedules and modifications](docs/guide/schedules.md),
54-
[running simulations](docs/guide/running.md) (one window per job, restarts),
55-
[Sire and OpenFF strategies, EMLE](docs/guide/strategies.md),
56-
[alchemical groups](docs/guide/groups.md),
57-
[writing a modification](docs/guide/extending.md),
58-
[logging](docs/guide/logging.md).
53+
[λ schedules and modifications](https://michellab.github.io/fes-ml/guide/schedules/),
54+
[running simulations](https://michellab.github.io/fes-ml/guide/running/) (one window per job, restarts),
55+
[Sire and OpenFF strategies, EMLE](https://michellab.github.io/fes-ml/guide/strategies/),
56+
[alchemical groups](https://michellab.github.io/fes-ml/guide/groups/),
57+
[writing a modification](https://michellab.github.io/fes-ml/guide/extending/),
58+
[logging](https://michellab.github.io/fes-ml/guide/logging/).
5959
Examples are in [`examples/`](examples/).
6060

6161
## Contributing

‎docs/guide/running.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from fes_ml import FES
77

88
fes = FES(output_prefix="run", checkpoint_frequency=10)
9-
fes.create_alchemical_states(lambda_schedule=schedule, alchemical_atoms=ligand,
9+
fes.create_alchemical_states(lambda_schedule=schedule, alchemical_atoms=ligand, strategy_name="sire",
1010
top_file="system.prm7", crd_file="system.rst7")
1111
fes.minimize(max_iterations=1000)
1212
fes.equilibrate(100_000)
@@ -36,7 +36,7 @@ With `shared_context=True`, fes-ml builds one System and one OpenMM Context, and
3636
set of λ global-parameter values:
3737

3838
```python
39-
fes.create_alchemical_states(lambda_schedule=schedule, alchemical_atoms=ligand,
39+
fes.create_alchemical_states(lambda_schedule=schedule, alchemical_atoms=ligand, strategy_name="sire",
4040
top_file="system.prm7", crd_file="system.rst7", shared_context=True)
4141
```
4242

‎docs/guide/strategies.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# Creation strategies
22

33
A creation strategy builds the unmodified OpenMM System from your input, then hands it to the
4-
modifications. Choose one with `strategy_name` in `create_alchemical_states`; its options are passed
5-
as keyword arguments there too.
4+
modifications. Choose one with `strategy_name` in `create_alchemical_states`. Pass the options of
5+
the strategy as keyword arguments to the same call.
66

77
| `strategy_name` | Input | Extra |
88
|---|---|---|
9-
| `"sire"` (default) | Amber (or any Sire-readable) topology and coordinates: `top_file`, `crd_file` | `sire` |
10-
| `"openff"` | SMILES and a force field; the box is built with Packmol | `openff` |
9+
| `"openff"` (default) | SMILES or SDF files and a force field. Packmol builds the box. | `openff` |
10+
| `"sire"` | Amber (or any Sire-readable) topology and coordinates: `top_file`, `crd_file` | `sire` |
11+
12+
Before 0.3.0 the default was `"sire"`. If you pass `top_file` or `crd_file` without
13+
`strategy_name`, fes-ml stops with an error that tells you to pass `strategy_name="sire"`.
1114

1215
## Sire
1316

@@ -29,6 +32,7 @@ dynamics_kwargs = {
2932
fes.create_alchemical_states(
3033
lambda_schedule=schedule,
3134
alchemical_atoms=ligand,
35+
strategy_name="sire",
3236
top_file="system.prm7",
3337
crd_file="system.rst7",
3438
dynamics_kwargs=dynamics_kwargs,

‎docs/index.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ lambda_schedule = {
2626
fes = FES(output_prefix="benzene_water")
2727
fes.create_alchemical_states(
2828
lambda_schedule=lambda_schedule,
29-
alchemical_atoms=list(range(12)),
30-
top_file="benzene_water.prm7",
31-
crd_file="benzene_water.rst7",
29+
alchemical_atoms=list(range(12)), # benzene is the first molecule: atoms 0 to 11
30+
smiles_ligand="c1ccccc1",
31+
smiles_solvent="O",
3232
)
3333
fes.minimize(max_iterations=1000)
3434
fes.equilibrate(100_000) # 100 ps at 1 fs per state

‎docs/installation.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ system builders and potentials are optional extras, so you install only what you
55

66
| Extra | Gives you | Packages |
77
|---|---|---|
8-
| `sire` | the default Sire creation strategy (Amber files) | `sire` |
9-
| `openff` | the OpenFF creation strategy, `CustomLJ`, `ChargeTransfer` | `openff-toolkit`, `openff-interchange` |
8+
| `sire` | the Sire creation strategy (Amber files) | `sire` |
9+
| `openff` | the OpenFF creation strategy (the default), `CustomLJ`, `ChargeTransfer` | `openff-toolkit`, `openff-interchange` |
1010
| `ml` | `MLPotential`, `MLInterpolation`, `MLCorrection` | `openmm-ml`, `openmm-torch`, `torch`, `torchani` |
1111
| `emle` | `EMLEPotential` (electrostatic embedding) | `emle-engine`, `sire` |
1212
| `analysis` | MBAR | `pymbar` |

‎src/fes_ml/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""fes_ml base package."""
22

3-
__version__ = "0.2.2"
3+
__version__ = "0.3.0"
44
__author__ = "Joao Morado"
55

66
from .fes import FES

‎src/fes_ml/alchemical/alchemical_factory.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ def get_strategy(self, name: str) -> AlchemicalStateCreationStrategy:
6868
strategy = self.strategies[name] = getattr(module, class_name)()
6969
return strategy
7070

71-
def create_alchemical_state(self, strategy_name: str = "sire", *args, **kwargs) -> AlchemicalState:
71+
def create_alchemical_state(self, strategy_name: str = "openff", *args, **kwargs) -> AlchemicalState:
7272
"""
7373
Create an alchemical state for the given λ values.
7474
7575
Parameters
7676
----------
77-
strategy_name : str, default='sire'
77+
strategy_name : str, default='openff'
7878
The name of the strategy to create the alchemical state.
7979
8080
Returns

‎src/fes_ml/fes.py‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
logger = logging.getLogger(__name__)
2121

2222

23+
# Strategy used when create_alchemical_states gets no strategy_name
24+
DEFAULT_STRATEGY = "openff"
25+
26+
2327
class FES:
2428
"""
2529
A class to perform free energy calculations.
@@ -99,7 +103,7 @@ def __init__(
99103
self._lambda_schedule: Dict[str, List[Union[float, None]]] = None
100104
self._alchemical_atoms: List[int] = None
101105
self._modifications_kwargs: Optional[Dict[str, Dict[str, Any]]] = None
102-
self._strategy_name: str = "sire"
106+
self._strategy_name: str = DEFAULT_STRATEGY
103107
self._create_alchemical_states_args: Optional[Tuple[Any, ...]] = None
104108
self._create_alchemical_states_kwargs: Optional[Dict[str, Any]] = None
105109

@@ -339,7 +343,7 @@ def create_alchemical_states(
339343
lambda_schedule: Dict[str, List[Union[float, None]]],
340344
alchemical_atoms: Optional[Union[List[int], Dict[str, List[int]]]] = None,
341345
modifications_kwargs: Optional[Dict[str, Dict[str, Any]]] = None,
342-
strategy_name: str = "sire",
346+
strategy_name: Optional[str] = None,
343347
*args,
344348
**kwargs,
345349
) -> List[AlchemicalState]:
@@ -364,9 +368,9 @@ def create_alchemical_states(
364368
},
365369
...
366370
}
367-
strategy_name : str, optional, default='sire'
368-
The name of the strategy to create the alchemical state.
369-
Available strategies are: "sire".
371+
strategy_name : str, optional, default='openff'
372+
The name of the strategy that builds the System: "openff" (SMILES or SDF input)
373+
or "sire" (Amber topology and coordinates in ``top_file`` and ``crd_file``).
370374
371375
Returns
372376
-------
@@ -387,6 +391,15 @@ def create_alchemical_states(
387391
emle = kwargs.pop("emle_kwargs") or {}
388392
modifications_kwargs["EMLEPotential"] = {**emle, **modifications_kwargs.get("EMLEPotential", {})}
389393

394+
if strategy_name is None:
395+
sire_inputs = sorted(key for key in ("top_file", "crd_file") if key in kwargs)
396+
if sire_inputs:
397+
# The default was "sire" before 0.3.0: do not send Amber files to OpenFF
398+
raise ValueError(
399+
f"{sire_inputs} are inputs of the Sire strategy, and the default strategy is 'openff'. Pass strategy_name='sire'."
400+
)
401+
strategy_name = DEFAULT_STRATEGY
402+
390403
kwargs = dict(kwargs)
391404
shared_context = bool(kwargs.pop("shared_context", False))
392405

‎tests/integration/test_sire_decoupling.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def test_shared_context_windows_match_reference(in_tmp_path, benzene_water_files
8888
windows = [(1.0, 1.0), (1.0, 0.5), (1.0, 0.0), (0.5, 0.0), (0.0, 0.0)]
8989
schedule = {"ChargeScaling": [q for q, _ in windows], "LJSoftCore": [lj for _, lj in windows]}
9090
states = FES(restart=False).create_alchemical_states(
91+
strategy_name="sire",
9192
lambda_schedule=schedule,
9293
alchemical_atoms=ligand,
9394
top_file=top,

0 commit comments

Comments
 (0)