def compare(sequenceA, sequenceB, gaps = False):
    """Compares two sequences and returns the identity. If gaps is set to True then count a shared gap as identical.

    Args:
        sequenceA (str): The first sequence.
        sequenceA (str): The second sequence.
        gaps (bool): Should gaps count as identical? (Default: False)

    Returns:
        float: identity.

    """


    assert(len(sequenceA) == len(sequenceA)), "Sequence lengths do not match"

    length = len(sequenceA)

    # Initiate counters
    identical  = 0
    gap_length = 0

    # Look at each position in turn
    for base in range(0, length):

        # Deal with gaps (gap in ref and seq to compare)
        if((sequenceA[base] == "-" and sequenceB[base] == "-") and gaps == False) :
              gap_length += 1
              continue

        # Is the base/residue the same?
        if ( sequenceA[base] == sequenceB[base]):

            # Increase the counter
            identical += 1

    # Avoid a divide by zero error
    if (gap_length == length): length += 1

    # Convert the count to a percentage
    identity = identical / (length - gap_length) * 100
    return identity