def computeHeteroPercentage(fileName):
    """Computes the heterozygosity percentage.

    :param fileName: the name of the input file.

    :type fileName: str

    Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
    :py:func:`createPedChr23UsingPlink`) and computes the heterozygosity
    percentage on the chromosome ``23``.

    """
    outputFile = None
    try:
        outputFile = open(fileName + ".hetero", "w")
    except IOError:
        msg = "%s: can't write file" % fileName + ".hetero"
        raise ProgramError(msg)
    print >>outputFile, "\t".join(["PED", "ID", "SEX", "HETERO"])

    try:
        toPrint = []
        with open(fileName, "r") as inputFile:
            for i, line in enumerate(inputFile):
                row = line.rstrip("\r\n").split(" ")
                if i != 0:
                    # This is data
                    genotypes = np.array(row[6:])
                    genotypes = genotypes[np.where(genotypes != "NA")]

                    nbMarker = len(genotypes)
                    nbHetero = len(np.where(genotypes == "1")[0])
                    percentHetero = -9999
                    if nbMarker != 0:
                        percentHetero = nbHetero / float(nbMarker)

                    toPrint.append((row[0], row[1], row[4], percentHetero))

        # Sorting the data
        toPrint.sort(reverse=True, key=lambda values: values[3])

        # Printing the data
        for row in toPrint:
            value = list(row)
            if value[3] == -9999:
                value[3] = "ALL_NA"
            else:
                value[3] = str(value[3])
            print >>outputFile, "\t".join(value)

    except IOError:
        msg = "%(fileName)s: no such file" % locals()
        raise ProgramError(msg)

    # Closing the output file
    outputFile.close()
Computes the heterozygosity percentage.

    :param fileName: the name of the input file.

    :type fileName: str

    Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
    :py:func:`createPedChr23UsingPlink`) and computes the heterozygosity
    percentage on the chromosome ``23``.