-
Notifications
You must be signed in to change notification settings - Fork 10
CLI charging update #187
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
Merged
Merged
CLI charging update #187
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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,105 @@ | ||
| # Generating Partial Charges with the OpenFE CLI | ||
|
|
||
| It is recommended to use a single set of charges for each ligand to ensure reproducibility between repeats or consistent | ||
| charges between different legs of a calculation involving the same ligand, like a relative binding affinity calculation for example (see [Osato et al.](https://chemrxiv.org/engage/chemrxiv/article-details/67579833085116a133e39d86)). | ||
| As such both the `plan-rbfe-network` and `plan-rhfe-network` commands will calculate partial charges for ligands making it expensive | ||
| to run multiple network mappings while finding the optimal one for the resources available. | ||
|
|
||
| Here we present a CLI tool to do this ahead of time, reducing overheads and further improving reproducibility. | ||
| This tutorial will show you how to use the OpenFE CLI command `charge-molecules` to generate and store partial charges for a series of ligands | ||
| into an SDF file which can be used with OpenFE protocols. | ||
|
|
||
| ## Charging Molecules | ||
|
|
||
| The `charge-molecules` command allows you to generate partial charges a series of small molecules saved in SDF or MOL2 | ||
| format using the `am1bcc` method calculated using `ambertools`: | ||
|
|
||
| ```bash | ||
| openfe charge-molecules -M tyk2_ligands.sdf -o charged_tyk2_ligands.sdf | ||
| ``` | ||
|
|
||
| This will result in a new SDF file `charged_tyk2_ligands.sdf` which contains the same ligands and their partial charges | ||
| stored in a new SD tag like so: | ||
|
|
||
| ```text | ||
| lig_ejm_42 | ||
| RDKit 3D | ||
|
|
||
| 35 36 0 0 0 0 0 0 0 0999 V2000 | ||
| -4.7651 -2.8327 -16.5085 H 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| -5.3566 -3.6931 -16.2274 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| -4.7703 -4.9699 -16.2000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
| [continues] | ||
| 28 31 1 0 | ||
| M END | ||
|
|
||
| > <ofe-name> | ||
| lig_ejm_42 | ||
|
|
||
| > <atom.dprop.PartialCharge> | ||
| 0.14794282857142857 -0.096057171428571425 -0.12905717142857143 ... | ||
| [continues] | ||
| ``` | ||
|
|
||
| Generating partial charges with the `am1bcc` method can be slow as they require a semi-empirical quantum chemical calculation, | ||
| we can however take advantage of multiprocessing to calculate the charges in parallel for each ligand which offers a | ||
| significant speed-up. The number of processors available for the workflow can be specified using the `-n` flag. For | ||
| example to spread out the calculation over 4 cores: | ||
|
|
||
| ```bash | ||
| openfe charge-molecules -M tyk2_ligands.sdf -o charged_tyk2_ligands.sdf -n 4 | ||
| ``` | ||
|
|
||
| ## Customizing the Charge Method | ||
|
|
||
| There are a wide range of partial charge generation methods available with `am1bcc` based schemes being most commonly | ||
| used with OpenFF force fields. The choice of charge scheme can be easily customised by providing a settings file in `.yaml` format. | ||
| For example to recreate the current default settings in the workflow you would do the following: | ||
|
|
||
| 1. Provide a file like `settings.yaml` with the desired settings: | ||
|
|
||
| ```yaml | ||
| partial_charge: | ||
| method: am1bcc | ||
| settings: | ||
| off_toolkit_backend: ambertools | ||
| ``` | ||
|
|
||
| 2. Charge the ligands with an additional `-s` flag for passing the settings: | ||
|
|
||
| ```bash | ||
| openfe charge-molecules -M tyk2_ligands.sdf -o charged_tyk2_ligands.sdf -n 4 -s settings.yaml | ||
| ``` | ||
|
|
||
| 3. The output of the CLI program will now reflect the changes made: | ||
|
|
||
| ```text | ||
| SMALL MOLECULE PARTIAL CHARGE GENERATOR | ||
| _________________________________________ | ||
|
|
||
| Parsing in Files: | ||
| Got input: | ||
| Small Molecules: SmallMoleculeComponent(name=lig_ejm_31) SmallMoleculeComponent(name=lig_ejm_42) SmallMoleculeComponent(name=lig_ejm_43) SmallMoleculeComponent(name=lig_ejm_46) SmallMoleculeComponent(name=lig_ejm_47) SmallMoleculeComponent(name=lig_ejm_48) SmallMoleculeComponent(name=lig_ejm_50) SmallMoleculeComponent(name=lig_jmc_23) SmallMoleculeComponent(name=lig_jmc_27) SmallMoleculeComponent(name=lig_jmc_28) | ||
| Using Options: | ||
| Partial Charge Generation: am1bcc | ||
| ``` | ||
|
|
||
| The full range of partial charge settings can be found in the snippet bellow, note that some may require installing extra packages. | ||
|
|
||
| ```yaml | ||
| partial_charge: | ||
| method: am1bcc | ||
| # method: am1bccelf10 | ||
| # method: espaloma | ||
| # method: nagl | ||
| settings: | ||
| off_toolkit_backend: ambertools | ||
| # off_toolkit_backend: openeye # required for the am1bccelf10 method | ||
| number_of_conformers: null # null specifies the use of the input conformer, a value requests that a new conformer be generated | ||
| # nagl_model: null # null specifies the use of the latest nagl model | ||
| ``` | ||
|
|
||
| ## Overwriting Charges | ||
|
|
||
| By default, the `charge-molecules` command will only assign partial charges to ligands which **do not** already have charges, | ||
| this behaviour can be changed via the `--overwrite-charges` flag which will assign new charges using the specified settings. | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Do you want to link to Meghan's preprint here?