# Path: dark/cigar.py
# (CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR,
#  CHARD_CLIP_STR) = 'IDM=XH'
# def dna2cigar(s1, s2, concise=False):
# def makeCigar(reference, query, noEdgeInsertions=True):
# def cigarTuplesToOperations(tuples, includeHardClip=True):
# def softClippedOffset(offset, pairs, cigarOperations):
# def insertionOffset(offset, pairs, cigarOperations):


from dark.cigar import CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR
        of the more specific 'X' and '='.
    @param aa: If C{True}, C{btopString} will be interpreted as though it
        refers to amino acids (as in the BTOP string produced by DIAMOND).
        In that case, it is not possible to use the 'precise' CIGAR characters
        because amino acids have multiple codons so we cannot know whether
        an amino acid match is due to an exact nucleotide matches or not.
        Also, the numbers in the BTOP string will be multiplied by 3 since
        they refer to a number of amino acids matching.
    @raise ValueError: If L{parseBtop} finds an error in C{btopString} or
        if C{aa} and C{concise} are both C{True}.
    @return: A generator that yields C{str} pieces of a CIGAR string. Use
        ''.join(btopString(...)) to get a complete CIGAR string.
    """
    if aa and concise:
        raise ValueError('aa and concise cannot both be True')

    thisLength = thisOperation = currentLength = currentOperation = None

    for item in parseBtop(btopString):
        if isinstance(item, int):
            thisLength = item
            thisOperation = CEQUAL_STR if concise else CMATCH_STR
        else:
            thisLength = 1
            query, reference = item
            if query == '-':
                # The query has a gap. That means that in matching the
                # query to the reference a deletion is needed in the
                # reference.
                assert reference != '-'

# Path: dark/cigar.py
# (CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR,
#  CHARD_CLIP_STR) = 'IDM=XH'
# def dna2cigar(s1, s2, concise=False):
# def makeCigar(reference, query, noEdgeInsertions=True):
# def cigarTuplesToOperations(tuples, includeHardClip=True):
# def softClippedOffset(offset, pairs, cigarOperations):
# def insertionOffset(offset, pairs, cigarOperations):


# Path: dark/btop.py
from dark.cigar import CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR

        of the more specific 'X' and '='.
    @param aa: If C{True}, C{btopString} will be interpreted as though it
        refers to amino acids (as in the BTOP string produced by DIAMOND).
        In that case, it is not possible to use the 'precise' CIGAR characters
        because amino acids have multiple codons so we cannot know whether
        an amino acid match is due to an exact nucleotide matches or not.
        Also, the numbers in the BTOP string will be multiplied by 3 since
        they refer to a number of amino acids matching.
    @raise ValueError: If L{parseBtop} finds an error in C{btopString} or
        if C{aa} and C{concise} are both C{True}.
    @return: A generator that yields C{str} pieces of a CIGAR string. Use
        ''.join(btopString(...)) to get a complete CIGAR string.
    """
    if aa and concise:
        raise ValueError('aa and concise cannot both be True')

    thisLength = thisOperation = currentLength = currentOperation = None

    for item in parseBtop(btopString):
        if isinstance(item, int):
            thisLength = item
            thisOperation = CEQUAL_STR if concise else CMATCH_STR
        else:
            thisLength = 1
            query, reference = item
            if query == '-':
                # The query has a gap. That means that in matching the
                # query to the reference a deletion is needed in the
                # reference.
                assert reference != '-'

                thisOperation = CDEL_STR