Print the concordance.

    :param concordance: the concordance.
    :param prefix: the prefix if the output files.
    :param tped: a representation of the ``tped`` of duplicated markers.
    :param snps: the position of the duplicated markers in the ``tped``.

    :type concordance: dict
    :type prefix: str
    :type tped: numpy.array
    :type snps: dict

    Prints the concordance in a file, in the format of a matrix. For each
    duplicated markers, the first line (starting with the `#` signs) contains
    the name of all the markers in the duplicated markers set. Then a :math:`N
    \\times N` matrix is printed to file (where :math:`N` is the number of
    markers in the duplicated marker list), containing the pairwise
    concordance.

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

    :param concordance: the concordance.
    :param prefix: the prefix if the output files.
    :param tped: a representation of the ``tped`` of duplicated markers.
    :param snps: the position of the duplicated markers in the ``tped``.

    :type concordance: dict
    :type prefix: str
    :type tped: numpy.array
    :type snps: dict

    Prints the concordance in a file, in the format of a matrix. For each
    duplicated markers, the first line (starting with the `#` signs) contains
    the name of all the markers in the duplicated markers set. Then a :math:`N
    \\times N` matrix is printed to file (where :math:`N` is the number of
    markers in the duplicated marker list), containing the pairwise
    concordance.

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

    for snpID in concordance.iterkeys():
        print >>outFile, "#" + "\t".join(
            list(snpID) + list(tped[snps[snpID], 1])
        )

        # Doing the division
        true_concordance = np.true_divide(concordance[snpID][0],
                                          concordance[snpID][1])

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

    outFile.close()