-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from choderalab/fix-ci
Fix ci
- Loading branch information
Showing
10 changed files
with
162 additions
and
26 deletions.
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
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,38 @@ | ||
name: "Build Doc" | ||
on: | ||
- push | ||
|
||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
installer-url: ${{ matrix.conda-installer }} | ||
python-version: ${{ matrix.python-version }} | ||
activate-environment: test | ||
channel-priority: true | ||
environment-file: devtools/conda-envs/espaloma.yaml | ||
auto-activate-base: false | ||
use-mamba: true | ||
|
||
- name: Install package | ||
shell: bash -l {0} | ||
run: | | ||
python -m pip install --no-deps . | ||
- name: Compile | ||
shell: bash -l {0} | ||
run: | | ||
python -m pip install sphinx sphinx-rtd-theme numpydoc | ||
cd docs && make html | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: docs/_build/html |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,4 +1,76 @@ | ||
Getting Started | ||
=============== | ||
|
||
This page details how to get started with espaloma. | ||
.. image:: _static/espaloma_abstract_v2-2.png | ||
|
||
Paper Abstract | ||
-------------- | ||
Molecular mechanics (MM) potentials have long been a workhorse of computational chemistry. | ||
Leveraging accuracy and speed, these functional forms find use in a wide variety of applications in biomolecular modeling and drug discovery, from rapid virtual screening to detailed free energy calculations. | ||
Traditionally, MM potentials have relied on human-curated, inflexible, and poorly extensible discrete chemical perception rules _atom types_ for applying parameters to small molecules or biopolymers, making it difficult to optimize both types and parameters to fit quantum chemical or physical property data. | ||
Here, we propose an alternative approach that uses _graph neural networks_ to perceive chemical environments, producing continuous atom embeddings from which valence and nonbonded parameters can be predicted using invariance-preserving layers. | ||
Since all stages are built from smooth neural functions, the entire process---spanning chemical perception to parameter assignment---is modular and end-to-end differentiable with respect to model parameters, allowing new force fields to be easily constructed, extended, and applied to arbitrary molecules. | ||
We show that this approach is not only sufficiently expressive to reproduce legacy atom types, but that it can learn and extend existing molecular mechanics force fields, construct entirely new force fields applicable to both biopolymers and small molecules from quantum chemical calculations, and even learn to accurately predict free energies from experimental observables. | ||
|
||
Minimal Example | ||
--------------- | ||
:: | ||
|
||
import torch, dgl, espaloma as esp | ||
|
||
# retrieve QM dataset used to train OpenFF 1.0.0 ("parsley") small molecule force field | ||
dataset = esp.data.dataset.GraphDataset.load("parsley").view(batch_size=128) | ||
|
||
# define Espaloma stage I: graph -> atom latent representation | ||
representation = esp.nn.Sequential( | ||
layer=esp.nn.layers.dgl_legacy.gn("SAGEConv"), # use SAGEConv implementation in DGL | ||
config=[128, "relu", 128, "relu", 128, "relu"], # 3 layers, 128 units, ReLU activation | ||
) | ||
|
||
# define Espaloma stage II and III: | ||
# atom latent representation -> bond, angle, and torsion representation and parameters | ||
readout = esp.nn.readout.janossy.JanossyPooling( | ||
in_features=128, | ||
config=[128, "relu", 128, "relu", 128, "relu"], | ||
out_features={ # define modular MM parameters Espaloma will assign | ||
1: {"e": 1, "s": 1}, | ||
2: {"coefficients": 2}, # bond linear combination | ||
3: {"coefficients": 3}, # angle linear combination | ||
4: {"k": 6}, # torsion barrier heights (can be positive or negative) | ||
}, | ||
) | ||
|
||
# compose all three Espaloma stages into an end-to-end model | ||
espaloma_model = torch.nn.Sequential( | ||
representation, | ||
readout, | ||
esp.mm.geometry.GeometryInGraph(), | ||
esp.mm.energy.EnergyInGraph(), | ||
esp.nn.readout.charge_equilibrium.ChargeEquilibrium(), | ||
) | ||
|
||
# define training metric | ||
metrics = [ | ||
esp.metrics.GraphMetric( | ||
base_metric=torch.nn.MSELoss(), # use mean-squared error loss | ||
between=['u', "u_ref"], # between predicted and QM energies | ||
level="g", | ||
) | ||
esp.metrics.GraphMetric( | ||
base_metric=torch.nn.MSELoss(), # use mean-squared error loss | ||
between=['q', "q_hat"], # between predicted and reference charges | ||
level="n1", | ||
) | ||
] | ||
|
||
# fit Espaloma model to training data | ||
results = esp.Train( | ||
ds_tr=dataset, net=espaloma_model, metrics=metrics, | ||
device=torch.device('cuda:0'), n_epochs=5000, | ||
optimizer=lambda net: torch.optim.Adam(net.parameters(), 1e-3), # use Adam optimizer | ||
).run() | ||
|
||
|
||
|
||
|
||
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
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