def ligand_residue_vs_water_hbonds(hbonds, solvent_resn, ligand):
    """
    Split hbonds into those involving residue and ligand directly and those
    mediated by water molecules.
    """
    ligand_residue_hbonds, water_hbonds = [], []
    for hbond in hbonds:
        frame_idx, atom1_label, atom2_label, itype = hbond
        if solvent_resn in atom1_label or solvent_resn in atom2_label:
            water_hbonds.append(hbond)
        else:
            ligand_residue_hbonds.append(hbond)

    return ligand_residue_hbonds, water_hbonds