def split_denovos(denovo_path, temp_dir):
    """ split de novos from an input file into files, one for each gene
    """
    
    # open the de novos, drop the header line, then sort them (which will be by
    # HGNC symbol, as the first element of each line)
    with open(denovo_path, "r") as handle:
        lines = handle.readlines()
        header = lines.pop(0)
    
    basename = os.path.basename(denovo_path)
    
    # only include genes with 2+ missense SNVs
    counts = count_missense_per_gene(lines)
    counts = dict((k, v) for k, v in counts.items() if v > 1 )
    
    genes = set([])
    for line in sorted(lines):
        gene = line.split("\t")[0]
        
        # open a new output file whenever we hit a different gene
        if gene not in genes and gene in counts:
            genes.add(gene)
            path = os.path.join(temp_dir, "tmp.{}.txt".format(len(genes)))
            output = open(path, "w")
            output.write(header)
        
        if gene in counts:
            output.write(line)
    
    return len(genes)
split de novos from an input file into files, one for each gene