# Path: dark/utils.py
# def countPrint(mesg, count, len1, len2=None):
#     """
#     Format a message followed by an integer count and a percentage (or
#     two, if the sequence lengths are unequal).
# 
#     @param mesg: a C{str} message.
#     @param count: a numeric value.
#     @param len1: the C{int} length of sequence 1.
#     @param len2: the C{int} length of sequence 2. If C{None}, will
#         default to C{len1}.
#     @return: A C{str} for printing.
#     """
#     def percentage(a, b):
#         """
#         What percent of a is b?
# 
#         @param a: a numeric value.
#         @param b: a numeric value.
#         @return: the C{float} percentage.
#         """
#         return 100.0 * a / b if b else 0.0
# 
#     if count == 0:
#         return '%s: %d' % (mesg, count)
#     else:
#         len2 = len2 or len1
#         if len1 == len2:
#             return '%s: %d/%d (%.2f%%)' % (
#                 mesg, count, len1, percentage(count, len1))
#         else:
#             return ('%s: %d/%d (%.2f%%) of sequence 1, '
#                     '%d/%d (%.2f%%) of sequence 2' % (
#                         mesg,
#                         count, len1, percentage(count, len1),
#                         count, len2, percentage(count, len2)))


from collections import defaultdict
from operator import itemgetter
from dark.utils import countPrint
    from itertools import zip_longest
    from itertools import izip_longest as zip_longest
    from dark.reads import DNAKozakRead
        the match was done strictly, insisting that only non-ambiguous
        nucleotides could contribute to the matching nucleotide count.
    @param indent: A C{str} to indent all returned lines with.
    @param offsets: If not C{None}, a C{set} of offsets of interest that were
        only considered when making C{match}.
    @param includeGapLocations: If C{True} indicate the (1-based) locations of
        gaps.
    @return: A C{str} describing the match.
    """
    match = dnaMatch['match']
    identicalMatchCount = match['identicalMatchCount']
    ambiguousMatchCount = match['ambiguousMatchCount']
    gapMismatchCount = match['gapMismatchCount']
    gapGapMismatchCount = match['gapGapMismatchCount']
    nonGapMismatchCount = match['nonGapMismatchCount']

    if offsets:
        len1 = len2 = len(offsets)
    else:
        len1, len2 = map(len, (read1, read2))

    result = []
    append = result.append

    append(countPrint('%sExact matches' % indent, identicalMatchCount,
                      len1, len2))
    append(countPrint('%sAmbiguous matches' % indent, ambiguousMatchCount,
                      len1, len2))
    if ambiguousMatchCount and identicalMatchCount:
        anyMatchCount = identicalMatchCount + ambiguousMatchCount

# Path: dark/utils.py
# def countPrint(mesg, count, len1, len2=None):
#     """
#     Format a message followed by an integer count and a percentage (or
#     two, if the sequence lengths are unequal).
# 
#     @param mesg: a C{str} message.
#     @param count: a numeric value.
#     @param len1: the C{int} length of sequence 1.
#     @param len2: the C{int} length of sequence 2. If C{None}, will
#         default to C{len1}.
#     @return: A C{str} for printing.
#     """
#     def percentage(a, b):
#         """
#         What percent of a is b?
# 
#         @param a: a numeric value.
#         @param b: a numeric value.
#         @return: the C{float} percentage.
#         """
#         return 100.0 * a / b if b else 0.0
# 
#     if count == 0:
#         return '%s: %d' % (mesg, count)
#     else:
#         len2 = len2 or len1
#         if len1 == len2:
#             return '%s: %d/%d (%.2f%%)' % (
#                 mesg, count, len1, percentage(count, len1))
#         else:
#             return ('%s: %d/%d (%.2f%%) of sequence 1, '
#                     '%d/%d (%.2f%%) of sequence 2' % (
#                         mesg,
#                         count, len1, percentage(count, len1),
#                         count, len2, percentage(count, len2)))


# Path: dark/dna.py
from collections import defaultdict
from operator import itemgetter
from dark.utils import countPrint
    from itertools import zip_longest
    from itertools import izip_longest as zip_longest
    from dark.reads import DNAKozakRead

        the match was done strictly, insisting that only non-ambiguous
        nucleotides could contribute to the matching nucleotide count.
    @param indent: A C{str} to indent all returned lines with.
    @param offsets: If not C{None}, a C{set} of offsets of interest that were
        only considered when making C{match}.
    @param includeGapLocations: If C{True} indicate the (1-based) locations of
        gaps.
    @return: A C{str} describing the match.
    """
    match = dnaMatch['match']
    identicalMatchCount = match['identicalMatchCount']
    ambiguousMatchCount = match['ambiguousMatchCount']
    gapMismatchCount = match['gapMismatchCount']
    gapGapMismatchCount = match['gapGapMismatchCount']
    nonGapMismatchCount = match['nonGapMismatchCount']

    if offsets:
        len1 = len2 = len(offsets)
    else:
        len1, len2 = map(len, (read1, read2))

    result = []
    append = result.append

    append(countPrint('%sExact matches' % indent, identicalMatchCount,
                      len1, len2))
    append(countPrint('%sAmbiguous matches' % indent, ambiguousMatchCount,
                      len1, len2))
    if ambiguousMatchCount and identicalMatchCount:
        anyMatchCount = identicalMatchCount + ambiguousMatchCount

        append(countPrint('%sExact or ambiguous matches' % indent,