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
Does CustomRMSDForce prevent atoms within the specified atom group from being periodically imaged? #2913
Comments
For example, I have a simple from simtk import unit, openmm
kB = unit.AVOGADRO_CONSTANT_NA * unit.BOLTZMANN_CONSTANT_kB
temperature = 300 * unit.kelvin
kT = kB * temperature
sigma = 1.0 * unit.angstrom
buffer = 2.0 * unit.angstrom
custom_cv_force = openmm.CustomCVForce('step(RMSD-buffer)*(K_RMSD/2)*(RMSD-buffer)^2')
custom_cv_force.addGlobalParameter('K_RMSD', kT / sigma**2)
custom_cv_force.addGlobalParameter('buffer', buffer)
rmsd_force = openmm.RMSDForce(self.hybrid_positions, rmsd_atom_indices)
custom_cv_force.addCollectiveVariable('RMSD', rmsd_force)
system.addForce(custom_cv_force) My guess is that the barostat is imaging the ligand into different boxes from the protein, since I see this if I report the CV value:
Would adding a zero-energy |
It appears that this is the case: Adding a zero-energy
|
@peastman: Perhaps we should modify the default behavior to group any RMSD restrained atoms into the same "molecule", since the RMSD and alignment will be meaningless otherwise? |
I think that would be a reasonable change. |
Since the barostat no longer translates molecules into different periodic boxes (see #3260), is this still an issue? |
Actually, I don't understand this issue. The RMSD calculation begins by finding an optimal translation and rotation to align the two groups of atoms. Moving one of them into a different periodic box shouldn't make any difference. Are you sure the problem isn't something different? |
@jchodera was this ever resolved? See my comments above from October. |
I have verified this problem still exists in OpenMM 7.7. Here is a test that computes the RMSD for a ligand bound to a protein dimer, showing that the RMSD remains low only if I add a virtual bond (a Here is the output of this test:
I don't understand why this is happening. As I understand it, OpenMM does not image or wrap the molecular coordinates unless requested when Instead, somehow, these molecules are being imaged differently before the RMSD is computed. This is not correct behavior. If it is unavoidable, the RMSD computation should find the imaging scheme that leads to minimal RMSD and use/report that. Otherwise, if an arbitrary box imaging displacement causes the RMSD to increase, it is by definition not the RMSD corresponding to the minimum value over translations and rotations. |
I see what you're doing now. You have multiple separate molecules, but you want to compute a single RMSD for all of them against a single set of reference coordinates. If you have periodic boundary conditions, it isn't clear to me how to define the RMSD in that situation. Each atom represents an infinite grid of atoms repeating through space. The "position" stored for each atom is an arbitrarily chosen one of those infinite periodic copies. I guess for each molecule, we could start by finding a different lattice translation to minimize the distance to the reference conformation for that particular molecule? Your workaround of adding a virtual bond guarantees you'll always get one particular periodic copy, but who is to say that's the "right" one? As the molecules move around, a different periodic copy might come to give a smaller RMSD. Also, imagine if someone asked for the RMSD of their entire system, including water, to a reference. If that forced us to treat the whole system as a single molecule, the simulation would slow to a crawl since we couldn't reorder the waters. |
I've been trying to come up with a definition that makes sense for multiple molecules with periodic boundary conditions. Does the following make sense? For a single molecule, it doesn't matter which periodic copy you choose. The translation built into the RMSD calculation will lead to the same result regardless. For the same reason, when you have multiple molecules, it doesn't matter which periodic copy you pick for the first one. That just sets an overall translation. But it does matter which copies you pick for all molecules after the first one. Let's define the correct result to be the minimum RMSD over all possible combinations of all possible periodic copies of the remaining molecules. Let's put aside the question of how to calculate it for the moment. Does that seem like an appropriate definition of what we want to calculate? |
I don't think there's anything ill-defined about this particular problem: By definition, the least-squares RMSD is intended to produce the minimum RMSD for any translation and rotation of the two systems. If translation of the collection of three associated objects by some amount will reduce the RMSD, the minimum over all those translations and rotations should be the appropriate least-squared RMSD.
This is only relevant if the collection of three objects dissociates, in which case the least-squares RMSD would be detectably large anyway. In this case, a restraint force is imposed to prevent this, but if any molecules in the collection are re-imaged, this fails. That's why I had to impose virtual bonds.
That's a different problem: That would be the least-squares RMSD over all possible molecular permutations, translations, and rotations. While there are some algorithms for dealing with this case efficiently, here, we're just considering all possible translations and rotations of the collection of atoms.
What I'm not quite understanding is why the molecules are being imaged into different boxes in the first place. How and when is this happening? I didn't think this should be happening at all unless we retrieve the state and ask for re-imaging. RMSD shouldn't be imaging either---it should just use the positions, or at least provide the user with the option to not attempt any (especially erroneous) imaging. That would be a simple solution: If no imaging is done during the simulation, simply not imaging when RMSD is computed should provide the correct result in this particular case. (Other cases where no restraint is applied and the ligand might unbind and rebind after passing through a unit cell length would not behave correctly, however.)
The least-squares RMSD feature should provide the smallest RMSD over all possible translations and rotations of the collections of atoms. If some of those translations would cause re-imaging of the collection of molecules in a way to reduce the RMSD, the minimum over all those translations is the correct least-squares RMSD. |
The code that does it is in |
The simple solution in this case (when the RMSD is intended to be applied
to the non-translated system) is to have an option to not image the
molecules in the RMSD computation. Practically, for numerical stability,
this could
* Compute the mean transformation vector stored for each atom
* Apply the stored transformation vector for each atom minus this mean
vector
That would result in all atoms being restored to their original positions,
but with the mean translation vector subtracted to avoid precision issues.
For the more general case, something more sophisticated would be needed,
but given that applying am RMSD restraint is a major use case, this is
probably sufficient to recover the correct behavior.
|
When a
CustomRMSDForce
is defined for a set of atoms, is this atom set prevented from being placed in different periodic images byMonteCarloBarostat
?The text was updated successfully, but these errors were encountered: