import hashlib


def process_fasta(fasta):
    """Accept fasta or plain sequence and return fasta, sequence hash, and sequence"""
    lines = fasta.splitlines()
    lines = [line for line in lines if line != '']
    if lines[0][0] == '>':
        lines = lines[1:]
    if any([line[0] == '>' for line in lines]):
        raise ValueError("Submit only one sequence at a time.")
    # name = lines[0][1:].split()[0] # Use for something?
    seq = ''.join(lines)
    sha1 = hashlib.sha1(seq.encode()).hexdigest()[:20]
    lines.insert(0, '>' + sha1)
    fasta = '\n'.join(lines) + '\n'
    return fasta, sha1, seq