make copy of sequences with short identifier

def get_ids(a):
    """
    make copy of sequences with short identifier
    """
    a_id = '%s.id.fa' % (a.rsplit('.', 1)[0])
    a_id_lookup = '%s.id.lookup' % (a.rsplit('.', 1)[0])
    if check(a_id) is True:
        return a_id, a_id_lookup
    a_id_f = open(a_id, 'w')
    a_id_lookup_f = open(a_id_lookup, 'w')
    ids = []
    for seq in parse_fasta(open(a)):
        id = id_generator() 
        while id in ids:
            id = id_generator() 
        ids.append(id)
        header = seq[0].split('>')[1]
        name = remove_bad(header)
        seq[0] = '>%s %s' % (id, header)
        print('\n'.join(seq), file=a_id_f)
        print('%s\t%s\t%s' % (id, name, header), file=a_id_lookup_f)
    return a_id, a_id_lookup