import re


def get_better_loci(filename, cutoff):
    """
    Returns a subset of loci such that each locus includes at least "cutoff"
    different species.
    :param filename:
    :param cutoff:
    :return:
    """
    f = open(filename)
    
    content = f.read()
    f.close()
    loci = re.split(r'//.*|', content)
    
    better_loci = []
    for locus in loci:
        
        found_species = set()
        
        for line in locus.strip().split("\n"):
            
            if line == "":
                continue
           
            (individual, sequence) = line[1:].split()
            found_species.add(individual.split("_")[-1])
        
        if len(found_species) >= cutoff:
            better_loci.append(locus)
    
    return better_loci