“cmd.set_geometry” changes PyMOL's assumptions about the proper valence and geometry of atoms in the selection.
cmd.set_geometry(string selection, int geometry, int valence)
def set_geometry(selection, geometry, valence):
set_geometry | api