Skip to content

Commit

Permalink
Blacken
Browse files Browse the repository at this point in the history
  • Loading branch information
fjclark committed Oct 29, 2024
1 parent e174b9c commit 11f3ccb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@ def analyse(
"The decoupled molecule has more than one residue and is likely a macromolecule. Ensure that this is intended."
)


ligand_selection_str = f"((resname {decoupled_resname}) and (not name H*))"
if append_to_ligand_selection:
ligand_selection_str += " and "
Expand Down Expand Up @@ -1033,10 +1032,12 @@ def _findOrderedPairs(u, ligand_selection_str, receptor_selection_str, cutoff):
"""

lig_selection = u.select_atoms(ligand_selection_str)

# Ensure that there are no shared atoms between the ligand selection and all possible receptor selections.
all_possible_receptor_selection = u.select_atoms(receptor_selection_str)
shared_atoms = [atom for atom in lig_selection if atom in all_possible_receptor_selection]
shared_atoms = [
atom for atom in lig_selection if atom in all_possible_receptor_selection
]
if shared_atoms:
raise _AnalysisError(
"Shared atoms between ligand and receptor selections detected. "
Expand Down Expand Up @@ -1521,7 +1522,9 @@ def _findOrderedBoresch(
dtheta = abs(val - circmean)
corrected_values.append(min(dtheta, 2 * _np.pi - dtheta))
corrected_values = _np.array(corrected_values)
boresch_dof_data[pair][dof]["var"] = _np.mean(corrected_values ** 2)
boresch_dof_data[pair][dof]["var"] = _np.mean(
corrected_values**2
)

# Assume Gaussian distributions and calculate force constants for harmonic potentials
# so as to reproduce these distributions at 298 K
Expand Down
7 changes: 5 additions & 2 deletions tests/Sandpit/Exscientia/FreeEnergy/test_restraint_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def test_top(self, restraint_search):
with open(outdir / "BoreschRestraint.top", "r") as f:
assert "intermolecular_interactions" in f.read()


@pytest.mark.skipif(
(has_gromacs is False or has_mdanalysis is False),
reason="Requires MDAnalysis and Gromacs to be installed.",
Expand Down Expand Up @@ -177,7 +178,7 @@ def _restraint_search(self, tmp_path_factory):
@pytest.fixture(scope="class")
def _restraint_search_protein(self, tmp_path_factory):
# Select the protein as the ligand.
return partial(self._restraint_search_general, tmp_path_factory,ligand_idx=0)()
return partial(self._restraint_search_general, tmp_path_factory, ligand_idx=0)()

@staticmethod
@pytest.fixture(scope="class")
Expand Down Expand Up @@ -280,7 +281,9 @@ def test_analysis_failure_boresch(self, _restraint_search):
cutoff=0.1 * angstrom,
)

def test_non_overlapping_anchor_selections_forbidden(self, _restraint_search_protein):
def test_non_overlapping_anchor_selections_forbidden(
self, _restraint_search_protein
):
"""
Ensure that anchor atoms cannot be in the same molecule
(the protein has been selected as the ligand, so we are
Expand Down

0 comments on commit 11f3ccb

Please sign in to comment.