Hi Enrico, One normally wouldn't use this approach at all. Instead, in whatever MD package you're using you post-process the trajectory so that molecules cross the periodic boundary as a unit rather than atom by atom (typically referred to as "re-imaging" the trajectory). For instance, the AMBER package provides a CPPTRAJ program with autoimage and image <https://amberhub.chpc.utah.edu/image/> commands for doing this. Gromacs has similar capabilities. I believe most major MD packages do. If for some reason you don't want to do this, you can use this ChimeraX Recipe <https://rbvi.github.io/chimerax-recipes/box_crossers/box_crossers.html> to select residues that cross the periodic boundary at any point and hide them. You could use Python to loop through the water residues and hide or show them based on their bond lengths. It would be faster than the commands you're using, but it's still computation at every step that may or may not be fast enough. Off the top of my head (i.e. untested), the code would be: from chimerax.atomic import all_atomic_structures for s in all_atomic_structures(session): for r in s.residues: if r.name != "HOH": continue for a in r.atoms: for b in a.bonds: if b.length > 5: r.atoms.displays = False break else: continue break else: r.atoms.displays = True --Eric Eric Pettersen UCSF Computer Graphics Lab
On Jan 21, 2026, at 1:34 PM, Enrico Martinez via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Dear ChimeraX users!
I am working on the visualization of an MD trajectory where some water molecules are broken due to PBC artifacts, causing oxygen and hydrogen atoms to be separated over large distances. To address this, I currently use the following workflow:
Remove all bonds in water molecules near the ligand.
Rebuild only reasonable bonds, avoiding artifactually long bonds.
Remove water atoms that have no bonds per frame:
perframe "~bond :HOH & :LIG :<5.0; bond :HOH & :LIG :<5.0 reasonable true; hide :HOH & @@num_bonds=0 target a" interval 1
This works well to fix visualization artifacts, but the workflow is computationally heavy, as it rebuilds bonds in every frame. Is there a way to achieve the same in a single step by simply removing waters with stretched bonds?
Many thanks in advance!
Enrico
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/