Print the concordance.

    :param concordance: the concordance of each sample.
    :param prefix: the prefix of all the files.

    :type concordance: dict
    :type prefix: str

    :returns: the concordance percentage (dict)

    The concordance is the number of genotypes that are equal when comparing a
    duplicated samples with another one, divided by the total number of
    genotypes (excluding genotypes that are no call [*i.e.* ``0``]). If a
    duplicated sample has 100% of no calls, the concordance will be zero.

    The file ``prefix.concordance`` will contain :math:`N \\times N` matrices
    for each set of duplicated samples.

def printConcordance(concordance, prefix):
    """Print the concordance.

    :param concordance: the concordance of each sample.
    :param prefix: the prefix of all the files.

    :type concordance: dict
    :type prefix: str

    :returns: the concordance percentage (dict)

    The concordance is the number of genotypes that are equal when comparing a
    duplicated samples with another one, divided by the total number of
    genotypes (excluding genotypes that are no call [*i.e.* ``0``]). If a
    duplicated sample has 100% of no calls, the concordance will be zero.

    The file ``prefix.concordance`` will contain :math:`N \\times N` matrices
    for each set of duplicated samples.

    """
    outFile = None
    try:
        outFile = open(prefix + ".concordance", "w")
    except IOError:
        msg = "%s: can't write file" % prefix + ".concordance"
        raise ProgramError(msg)

    concordance_percentage = {}
    for key in concordance.iterkeys():
        print >>outFile, "#%s\t%s" % key

        # Doing the division
        none_zero = concordance[key][1] != 0
        true_concordance = np.zeros(np.multiply(*concordance[key][1].shape))
        true_concordance[np.ravel(none_zero)] = np.true_divide(
            concordance[key][0][none_zero],
            concordance[key][1][none_zero],
        )
        true_concordance.shape = concordance[key][1].shape
        true_concordance = np.asmatrix(true_concordance)
        concordance_percentage[key] = true_concordance

        output = StringIO.StringIO()
        np.savetxt(output, true_concordance, delimiter="\t", fmt="%.8f")
        print >>outFile, output.getvalue().rstrip("\r\n")

    outFile.close()

    return concordance_percentage