Skip to content

Commit

Permalink
Merge pull request #97 from florianjoerg/clear_14ww
Browse files Browse the repository at this point in the history
removed unused 14 exclusion lists
  • Loading branch information
florianjoerg authored May 24, 2023
2 parents 408fb9d + 8319ed9 commit 66b26c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 62 deletions.
6 changes: 0 additions & 6 deletions protex/residue.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class Residue:
The parameters for the residue
alternativ_parameters: dict[list]
The parameters for the alternativ (protonated/deprotonated) state
pair_12_13_exclusion_list: list
1-2 and 1-3 exclusions in the system
force_idxs:
has_equivalent_atoms: tuple[bool,bool]
if original name and alternative name have equivalent atoms
Expand All @@ -44,8 +42,6 @@ class Residue:
Records the charge state of that residue
system: openmm.openmm.System
The system generated with openMM, where all residues are in
pair_12_13_list: list
1-2 and 1-3 exclusions in the system
equivalent_atoms: dict[str, bool]
if orignal_name and alternative name have equivalent atoms
force_idxs:
Expand All @@ -58,7 +54,6 @@ def __init__(
system,
inital_parameters,
alternativ_parameters,
# pair_12_13_exclusion_list,
has_equivalent_atoms,
force_idxs=dict(),
) -> None:
Expand All @@ -74,7 +69,6 @@ def __init__(
}
self.record_charge_state = []
self.record_charge_state.append(self.endstate_charge) # Not used anywhere?
# self.pair_12_13_list = pair_12_13_exclusion_list
if has_equivalent_atoms is not None:
self.equivalent_atoms: dict[str, bool] = {
self.original_name: has_equivalent_atoms[0],
Expand Down
58 changes: 2 additions & 56 deletions protex/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,6 @@ def __init__(
self.simulation: openmm.app.simulation.Simulation = simulation
self.templates: ProtexTemplates = templates
self.simulation_for_parameters = simulation_for_parameters
# self.pair_12_13_list = self._build_exclusion_list(self.topology)
# self.pair_12_13_list_params = (
# self._build_exclusion_list(self.simulation_for_parameters.topology)
# if self.simulation_for_parameters is not None
# else self.pair_12_13_list
# )
self.fast: bool = fast
self.residues: list[Residue] = self._set_initial_states()
self.boxlength: openmm.Quantity = (
Expand Down Expand Up @@ -402,35 +396,6 @@ def update_context(self, name: str):
if type(force).__name__ == name:
force.updateParametersInContext(self.simulation.context)

# deprecated, not needed anymore
# def _build_exclusion_list(self, topology):
# pair_12_set = set()
# pair_13_set = set()
# for bond in topology.bonds():
# a1, a2 = bond.atom1, bond.atom2
# if "H" not in a1.name and "H" not in a2.name:
# pair = (
# min(a1.index, a2.index),
# max(a1.index, a2.index),
# )
# pair_12_set.add(pair)
# for a in pair_12_set:
# for b in pair_12_set:
# shared = set(a).intersection(set(b))
# if len(shared) == 1:
# pair = tuple(sorted(set(list(a) + list(b)) - shared))
# pair_13_set.add(pair)
# # there were duplicates in pair_13_set, e.g. (1,3) and (3,1), needs to be sorted

# # self.pair_12_list = list(sorted(pair_12_set))
# # self.pair_13_list = list(sorted(pair_13_set - pair_12_set))
# # self.pair_12_13_list = self.pair_12_list + self.pair_13_list
# # change to return the list and set the parameters in the init method?
# pair_12_list = list(sorted(pair_12_set))
# pair_13_list = list(sorted(pair_13_set - pair_12_set))
# pair_12_13_list = pair_12_list + pair_13_list
# return pair_12_13_list

def _extract_templates(self, query_name: str) -> defaultdict:
# returns the forces for the residue name
forces_dict = defaultdict(list)
Expand All @@ -442,8 +407,6 @@ def _extract_templates(self, query_name: str) -> defaultdict:
else:
sim = self.simulation

# pair_12_13_list_params = self._build_exclusion_list(sim.topology)

for residue in sim.topology.residues():
if query_name == residue.name:
atom_idxs = [atom.index for atom in residue.atoms()]
Expand Down Expand Up @@ -524,27 +487,15 @@ def _extract_templates(self, query_name: str) -> defaultdict:
forces_dict[type(force).__name__].append(f)
# store the drude idx as they are in the system
particle_map[drude_id] = idx1
# print(self.pair_12_13_list)
# assert ( #? not working with tfa, investigate
# len(pair_12_13_list_params) == force.getNumScreenedPairs()
# ), f"{len(pair_12_13_list_params)=}, {force.getNumScreenedPairs()=}"
for drude_id in range(force.getNumScreenedPairs()):
f = force.getScreenedPairParameters(drude_id)
idx1 = f[
0
] # yields the id within this force == drude_id from getNumParticles
# yields the id within this force == drude_id from getNumParticles
idx1 = f[0]
idx2 = f[1]
thole = f[2]
# get the drude idxs in the system
drude1 = particle_map[idx1]
drude2 = particle_map[idx2]
# parent1, parent2 = pair_12_13_list_params[drude_id]
# drude1, drude2 = parent1 + 1, parent2 + 1
# print(f"thole {idx1=}, {idx2=}")
# print(f"{drude_id=}, {f=}")
if drude1 in atom_idxs and drude2 in atom_idxs:
# print(f"Thole {query_name=}")
# print(f"{drude1=}, {drude2=}")
forces_dict[type(force).__name__ + "Thole"].append(f)
break # do this only for the relevant residue once
else:
Expand Down Expand Up @@ -706,9 +657,6 @@ def _set_initial_states(self) -> list:
For each ionic liquid residue in the system the protonation state
is interfered from the provided openMM system object and the protonation site is defined.
"""
# self._build_exclusion_list()
# pair_12_13_list = self._build_exclusion_list(self.topology)

residues = []
self.residue_templates = dict()
# this will become a dict of the form:
Expand Down Expand Up @@ -750,7 +698,6 @@ def _set_initial_states(self) -> list:
self.system,
parameters_state1,
parameters_state2,
# pair_12_13_list,
(
self.templates.has_equivalent_atom(name),
self.templates.has_equivalent_atom(name_of_paired_ion),
Expand All @@ -764,7 +711,6 @@ def _set_initial_states(self) -> list:
self.system,
parameters_state1,
parameters_state2,
# pair_12_13_list,
(
self.templates.has_equivalent_atom(name),
self.templates.has_equivalent_atom(name_of_paired_ion),
Expand Down

0 comments on commit 66b26c1

Please sign in to comment.