selection.by_residue() — make sure all residues are fully selected

by_residue()
This returns a new selection, in which any residues in the existing selection that have at least one selected atom are now entirely selected (all atoms in each residue are selected). The original selection is unchanged. This is equivalent to calling selection.extend_by_residue() with an extension of zero.
Example: See selection() command.