def get_groups_per_chain(chains, ligands, waters):
    """Takes lists of chains, ligands and waters, and returns the chain counts
    that should go in the .mmtf file.

    :param list chains: the chains to pack.
    :param list ligands: the ligands to pack.
    :param list waters: the waters to pack.
    :rtype: ``list``"""

    groups_per_chain = []
    for chain in chains:
        groups_per_chain.append(len(chain.residues()))
    for ligand in ligands:
        groups_per_chain.append(1)
    water_chains = sorted(set(w._internal_id for w in waters))
    for wc in water_chains:
        groups_per_chain.append(len([w for w in waters if w._internal_id == wc]))
    return groups_per_chain