Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 23, 2024
1 parent 37520fe commit a4bbde0
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 90 deletions.
72 changes: 36 additions & 36 deletions feflow/tests/data/capped_AAs/ARG_capped.pdb
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
REMARK 1 CREATED WITH OPENMM 8.1.1, 2024-10-22
HETATM 1 H1 ACE A 1 1.328 2.173 0.000 1.00 0.00 H
HETATM 2 CH3 ACE A 1 2.006 1.318 0.000 1.00 0.00 C
HETATM 3 H2 ACE A 1 2.634 1.352 0.890 1.00 0.00 H
HETATM 4 H3 ACE A 1 2.634 1.352 -0.890 1.00 0.00 H
HETATM 5 C ACE A 1 1.229 0.000 0.000 1.00 0.00 C
HETATM 6 O ACE A 1 0.000 0.000 0.000 1.00 0.00 O
ATOM 7 N ARG A 2 1.954 -1.121 0.000 1.00 0.00 N
ATOM 8 H ARG A 2 3.113 -0.999 -0.240 1.00 0.00 H
ATOM 9 CA ARG A 2 1.337 -2.432 -0.001 1.00 0.00 C
ATOM 10 HA ARG A 2 0.663 -2.344 -0.981 1.00 0.00 H
ATOM 11 CB ARG A 2 2.391 -3.535 -0.001 1.00 0.00 C
ATOM 12 HB2 ARG A 2 3.180 -3.267 -0.861 1.00 0.00 H
ATOM 13 HB3 ARG A 2 3.041 -3.594 1.003 1.00 0.00 H
ATOM 14 C ARG A 2 0.461 -2.626 1.229 1.00 0.00 C
ATOM 15 O ARG A 2 -0.621 -3.201 1.139 1.00 0.00 O
ATOM 16 CG ARG A 2 2.084 -5.004 -0.344 1.00 0.00 C
ATOM 17 HG2 ARG A 2 1.598 -5.507 0.625 1.00 0.00 H
ATOM 18 HG3 ARG A 2 3.136 -5.550 -0.506 1.00 0.00 H
ATOM 19 CD ARG A 2 1.099 -5.210 -1.499 1.00 0.00 C
ATOM 20 HD2 ARG A 2 1.752 -5.185 -2.502 1.00 0.00 H
ATOM 21 HD3 ARG A 2 0.191 -4.493 -1.801 1.00 0.00 H
ATOM 22 NE ARG A 2 0.404 -6.514 -1.519 1.00 0.00 N
ATOM 23 HE ARG A 2 -0.766 -6.478 -1.303 1.00 0.00 H
ATOM 24 CZ ARG A 2 0.893 -7.771 -1.573 1.00 0.00 C
ATOM 25 NH1 ARG A 2 2.182 -8.043 -1.320 1.00 0.00 N
ATOM 26 HH11 ARG A 2 2.609 -8.561 -0.336 1.00 0.00 H
ATOM 27 HH12 ARG A 2 2.902 -8.196 -2.257 1.00 0.00 H
ATOM 28 NH2 ARG A 2 0.038 -8.772 -1.831 1.00 0.00 N
ATOM 29 HH21 ARG A 2 -0.588 -8.881 -2.837 1.00 0.00 H
ATOM 30 HH22 ARG A 2 -0.095 -9.737 -1.148 1.00 0.00 H
HETATM 31 N NME A 3 0.933 -2.143 2.381 1.00 0.00 N
HETATM 32 H NME A 3 1.829 -1.678 2.404 1.00 0.00 H
HETATM 33 C NME A 3 0.194 -2.264 3.621 1.00 0.00 C
HETATM 34 H1 NME A 3 -0.745 -2.786 3.436 1.00 0.00 H
HETATM 35 H2 NME A 3 0.786 -2.827 4.344 1.00 0.00 H
HETATM 36 H3 NME A 3 -0.014 -1.271 4.019 1.00 0.00 H
HETATM 1 H1 ACE A 1 1.328 2.173 0.000 1.00 0.00 H
HETATM 2 CH3 ACE A 1 2.006 1.318 0.000 1.00 0.00 C
HETATM 3 H2 ACE A 1 2.634 1.352 0.890 1.00 0.00 H
HETATM 4 H3 ACE A 1 2.634 1.352 -0.890 1.00 0.00 H
HETATM 5 C ACE A 1 1.229 0.000 0.000 1.00 0.00 C
HETATM 6 O ACE A 1 0.000 0.000 0.000 1.00 0.00 O
ATOM 7 N ARG A 2 1.954 -1.121 0.000 1.00 0.00 N
ATOM 8 H ARG A 2 3.113 -0.999 -0.240 1.00 0.00 H
ATOM 9 CA ARG A 2 1.337 -2.432 -0.001 1.00 0.00 C
ATOM 10 HA ARG A 2 0.663 -2.344 -0.981 1.00 0.00 H
ATOM 11 CB ARG A 2 2.391 -3.535 -0.001 1.00 0.00 C
ATOM 12 HB2 ARG A 2 3.180 -3.267 -0.861 1.00 0.00 H
ATOM 13 HB3 ARG A 2 3.041 -3.594 1.003 1.00 0.00 H
ATOM 14 C ARG A 2 0.461 -2.626 1.229 1.00 0.00 C
ATOM 15 O ARG A 2 -0.621 -3.201 1.139 1.00 0.00 O
ATOM 16 CG ARG A 2 2.084 -5.004 -0.344 1.00 0.00 C
ATOM 17 HG2 ARG A 2 1.598 -5.507 0.625 1.00 0.00 H
ATOM 18 HG3 ARG A 2 3.136 -5.550 -0.506 1.00 0.00 H
ATOM 19 CD ARG A 2 1.099 -5.210 -1.499 1.00 0.00 C
ATOM 20 HD2 ARG A 2 1.752 -5.185 -2.502 1.00 0.00 H
ATOM 21 HD3 ARG A 2 0.191 -4.493 -1.801 1.00 0.00 H
ATOM 22 NE ARG A 2 0.404 -6.514 -1.519 1.00 0.00 N
ATOM 23 HE ARG A 2 -0.766 -6.478 -1.303 1.00 0.00 H
ATOM 24 CZ ARG A 2 0.893 -7.771 -1.573 1.00 0.00 C
ATOM 25 NH1 ARG A 2 2.182 -8.043 -1.320 1.00 0.00 N
ATOM 26 HH11 ARG A 2 2.609 -8.561 -0.336 1.00 0.00 H
ATOM 27 HH12 ARG A 2 2.902 -8.196 -2.257 1.00 0.00 H
ATOM 28 NH2 ARG A 2 0.038 -8.772 -1.831 1.00 0.00 N
ATOM 29 HH21 ARG A 2 -0.588 -8.881 -2.837 1.00 0.00 H
ATOM 30 HH22 ARG A 2 -0.095 -9.737 -1.148 1.00 0.00 H
HETATM 31 N NME A 3 0.933 -2.143 2.381 1.00 0.00 N
HETATM 32 H NME A 3 1.829 -1.678 2.404 1.00 0.00 H
HETATM 33 C NME A 3 0.194 -2.264 3.621 1.00 0.00 C
HETATM 34 H1 NME A 3 -0.745 -2.786 3.436 1.00 0.00 H
HETATM 35 H2 NME A 3 0.786 -2.827 4.344 1.00 0.00 H
HETATM 36 H3 NME A 3 -0.014 -1.271 4.019 1.00 0.00 H
TER 37 NME A 3
CONECT 1 2
CONECT 2 5 1 3 4
Expand Down
68 changes: 34 additions & 34 deletions feflow/tests/data/capped_AAs/LYS_capped.pdb
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
REMARK 1 CREATED WITH OPENMM 8.1.1, 2024-10-22
HETATM 1 H1 ACE A 1 1.328 2.173 0.000 1.00 0.00 H
HETATM 2 CH3 ACE A 1 2.006 1.318 0.000 1.00 0.00 C
HETATM 3 H2 ACE A 1 2.634 1.352 0.890 1.00 0.00 H
HETATM 4 H3 ACE A 1 2.634 1.352 -0.890 1.00 0.00 H
HETATM 5 C ACE A 1 1.229 0.000 0.000 1.00 0.00 C
HETATM 6 O ACE A 1 0.000 0.000 0.000 1.00 0.00 O
ATOM 7 N LYS A 2 1.954 -1.121 0.000 1.00 0.00 N
ATOM 8 H LYS A 2 3.122 -1.025 -0.195 1.00 0.00 H
ATOM 9 CA LYS A 2 1.337 -2.432 -0.001 1.00 0.00 C
ATOM 10 HA LYS A 2 0.565 -2.458 -0.915 1.00 0.00 H
ATOM 11 CB LYS A 2 2.391 -3.535 -0.001 1.00 0.00 C
ATOM 12 HB2 LYS A 2 1.702 -4.515 0.088 1.00 0.00 H
ATOM 13 HB3 LYS A 2 3.047 -3.497 0.998 1.00 0.00 H
ATOM 14 C LYS A 2 0.461 -2.626 1.229 1.00 0.00 C
ATOM 15 O LYS A 2 -0.621 -3.201 1.139 1.00 0.00 O
ATOM 16 CG LYS A 2 3.224 -3.837 -1.235 1.00 0.00 C
ATOM 17 HG2 LYS A 2 2.315 -3.880 -2.010 1.00 0.00 H
ATOM 18 HG3 LYS A 2 4.035 -3.108 -1.721 1.00 0.00 H
ATOM 19 CD LYS A 2 4.148 -4.963 -0.767 1.00 0.00 C
ATOM 20 HD2 LYS A 2 4.973 -4.351 -0.150 1.00 0.00 H
ATOM 21 HD3 LYS A 2 3.850 -5.847 -0.026 1.00 0.00 H
ATOM 22 CE LYS A 2 4.914 -5.474 -1.977 1.00 0.00 C
ATOM 23 HE2 LYS A 2 5.858 -5.939 -1.402 1.00 0.00 H
ATOM 24 HE3 LYS A 2 5.434 -4.831 -2.835 1.00 0.00 H
ATOM 25 NZ LYS A 2 4.338 -6.749 -2.436 1.00 0.00 N
ATOM 26 HZ1 LYS A 2 4.059 -6.551 -3.589 1.00 0.00 H
ATOM 27 HZ2 LYS A 2 5.104 -7.672 -2.508 1.00 0.00 H
ATOM 28 HZ3 LYS A 2 3.279 -7.099 -1.995 1.00 0.00 H
HETATM 29 N NME A 3 0.933 -2.143 2.381 1.00 0.00 N
HETATM 30 H NME A 3 1.829 -1.678 2.404 1.00 0.00 H
HETATM 31 C NME A 3 0.194 -2.264 3.621 1.00 0.00 C
HETATM 32 H1 NME A 3 -0.745 -2.786 3.436 1.00 0.00 H
HETATM 33 H2 NME A 3 0.786 -2.827 4.344 1.00 0.00 H
HETATM 34 H3 NME A 3 -0.014 -1.271 4.019 1.00 0.00 H
HETATM 1 H1 ACE A 1 1.328 2.173 0.000 1.00 0.00 H
HETATM 2 CH3 ACE A 1 2.006 1.318 0.000 1.00 0.00 C
HETATM 3 H2 ACE A 1 2.634 1.352 0.890 1.00 0.00 H
HETATM 4 H3 ACE A 1 2.634 1.352 -0.890 1.00 0.00 H
HETATM 5 C ACE A 1 1.229 0.000 0.000 1.00 0.00 C
HETATM 6 O ACE A 1 0.000 0.000 0.000 1.00 0.00 O
ATOM 7 N LYS A 2 1.954 -1.121 0.000 1.00 0.00 N
ATOM 8 H LYS A 2 3.122 -1.025 -0.195 1.00 0.00 H
ATOM 9 CA LYS A 2 1.337 -2.432 -0.001 1.00 0.00 C
ATOM 10 HA LYS A 2 0.565 -2.458 -0.915 1.00 0.00 H
ATOM 11 CB LYS A 2 2.391 -3.535 -0.001 1.00 0.00 C
ATOM 12 HB2 LYS A 2 1.702 -4.515 0.088 1.00 0.00 H
ATOM 13 HB3 LYS A 2 3.047 -3.497 0.998 1.00 0.00 H
ATOM 14 C LYS A 2 0.461 -2.626 1.229 1.00 0.00 C
ATOM 15 O LYS A 2 -0.621 -3.201 1.139 1.00 0.00 O
ATOM 16 CG LYS A 2 3.224 -3.837 -1.235 1.00 0.00 C
ATOM 17 HG2 LYS A 2 2.315 -3.880 -2.010 1.00 0.00 H
ATOM 18 HG3 LYS A 2 4.035 -3.108 -1.721 1.00 0.00 H
ATOM 19 CD LYS A 2 4.148 -4.963 -0.767 1.00 0.00 C
ATOM 20 HD2 LYS A 2 4.973 -4.351 -0.150 1.00 0.00 H
ATOM 21 HD3 LYS A 2 3.850 -5.847 -0.026 1.00 0.00 H
ATOM 22 CE LYS A 2 4.914 -5.474 -1.977 1.00 0.00 C
ATOM 23 HE2 LYS A 2 5.858 -5.939 -1.402 1.00 0.00 H
ATOM 24 HE3 LYS A 2 5.434 -4.831 -2.835 1.00 0.00 H
ATOM 25 NZ LYS A 2 4.338 -6.749 -2.436 1.00 0.00 N
ATOM 26 HZ1 LYS A 2 4.059 -6.551 -3.589 1.00 0.00 H
ATOM 27 HZ2 LYS A 2 5.104 -7.672 -2.508 1.00 0.00 H
ATOM 28 HZ3 LYS A 2 3.279 -7.099 -1.995 1.00 0.00 H
HETATM 29 N NME A 3 0.933 -2.143 2.381 1.00 0.00 N
HETATM 30 H NME A 3 1.829 -1.678 2.404 1.00 0.00 H
HETATM 31 C NME A 3 0.194 -2.264 3.621 1.00 0.00 C
HETATM 32 H1 NME A 3 -0.745 -2.786 3.436 1.00 0.00 H
HETATM 33 H2 NME A 3 0.786 -2.827 4.344 1.00 0.00 H
HETATM 34 H3 NME A 3 -0.014 -1.271 4.019 1.00 0.00 H
TER 35 NME A 3
CONECT 1 2
CONECT 2 5 1 3 4
Expand Down
93 changes: 73 additions & 20 deletions feflow/tests/test_protein_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ def ala_to_gly_mapping():
def gly_to_ala_mapping(ala_capped, gly_capped, ala_to_gly_mapping):
"""GLY to ALA mapping. Inverts the ala_to_gly_mapping fixture."""
gly_to_ala_map = ala_to_gly_mapping.componentB_to_componentA
mapping = LigandAtomMapping(componentA=gly_capped, componentB=ala_capped,
componentA_to_componentB=gly_to_ala_map)
mapping = LigandAtomMapping(
componentA=gly_capped,
componentB=ala_capped,
componentA_to_componentB=gly_to_ala_map,
)
return mapping


Expand All @@ -135,8 +138,11 @@ def ala_to_arg_mapping():
def arg_to_ala_mapping(ala_capped, arg_capped, ala_to_arg_mapping):
"""ARG to ALA mapping. Inverts the ala_to_arg_mapping fixture."""
arg_to_ala_map = ala_to_arg_mapping.componentB_to_componentA
mapping = LigandAtomMapping(componentA=arg_capped, componentB=ala_capped,
componentA_to_componentB=arg_to_ala_map)
mapping = LigandAtomMapping(
componentA=arg_capped,
componentB=ala_capped,
componentA_to_componentB=arg_to_ala_map,
)
return mapping


Expand All @@ -155,8 +161,11 @@ def ala_to_lys_mapping():
def lys_to_ala_mapping(ala_capped, lys_capped, ala_to_lys_mapping):
"""GLY to ALA mapping. Inverts the ala_to_gly_mapping fixture."""
lys_to_ala_map = ala_to_lys_mapping.componentB_to_componentA
mapping = LigandAtomMapping(componentA=lys_capped, componentB=ala_capped,
componentA_to_componentB=lys_to_ala_map)
mapping = LigandAtomMapping(
componentA=lys_capped,
componentB=ala_capped,
componentA_to_componentB=lys_to_ala_map,
)
return mapping


Expand Down Expand Up @@ -251,7 +260,9 @@ def protocol_asp_to_leu_result(

return protocol_short, dag, dagresult

def execute_forward_reverse_dag(self, component_a, component_b, system_a, system_b, mapping_obj, tmpdir):
def execute_forward_reverse_dag(
self, component_a, component_b, system_a, system_b, mapping_obj, tmpdir
):
"""
Perform a forward and reverse free energy (FE) estimation between two protein mutation systems.
Expand Down Expand Up @@ -288,8 +299,11 @@ def execute_forward_reverse_dag(self, component_a, component_b, system_a, system
)
# Reverse mapping
arg_to_ala_dict = mapping_obj.componentB_to_componentA
arg_to_ala_mapping = LigandAtomMapping(componentA=component_b, componentB=component_a,
componentA_to_componentB=arg_to_ala_dict)
arg_to_ala_mapping = LigandAtomMapping(
componentA=component_b,
componentB=component_a,
componentA_to_componentB=arg_to_ala_dict,
)
reverse_dag = protocol.create(
stateA=system_b,
stateB=system_a,
Expand Down Expand Up @@ -324,7 +338,7 @@ def execute_forward_reverse_dag(self, component_a, component_b, system_a, system

# they should add up to close to zero
forward_reverse_sum = forward_fe + reverse_fe
forward_reverse_sum_error = forward_error ** 2 + reverse_error ** 2
forward_reverse_sum_error = forward_error**2 + reverse_error**2

return forward_reverse_sum, forward_reverse_sum_error

Expand All @@ -351,7 +365,14 @@ def test_asp_to_leu_execute(self, protocol_asp_to_leu_result):
assert finishresult.name == "result"

@pytest.mark.slow
def test_ala_gly_convergence(self, ala_capped_system, gly_capped_system, ala_to_gly_mapping, gly_to_ala_mapping, tmpdir):
def test_ala_gly_convergence(
self,
ala_capped_system,
gly_capped_system,
ala_to_gly_mapping,
gly_to_ala_mapping,
tmpdir,
):
"""Convergence test for ALA to GLY forward and reverse neutral protein mutation protocol
execution with default (production-ready) settings. Runs ALA to GLY and compares the
FE estimate with running GLY to ALA."""
Expand Down Expand Up @@ -401,14 +422,28 @@ def test_ala_gly_convergence(self, ala_capped_system, gly_capped_system, ala_to_

# they should add up to close to zero
forward_reverse_sum = abs(forward_fe + reverse_fe)
forward_reverse_sum_err = np.sqrt(forward_error ** 2 + reverse_error ** 2)
print(f"DDG: {forward_reverse_sum}, 6*dDDG: {6 * forward_reverse_sum_err}") # DEBUG
forward_reverse_sum_err = np.sqrt(forward_error**2 + reverse_error**2)
print(
f"DDG: {forward_reverse_sum}, 6*dDDG: {6 * forward_reverse_sum_err}"
) # DEBUG
assert forward_reverse_sum < 6 * forward_reverse_sum_err, (
f"DDG ({forward_reverse_sum}) is greater than "
f"6 * dDDG ({6 * forward_reverse_sum_err})")
f"6 * dDDG ({6 * forward_reverse_sum_err})"
)

@pytest.mark.slow
def test_charge_changing_convergence(self, arg_capped, ala_capped, lys_capped, ala_capped_system, arg_capped_system, lys_capped_system, arg_to_ala_mapping, lys_to_ala_mapping, tmpdir):
def test_charge_changing_convergence(
self,
arg_capped,
ala_capped,
lys_capped,
ala_capped_system,
arg_capped_system,
lys_capped_system,
arg_to_ala_mapping,
lys_to_ala_mapping,
tmpdir,
):
"""
Test for charge changing transformation for the protein mutation protocol.
Expand All @@ -421,13 +456,31 @@ def test_charge_changing_convergence(self, arg_capped, ala_capped, lys_capped, a
and negative full cycles.
"""
# Create and execute DAGs
arg_results = self.execute_forward_reverse_dag(arg_capped, ala_capped, arg_capped_system, ala_capped_system, arg_to_ala_mapping, tmpdir)
lys_results = self.execute_forward_reverse_dag(lys_capped, ala_capped, lys_capped_system, ala_capped_system, lys_to_ala_mapping, tmpdir)
arg_results = self.execute_forward_reverse_dag(
arg_capped,
ala_capped,
arg_capped_system,
ala_capped_system,
arg_to_ala_mapping,
tmpdir,
)
lys_results = self.execute_forward_reverse_dag(
lys_capped,
ala_capped,
lys_capped_system,
ala_capped_system,
lys_to_ala_mapping,
tmpdir,
)

# FE estimates are the first element, errors are the second element in the tuple
arg_lys_diff = abs(arg_results[0] - lys_results[0])
arg_lys_diff_error = np.sqrt(arg_results[1] + lys_results[1])

print(f"DDG: {arg_lys_diff}, 6*dDDG: {6 * arg_lys_diff_error}") # debug control print
assert arg_lys_diff < 6 * arg_lys_diff_error, (f"DDG ({arg_lys_diff}) is greater than "
f"6 * dDDG ({6 * arg_lys_diff_error})")
print(
f"DDG: {arg_lys_diff}, 6*dDDG: {6 * arg_lys_diff_error}"
) # debug control print
assert arg_lys_diff < 6 * arg_lys_diff_error, (
f"DDG ({arg_lys_diff}) is greater than "
f"6 * dDDG ({6 * arg_lys_diff_error})"
)

0 comments on commit a4bbde0

Please sign in to comment.