import math


def get_subsets(sampledsubsetdict, nodelist, iteration_num):
    """
    Takes a dictionary of counts and returns subsets per protein 
    in a list, with the constraint that subsets contain proteins 
    visited at least t times.

    Parameters
    ----------
    sampledsubsetdict: dict
        dict of nodes visited and visitation counts per node
    nodelist: list
    iteration_num: int

    Returns
    -------
    masterlist: list
        subsets per protein
    """
    t=math.ceil(iteration_num/2)
    masterlist = []
    refdict = {}
    count = 0
    for prot in nodelist:
        refdict[prot] = count
        count += 1

    for prot in nodelist:
        listofsets = []
        listoftups = sampledsubsetdict[prot]
        for pair in listoftups:
            if pair[1] >= t:
                listofsets.append(refdict[pair[0]])
        masterlist.append(set(listofsets))

    return masterlist