Skip to content
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

Added verbose info logs to NonEquilibriumCyclingProtocol SetupUnit #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions feflow/protocols/nonequilibrium_cycling.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
else:
ffcache = None

self.logger.info("Creating system generator")
system_generator = system_creation.get_system_generator(
forcefield_settings=forcefield_settings,
thermo_settings=thermodynamic_settings,
Expand Down Expand Up @@ -238,6 +239,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
common_small_mols[comp] = comp.to_openff()

# Assign partial charges to all small mols
self.logger.info("Assigning partial charges to all small molecules")
all_openff_mols = list(
chain(all_alchemical_mols.values(), common_small_mols.values())
)
Expand All @@ -248,12 +250,14 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
# Force the creation of parameters
# This is necessary because we need to have the FF templates
# registered ahead of solvating the system.
self.logger.info("Creating parameterized system")
for off_mol in all_openff_mols:
system_generator.create_system(
off_mol.to_topology().to_openmm(), molecules=[off_mol]
)

# c. get OpenMM Modeller + a dictionary of resids for each component
self.logger.info("Creating OpenMM modeller instance")
state_a_modeller, comp_resids = system_creation.get_omm_modeller(
protein_comp=receptor_comp,
solvent_comp=solvent_comp,
Expand All @@ -264,10 +268,12 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):

# d. get topology & positions
# Note: roundtrip positions to remove vec3 issues
self.logger.info("Getting topology and positions for state A")
state_a_topology = state_a_modeller.getTopology()
state_a_positions = to_openmm(from_openmm(state_a_modeller.getPositions()))

# e. create the stateA System
self.logger.info("Creating state A system")
state_a_system = system_generator.create_system(
state_a_modeller.topology,
molecules=list(
Expand All @@ -277,6 +283,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):

# 2. Get stateB system
# a. get the topology
self.logger.info("Getting topology for state B")
(
state_b_topology,
state_b_alchem_resids,
Expand All @@ -286,6 +293,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
exclude_resids=comp_resids[ligand_a],
)

self.logger.info("Creating state B system")
state_b_system = system_generator.create_system(
state_b_topology,
molecules=list(
Expand All @@ -294,6 +302,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
)

# c. Define correspondence mappings between the two systems
self.logger.info("Defining correspondence mappings between two systems")
ligand_mappings = _rfe_utils.topologyhelpers.get_system_mappings(
mapping.componentA_to_componentB,
state_a_system,
Expand All @@ -309,6 +318,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
# Handle charge corrections/transformations
# Get the change difference between the end states
# and check if the charge correction used is appropriate
self.logger.info("Getting alchemical charge differences between end states")
charge_difference = get_alchemical_charge_difference(
mapping,
forcefield_settings.nonbonded_method,
Expand All @@ -333,6 +343,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
)

# d. Finally get the positions
self.logger.info("Getting state B postiions")
state_b_positions = _rfe_utils.topologyhelpers.set_and_check_new_positions(
ligand_mappings,
state_a_topology,
Expand All @@ -349,7 +360,9 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
softcore_LJ_v2 = True
elif alchemical_settings.softcore_LJ.lower() == "beutler":
softcore_LJ_v2 = False

# Now we can create the HTF from the previous objects
self.logger.info("Creating hybrid topology factory")
hybrid_factory = HybridTopologyFactory(
state_a_system,
state_a_positions,
Expand All @@ -371,6 +384,7 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
positions = hybrid_factory.hybrid_positions

# Set up integrator
self.logger.info("Setting up OpenMM integrator")
temperature = to_openmm(thermodynamic_settings.temperature)
integrator_settings = settings.integrator_settings
integrator = PeriodicNonequilibriumIntegrator(
Expand All @@ -383,12 +397,16 @@ def _execute(self, ctx, *, protocol, state_a, state_b, mapping, **inputs):
)

# Set up context
self.logger.info("Setting up OpenMM context")
platform = get_openmm_platform(settings.engine_settings.compute_platform)
context = openmm.Context(system, integrator, platform)
context.setPeriodicBoxVectors(*system.getDefaultPeriodicBoxVectors())
context.setPositions(positions)

try:
self.logger.info(
"Serializing HybridTopologyFactory, OpenMM system, state, and integrator"
)
# SERIALIZE SYSTEM, STATE, INTEGRATOR
# need to set velocities to temperature so serialized state features velocities,
# which is important for usability by the Folding@Home openmm-core
Expand Down
Loading