def parse_fasta(data):
    """Load sequences in Fasta format.

    This generator function yields a tuple containing a defline and a sequence
    for each record in the Fasta data. Stolen shamelessly from
    http://stackoverflow.com/a/7655072/459780.
    """
    defline, sequence = None, list()
    for line in data:
        line = line.rstrip()
        if line.startswith('>'):
            if defline:
                yield defline[1:], ''.join(sequence)
            defline, sequence = line, list()
        else:
            sequence.append(line)
    yield defline[1:], ''.join(sequence)
