Skip to content

Commit

Permalink
add charges to cofactor sdf, fix docs, expose overwrite charges to pl…
Browse files Browse the repository at this point in the history
…an CLI
  • Loading branch information
jthorton committed Jan 24, 2025
1 parent 37add05 commit c46e7c1
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 26 deletions.
1 change: 1 addition & 0 deletions docs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- nbsphinx
- nbsphinx-link
- myst-parser
- threadpoolctl
- pip:
- sphinx-design
- sphinx-toolbox
Expand Down
11 changes: 11 additions & 0 deletions openfe/tests/data/eg5/eg5_cofactor.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,15 @@
26 27 1 0 0 0
M CHG 3 3 -1 4 -1 7 -1
M END

> <ofe-name>
3L9H

> <atom.dprop.PartialCharge>
1.3988487435897436 -0.91321825641025633 -0.91321825641025633 -0.91321825641025633 1.5677487435897437 -0.67705125641025643 -0.67705125641025643 -0.77085125641025642 -0.59125125641025633
0.1833487435897436 0.088048743589743572 -0.42865125641025642 0.064048743589743579 -0.59785125641025638 0.080048743589743579 -0.6198512564102564 0.27474874358974355 -0.28105125641025647
0.35164874358974357 -0.76515125641025639 -0.11125125641025642 0.54814874358974364 -0.89255125641025634 -0.77805125641025641 0.56384874358974357 -0.71505125641025635 0.38374874358974354
0.06664874358974357 0.06664874358974357 0.034648743589743576 0.16864874358974358 0.38094874358974357 0.11064874358974358 0.40294874358974359 0.042648743589743576 0.15174874358974358
0.35724874358974357 0.35724874358974357 0.0010487435897435762

$$$$
86 changes: 86 additions & 0 deletions openfe/tests/data/openmm_rfe/dummy_charge_ligand_23.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
ligand_23
RDKit 3D

36 38 0 0 0 0 0 0 0 0999 V2000
-1.9600 21.5500 -27.3300 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.2900 22.4100 -28.2000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.9600 22.9500 -29.2900 C 0 0 0 0 0 0 0 0 0 0 0 0
-3.3000 22.6200 -29.5400 C 0 0 0 0 0 0 0 0 0 0 0 0
-3.9700 21.7600 -28.6500 C 0 0 0 0 0 0 0 0 0 0 0 0
-3.2900 21.2300 -27.5600 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.6400 21.3500 -28.9200 Cl 0 0 0 0 0 0 0 0 0 0 0 0
-4.0400 23.1500 -30.7100 C 0 0 0 0 0 0 0 0 0 0 0 0
-4.2300 22.4200 -31.6700 O 0 0 0 0 0 0 0 0 0 0 0 0
-4.5100 24.4100 -30.6500 N 0 0 0 0 0 0 0 0 0 0 0 0
-5.2900 25.1100 -31.5800 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.9600 24.5500 -32.6800 C 0 0 0 0 0 0 0 0 0 0 0 0
-6.7800 25.3600 -33.4600 C 0 0 0 0 0 0 0 0 0 0 0 0
-6.9200 26.6500 -33.1800 N 0 0 0 0 0 0 0 0 0 0 0 0
-6.3000 27.2300 -32.1600 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.5100 26.4600 -31.3100 C 0 0 0 0 0 0 0 0 0 0 0 0
-6.5400 28.5800 -31.8800 N 0 0 0 0 0 0 0 0 0 0 0 0
-5.7100 29.4500 -31.2300 C 0 0 0 0 0 0 0 0 0 0 0 0
-4.6200 29.1200 -30.8100 O 0 0 0 0 0 0 0 0 0 0 0 0
-6.2300 30.8500 -31.0300 C 0 0 1 0 0 0 0 0 0 0 0 0
-5.5800 31.7500 -29.9800 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.3600 32.0200 -31.4700 C 0 0 1 0 0 0 0 0 0 0 0 0
-4.1100 31.7200 -32.0100 F 0 0 0 0 0 0 0 0 0 0 0 0
-1.1100 24.0500 -30.3300 Cl 0 0 0 0 0 0 0 0 0 0 0 0
-7.3100 30.9400 -31.1600 H 0 0 0 0 0 0 0 0 0 0 0 0
-5.8600 32.9000 -31.8800 H 0 0 0 0 0 0 0 0 0 0 0 0
-1.4400 21.1300 -26.4800 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.2600 22.6600 -28.0200 H 0 0 0 0 0 0 0 0 0 0 0 0
-3.8100 20.5600 -26.8900 H 0 0 0 0 0 0 0 0 0 0 0 0
-4.3200 24.9800 -29.8400 H 0 0 0 0 0 0 0 0 0 0 0 0
-5.8400 23.5000 -32.9100 H 0 0 0 0 0 0 0 0 0 0 0 0
-7.3100 24.9400 -34.3000 H 0 0 0 0 0 0 0 0 0 0 0 0
-5.0600 26.9100 -30.4300 H 0 0 0 0 0 0 0 0 0 0 0 0
-7.4000 29.0100 -32.1800 H 0 0 0 0 0 0 0 0 0 0 0 0
-6.3500 32.2000 -29.3600 H 0 0 0 0 0 0 0 0 0 0 0 0
-4.9200 31.1500 -29.3500 H 0 0 0 0 0 0 0 0 0 0 0 0
13 32 1 0
13 14 1 0
12 13 2 0
14 15 2 0
12 31 1 0
11 12 1 0
17 34 1 0
15 17 1 0
15 16 1 0
22 23 1 0
17 18 1 0
22 26 1 6
8 9 2 0
11 16 2 0
10 11 1 0
20 22 1 0
21 22 1 0
16 33 1 0
18 20 1 0
18 19 2 0
20 25 1 6
20 21 1 0
8 10 1 0
4 8 1 0
10 30 1 0
3 24 1 0
21 35 1 0
21 36 1 0
3 4 2 0
4 5 1 0
2 3 1 0
5 7 1 0
5 6 2 0
2 28 1 0
1 2 2 0
1 6 1 0
6 29 1 0
1 27 1 0
M END
> <atom.dprop.PartialCharge> (1)
-0.097000000000000003 -0.1295 0.050899999999999994 -0.1426 0.050899999999999994 -0.1295 -0.058400000000000007 0.68969999999999998 -0.53810000000000002 -0.46510000000000001 0.1236
-0.32829999999999998 0.44219999999999998 -0.72699999999999998 0.54220000000000002 -0.27029999999999998 -0.5464 0.69610000000000005 -0.56910000000000005 -0.23069999999999999
-0.13339999999999999 0.12759999999999999 -0.20530000000000001 -0.058400000000000007 0.1237 0.1027 0.14799999999999999 0.1565 0.1565 0.32550000000000001 0.14199999999999999
0.022099999999999995 0.20300000000000001 0.33750000000000002 0.094200000000000006 0.094200000000000006

$$$$
79 changes: 79 additions & 0 deletions openfe/tests/data/openmm_rfe/dummy_charge_ligand_55.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ligand_55
RDKit 3D

33 34 0 0 0 0 0 0 0 0999 V2000
-1.9600 21.5500 -27.3300 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.2900 22.4100 -28.2000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.9600 22.9500 -29.2900 C 0 0 0 0 0 0 0 0 0 0 0 0
-3.3000 22.6200 -29.5400 C 0 0 0 0 0 0 0 0 0 0 0 0
-3.9700 21.7600 -28.6500 C 0 0 0 0 0 0 0 0 0 0 0 0
-3.2900 21.2300 -27.5600 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.6400 21.3500 -28.9200 Cl 0 0 0 0 0 0 0 0 0 0 0 0
-4.0400 23.1500 -30.7100 C 0 0 0 0 0 0 0 0 0 0 0 0
-4.2300 22.4200 -31.6700 O 0 0 0 0 0 0 0 0 0 0 0 0
-4.5100 24.4100 -30.6500 N 0 0 0 0 0 0 0 0 0 0 0 0
-5.2900 25.1100 -31.5800 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.9600 24.5500 -32.6800 C 0 0 0 0 0 0 0 0 0 0 0 0
-6.7800 25.3600 -33.4600 C 0 0 0 0 0 0 0 0 0 0 0 0
-6.9200 26.6500 -33.1800 N 0 0 0 0 0 0 0 0 0 0 0 0
-6.3000 27.2300 -32.1600 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.5100 26.4600 -31.3100 C 0 0 0 0 0 0 0 0 0 0 0 0
-6.5400 28.5800 -31.8800 N 0 0 0 0 0 0 0 0 0 0 0 0
-5.7100 29.4500 -31.2300 C 0 0 0 0 0 0 0 0 0 0 0 0
-4.6200 29.1200 -30.8100 O 0 0 0 0 0 0 0 0 0 0 0 0
-1.1100 24.0500 -30.3300 Cl 0 0 0 0 0 0 0 0 0 0 0 0
-1.4400 21.1300 -26.4800 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.2600 22.6600 -28.0200 H 0 0 0 0 0 0 0 0 0 0 0 0
-3.8100 20.5600 -26.8900 H 0 0 0 0 0 0 0 0 0 0 0 0
-4.3200 24.9800 -29.8400 H 0 0 0 0 0 0 0 0 0 0 0 0
-5.8400 23.5000 -32.9100 H 0 0 0 0 0 0 0 0 0 0 0 0
-7.3100 24.9400 -34.3000 H 0 0 0 0 0 0 0 0 0 0 0 0
-5.0600 26.9100 -30.4300 H 0 0 0 0 0 0 0 0 0 0 0 0
-7.4000 29.0100 -32.1800 H 0 0 0 0 0 0 0 0 0 0 0 0
-5.1900 31.8500 -30.6800 C 0 0 0 0 0 0 0 0 0 0 0 0
-5.5900 32.8600 -30.8200 H 0 0 0 0 0 0 0 0 0 0 0 0
-4.9100 31.7200 -29.6300 H 0 0 0 0 0 0 0 0 0 0 0 0
-6.2500 30.8500 -31.0300 O 0 0 0 0 0 0 0 0 0 0 0 0
-4.3200 31.7100 -31.3200 H 0 0 0 0 0 0 0 0 0 0 0 0
13 26 1 0
13 14 1 0
12 13 2 0
14 15 2 0
12 25 1 0
11 12 1 0
17 28 1 0
15 17 1 0
15 16 1 0
17 18 1 0
8 9 2 0
11 16 2 0
10 11 1 0
29 33 1 0
16 27 1 0
18 32 1 0
18 19 2 0
29 32 1 0
29 30 1 0
8 10 1 0
4 8 1 0
29 31 1 0
10 24 1 0
3 20 1 0
3 4 2 0
4 5 1 0
2 3 1 0
5 7 1 0
5 6 2 0
2 22 1 0
1 2 2 0
1 6 1 0
6 23 1 0
1 21 1 0
M END
> <atom.dprop.PartialCharge> (1)
-0.094999969696969694 -0.1279999696969697 0.052400030303030309 -0.1445999696969697 0.052400030303030309 -0.1279999696969697 -0.059899969696969695 0.69270003030303029 -0.54809996969696972
-0.4610999696969697 0.1306000303030303 -0.2992999696969697 0.44520003030303029 -0.72799996969696967 0.55120003030303033 -0.32229996969696967 -0.51939996969696967 0.74610003030303029
-0.57699996969696965 -0.059899969696969695 0.1480000303030303 0.15800003030303031 0.15800003030303031 0.33150003030303032 0.1840000303030303 0.028100030303030307 0.1790000303030303
0.35250003030303029 0.1387000303030303 0.055033030303030306 0.055033030303030306 -0.44289996969696971 0.055033030303030306

$$$$
11 changes: 5 additions & 6 deletions openfecli/commands/generate_partial_charges.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import click
from openfecli import OFECommandPlugin
from openfecli.parameters import MOL_DIR, YAML_OPTIONS, OUTPUT_FILE_AND_EXT, NCORES
from openfecli.parameters import MOL_DIR, YAML_OPTIONS, OUTPUT_FILE_AND_EXT, NCORES, OVERWRITE


@click.command(
Expand All @@ -21,11 +21,10 @@
help=NCORES.kwargs["help"],
default=1,
)
@click.option(
"--overwrite-charges",
is_flag=True,
default=False,
help="If the charges already present in the molecules should be overwritten."
@OVERWRITE.parameter(
help=OVERWRITE.kwargs["help"],
default=OVERWRITE.kwargs["default"],
is_flag=True
)
def charge_molecules(
molecules,
Expand Down
22 changes: 16 additions & 6 deletions openfecli/commands/plan_rbfe_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from openfecli.utils import write, print_duration
from openfecli import OFECommandPlugin
from openfecli.parameters import (
MOL_DIR, PROTEIN, OUTPUT_DIR, COFACTORS, YAML_OPTIONS, NCORES
MOL_DIR, PROTEIN, OUTPUT_DIR, COFACTORS, YAML_OPTIONS, NCORES, OVERWRITE
)

def plan_rbfe_network_main(
Expand All @@ -18,6 +18,7 @@ def plan_rbfe_network_main(
cofactors,
partial_charge_settings,
processors,
overwrite_charges
):
"""Utility method to plan a relative binding free energy network.
Expand All @@ -36,12 +37,14 @@ def plan_rbfe_network_main(
protein : ProteinComponent
protein component for complex simulations, to which the ligands are bound
cofactors : Iterable[SmallMoleculeComponent]
any cofactors alongisde the protein, can be empty list
any cofactors alongside the protein, can be empty list
partial_charge_settings : OpenFFPartialChargeSettings
how to assign partial charges to the input ligands
(if they don't already have partial charges).
processors: int
The number of processors that should be used when generating the charges
overwrite_charges: bool
If any partial charges already present on the small molecules should be overwritten
Returns
-------
Expand All @@ -59,7 +62,7 @@ def plan_rbfe_network_main(

charged_small_molecules = bulk_assign_partial_charges(
molecules=small_molecules,
overwrite=False,
overwrite=overwrite_charges,
method=partial_charge_settings.partial_charge_method,
toolkit_backend=partial_charge_settings.off_toolkit_backend,
generate_n_conformers=partial_charge_settings.number_of_conformers,
Expand All @@ -72,7 +75,7 @@ def plan_rbfe_network_main(

cofactors = bulk_assign_partial_charges(
molecules=cofactors,
overwrite=False,
overwrite=overwrite_charges,
method=partial_charge_settings.partial_charge_method,
toolkit_backend=partial_charge_settings.off_toolkit_backend,
generate_n_conformers=partial_charge_settings.number_of_conformers,
Expand Down Expand Up @@ -120,12 +123,18 @@ def plan_rbfe_network_main(
help=NCORES.kwargs["help"],
default=1,
)
@OVERWRITE.parameter(
help=OVERWRITE.kwargs["help"],
default=OVERWRITE.kwargs["default"],
is_flag=True
)
@print_duration
def plan_rbfe_network(
molecules: list[str], protein: str, cofactors: tuple[str],
yaml_settings: str,
output_dir: str,
n_cores: int
n_cores: int,
overwrite_charges: bool
):
"""
Plan a relative binding free energy network, saved as JSON files for
Expand Down Expand Up @@ -211,7 +220,8 @@ def plan_rbfe_network(
protein=protein,
cofactors=cofactors,
partial_charge_settings=partial_charge,
processors=n_cores
processors=n_cores,
overwrite_charges=overwrite_charges
)
write("\tDone")
write("")
Expand Down
18 changes: 13 additions & 5 deletions openfecli/commands/plan_rhfe_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from openfecli.utils import write, print_duration
from openfecli import OFECommandPlugin
from openfecli.parameters import (
MOL_DIR, MAPPER, OUTPUT_DIR, YAML_OPTIONS, NCORES
MOL_DIR, MAPPER, OUTPUT_DIR, YAML_OPTIONS, NCORES, OVERWRITE
)

def plan_rhfe_network_main(
mapper, mapping_scorer, ligand_network_planner, small_molecules,
solvent, partial_charge_settings, processors
solvent, partial_charge_settings, processors, overwrite_charges
):
"""Utility method to plan a relative hydration free energy network.
Expand All @@ -34,6 +34,8 @@ def plan_rhfe_network_main(
(if they don't already have partial charges).
processors: int
The number of processors that should be used when generating the charges
overwrite_charges: bool
If any partial charges already present on the small molecules should be overwritten
Returns
-------
Expand All @@ -50,7 +52,7 @@ def plan_rhfe_network_main(

charged_small_molecules = bulk_assign_partial_charges(
molecules=small_molecules,
overwrite=False,
overwrite=overwrite_charges,
method=partial_charge_settings.partial_charge_method,
toolkit_backend=partial_charge_settings.off_toolkit_backend,
generate_n_conformers=partial_charge_settings.number_of_conformers,
Expand Down Expand Up @@ -92,8 +94,13 @@ def plan_rhfe_network_main(
help=NCORES.kwargs["help"],
default=1,
)
@OVERWRITE.parameter(
help=OVERWRITE.kwargs["help"],
default=OVERWRITE.kwargs["default"],
is_flag=True
)
@print_duration
def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, n_cores: int):
def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, n_cores: int, overwrite_charges: bool):
"""
Plan a relative hydration free energy network, saved as JSON files for
the quickrun command.
Expand Down Expand Up @@ -169,7 +176,8 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str,
small_molecules=small_molecules,
solvent=solvent,
partial_charge_settings=partial_charge,
processors=n_cores
processors=n_cores,
overwrite_charges=overwrite_charges
)
write("\tDone")
write("")
Expand Down
2 changes: 1 addition & 1 deletion openfecli/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
from .protein import PROTEIN
from .molecules import MOL_DIR, COFACTORS
from .plan_network_options import YAML_OPTIONS
from .misc import NCORES
from .misc import NCORES, OVERWRITE
7 changes: 7 additions & 0 deletions openfecli/parameters/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
"-n",
"--n-cores",
help="The number of cores which should be used for multiprocessing stages."
)

OVERWRITE = Option(
"--overwrite-charges",
is_flag=True,
default=False,
help="If the charges already present in the molecules should be overwritten."
)
Loading

0 comments on commit c46e7c1

Please sign in to comment.