choderalab / perses

Experiments with expanded ensembles to explore chemical space
http://perses.readthedocs.io
MIT License
179 stars 50 forks source link

Fix potential bug in counterion implementation: get_water_indices() #1225

Open zhang-ivy opened 11 months ago

zhang-ivy commented 11 months ago

Iván and I caught a potential bug in the counterion implementation, specifically in get_water_indices(), which selects the water(s) to alchemically transform into counterion(s).

The function selects waters at least a certain distance from the solute atoms, and the solute atoms are defined as atoms in the topology that are not in mdtraj's _SOLVENT_TYPES: https://github.com/choderalab/perses/blob/main/perses/utils/charge_changing.py#L88-L89

However, _SOLVENT_TYPES does not include all possible water residue names. It includes HOH, but does not include WAT, or other water residue names, so we should change this line https://github.com/choderalab/perses/blob/main/perses/utils/charge_changing.py#L88 to solvent_types = list(_SOLVENT_TYPES) + list(_WATER_RESIDUES). _WATER_RESIDUES can be imported from mdtraj and is present here: https://github.com/mdtraj/mdtraj/blob/master/mdtraj/core/residue_names.py#L45