OpenFreeEnergy / OpenFreeEnergy/openfe
The number of samples is not equivalent across all states
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 332
- Forks
- 56
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 13
Description
When I run the tutorial example using my protein and two small molecules, I got the following error:
openfe/lib/python3.12/site-packages/openfe/protocols/openmm_utils/multistate_analysis.py", line 322, in get_forward_and_reverse_analysis
raise ValueError(errmsg)
ValueError: The number of samples is not equivalent across all states [ 0 878 878 878 878 878 878 878 878 878 878 878 0]
It seems that lambda=0 and 1 are not sampled properly. But, I don't know why this happens.
How can I fix this?
The below script shows my setting:
rbfe_settings = RelativeHybridTopologyProtocolSettings(
protocol_repeats=3, # Number of independent repeats of the Protocol transformation
forcefield_settings=equil_rfe_settings.OpenMMSystemGeneratorFFSettings(
constraints='hbonds', # 'hbonds': Use constraints for bonds involving hydrogen
rigid_water=True, # True: Use constraints for bonds in water
hydrogen_mass=3.024, # Perform hydrogen mass repartitioning
forcefields=[ # OpenMM force fields to use for solvents and proteins
'amber/ff14SB.xml',
'amber/tip3p_standard.xml',
'amber/tip3p_HFE_multivalent.xml',
'amber/phosaa10.xml'
],
# Small molecule force field to use with OpenMM template generator:
#small_molecule_forcefield='openff-2.1.1',
small_molecule_forcefield='gaff-2.11',
# Nonbonded settings
nonbonded_method='PME', # Particle Mesh Ewald for long range electrostatics
nonbonded_cutoff=1.0 * unit.nm, # Cut off Lennard-Jones interactions beyond 1 nm
),
thermo_settings=equil_rfe_settings.ThermoSettings(
temperature=298.15 * unit.kelvin, # Set thermostat temperature
pressure=1 * unit.bar, # Set barostat pressure
ph=7.4, # None: Do not keep pH constant
redox_potential=None # None: Do not keep redox potential constant
),
solvation_settings=equil_rfe_settings.OpenMMSolvationSettings(
solvent_model='tip3p', # Solvent model to generate starting coords
solvent_padding=1.2 * unit.nm, # Total distance between periodic image starting coords
),
partial_charge_settings=equil_rfe_settings.OpenFFPartialChargeSettings(
partial_charge_method='am1bcc', # Partial charge method applied - am1bcc
off_toolkit_backend='ambertools', # Toolkit to use for partial charge assignment - ambertools
number_of_conformers=None, # None: use input conformer for partial charge assignment
nagl_model=None, # None: not using NAGL so no model needs to be chosen
),
lambda_settings=equil_rfe_settings.LambdaSettings(
lambda_functions='default', # Interpolation functions for force field parameters
lambda_windows=11, # Split the transformation over n lambda windows
),
alchemical_settings=equil_rfe_settings.AlchemicalSettings(
# False: Don't use unsampled (non-hybrid) endstates for long range correction
endstate_dispersion_correction=True,
use_dispersion_correction=True, # False: Don't use dispersion correction
softcore_LJ='gapsys', # Use LJ potential from Gapsys et al. (JCTC 2012)
softcore_alpha=0.85, # Set soft-core Lennard-Jones potential parameter α
# False: Keep all exceptions (1,4 or otherwise) at all λ
tun_off_core_unique_exceptions=False,
# Explicit charge correction settings
# False: don't apply explicit charge correction using an alchemical water
explicit_charge_correction=True,
# Cutoff distance for choosing alchemical waters
explicit_charge_correction_cutoff=0.8 * unit.nm,
),
simulation_settings=equil_rfe_settings.MultiStateSimulationSettings(
# Simulation lengths
minimization_steps=5000, # Minimize potential energy for n steps
equilibration_length=1.0 * unit.nanosecond, # Simulation time to equilibrate for
production_length=5.0 * unit.nanosecond, # Simulation time to collect data for
# Alchemical Space Sampling settings
n_replicas=11, # Number of replicas sampling alchemical space
sampler_method='repex', # Sample lambda with Hamiltonian Replica Exchange
time_per_iteration=1*unit.ps, # Time interval between state sampling (MCMC) attempts
# SAMS sampling settings (used if sampler_method='sams')
sams_flatness_criteria='logZ-flatness', # Criteria for switch to asymptomatically optimal scheme
sams_gamma0=1.0, # Initial SAMS weight adoption rate.
# Settings to control free energy analysis
# Time interval at which to perform an analysis of the free energies
real_time_analysis_interval=250*unit.picosecond,
# Minimum simulation time before energy analysis is carried out
real_time_analysis_minimum_time=500*unit.picosecond,
# Stop simulation if this target error is reached:
early_termination_target_error=0.0*unit.kilocalorie_per_mole,
),
engine_settings=equil_rfe_settings.OpenMMEngineSettings(
compute_platform='CUDA', # Let OpenMM choose the best platform for your hardware
),
integrator_settings=equil_rfe_settings.IntegratorSettings(
timestep=4 * unit.femtosecond, # Integration timestep
langevin_collision_rate=1.0 / unit.picosecond, # Langevin integrator collision rate γ
reassign_velocities=False, # False: Velocities are not lost through MCMC moves
n_restart_attempts=20, # Restart simulations the first n times they blow up
constraint_tolerance=1e-06, # Tolerance for holonomic constraints
barostat_frequency=25 * unit.timestep, # Attempt MC volume scaling every n integration steps
remove_com=False, # False: don't remove the center of mass motion
),
output_settings=equil_rfe_settings.MultiStateOutputSettings(
output_filename='simulation.nc', # Filename to save trajectory
output_structure='hybrid_system.pdb', # Filename to save starting coordinates
checkpoint_storage_filename='checkpoint.chk', # Filename for simulation checkpoints
forcefield_cache='db.json', # Cache for small molecule residue templates
output_indices='not water', # Do not save water positions
checkpoint_interval=250 * unit.ps, # Save a checkpoint every 250 picoseconds
),
)
Thanks in advance for your help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with openfe/protocols/openmm_utils/multistate_analysis.py at get_forward_and_reverse_analysis, using the reported sample-count error as the reproduction target. Inspect simulation.nc and the listed multistate simulation settings to determine why the endpoint states have zero samples; done means identifying a reproducible cause and confirming that all states contain equivalent samples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100