Finds SNPs with MAF of 0 and put them in a file.

    :param freqFileName: the name of the frequency file.
    :param prefix: the prefix of all the files.

    :type freqFileName: str
    :type prefix: str

    Reads a frequency file from Plink, and find markers with a minor allele
    frequency of zero.

def findSnpWithMaf0(freqFileName, prefix):
    """Finds SNPs with MAF of 0 and put them in a file.

    :param freqFileName: the name of the frequency file.
    :param prefix: the prefix of all the files.

    :type freqFileName: str
    :type prefix: str

    Reads a frequency file from Plink, and find markers with a minor allele
    frequency of zero.

    """
    maf_0_set = set()
    na_set = set()

    try:
        with open(freqFileName, "r") as inputFile:
            headerIndex = None
            for i, line in enumerate(inputFile):
                row = createRowFromPlinkSpacedOutput(line)
                if i == 0:
                    # We have the header
                    headerIndex = dict([
                        (row[i], i) for i in xrange(len(row))
                    ])
                    for columnName in ["SNP", "MAF"]:
                        if columnName not in headerIndex:
                            msg = "%(freqFileName)s: no column named " \
                                  "%(columnName)s" % locals()
                            raise ProgramError(msg)

                else:
                    # We have data
                    snpName = row[headerIndex["SNP"]]
                    snpMAF = row[headerIndex["MAF"]]

                    if snpMAF == "0":
                        # We want to flag this SNP
                        maf_0_set.add(snpName)

                    elif snpMAF == "NA":
                        # We want to flag this SNP, because the MAF est NA
                        na_set.add(snpName)

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

    # Creating the output files
    if len(maf_0_set) == 0:
        logger.info("  - There are no markers with MAF 0")
    else:
        logger.info("  - There are {} markers with MAF 0".format(
            len(maf_0_set),
        ))
    outputFile = None
    try:
        with open(prefix + ".list", "w") as output_file:
            for marker_name in maf_0_set:
                print >>output_file, marker_name
    except IOError:
        msg = "{}.list: can't write file".format(prefix)
        raise ProgramError(msg)

    if len(na_set) > 0:
        logger.info("  - There are {} markers with NA MAF".format(len(na_set)))
        try:
            with open(prefix + ".na_list", "w") as output_file:
                for marker_name in na_set:
                    print >>output_file, marker_name
        except IOError:
            msg = "{}.na_list: can't write file".format(prefix)
            raise ProgramError(msg)