def correct_gag_residue_names_messed_up_by_moe(molstruct):
    """Rename messed up GAG residue names from MOE files.

    1. Undo capitalization (e.g. `02U` --> `02u`).
    2. Remove leading `Q` (e.g. `Q42u` --> `42u`).

    """
    REP_TABLE = {'02U': '02u', '03U': '03u', '07U': '07u', '0UA': '0uA',
        '42U': '42u', '47U': '47u', '4UA': '4uA'}
    for residue in molstruct.residues():
        if residue.name is not None and residue.name[0] == 'Q':
            residue.name = residue.name[1:]
        if residue.name is not None and residue.name in REP_TABLE:
            residue.name = REP_TABLE[residue.name]
    return True
