docs: def readCheckSexFile(fileName, allProblemsFileName, idsFileName, femaleF,
                       maleF):
      """Reads the Plink check-sex output file.
  
      :param fileName: the name of the input file.
      :param allProblemsFileName: the name of the output file that will contain
                                  all the problems.
      :param idsFileName: the name of the output file what will contain samples
                          with sex problems.
      :param femaleF: the F threshold for females.
      :param maleF: the F threshold for males.
  
      :type fileName: str
      :type allProblemsFileName: str
      :type idsFileName: str
      :type femaleF: float
      :type maleF: float
  
      :returns: ``True`` if there are sex problems, ``False`` otherwise.
  
      Reads sex check file provided by :py:func:`runPlinkSexCheck` (Plink) and
      extract the samples that have sex problems.
  
      """
      allProblemsFile = None
      try:
          allProblemsFile = open(allProblemsFileName, 'w')
      except IOError:
          msg = "%(allProblemsFileName)s: can't write file" % locals()
          raise ProgramError(msg)
  
      idsFile = None
      try:
          idsFile = open(idsFileName, 'w')
      except IOError:
          msg = "%(idsFileName)s: can't write file" % locals()
          raise ProgramError(msg)
  
      try:
          with open(fileName, 'r') as inputFile:
              headerIndex = None
              nbProblems = 0
              nbTotalProblems = 0
              nbSexUnknown = 0
              nbFemaleThreshold = 0
              nbMaleThreshold = 0
              for line in inputFile:
                  row = createRowFromPlinkSpacedOutput(line)
  
                  if headerIndex is None:
                      # This is the header
                      headerIndex = dict([
                          (row[i], i) for i in xrange(len(row))
                      ])
                      for columnName in ["STATUS", "PEDSEX", "SNPSEX", "F",
                                         "FID", "IID"]:
                          if columnName not in headerIndex:
                              msg = "%(fileName)s: no column named " \
                                    "%(columnName)s" % locals()
                              raise ProgramError(msg)
                      print >>allProblemsFile, "\t".join(row)
                      continue
  
                  # We have data
                  status = row[headerIndex["STATUS"]]
  
                  if status == "PROBLEM":
                      # We have a sex problem
                      nbTotalProblems += 1
                      pedsex = row[headerIndex["PEDSEX"]]
  
                      if pedsex == "0":
                          # The individual was "0", so we skip
                          nbSexUnknown += 1
                          continue
  
                      snpsex = row[headerIndex["SNPSEX"]]
                      if snpsex == "0":
                          # The new sex is unknown
                          f = None
                          try:
                              f = float(row[headerIndex["F"]])
                          except ValueError:
                              msg = "F=%s: not a float" % row[headerIndex["F"]]
                              raise ProgramError(msg)
  
                          if pedsex == "2":
                              # We have a female
                              if f < femaleF:
                                  nbFemaleThreshold += 1
                                  continue
  
                          if pedsex == "1":
                              # We have a male
                              if f > maleF:
                                  nbMaleThreshold += 1
                                  continue
  
                      print >>allProblemsFile, "\t".join(row)
  
                      famID = row[headerIndex["FID"]]
                      indID = row[headerIndex["IID"]]
                      print >>idsFile, "\t".join([famID, indID])
  
                      nbProblems += 1
  
              logger.info("Sex Check Summary")
              logger.info("  - {:,d} total problems".format(nbTotalProblems))
              logger.info("  - {:,d} pedsex unknown".format(nbSexUnknown))
              logger.info("  - {:,d} female F < {}".format(nbFemaleThreshold,
                                                           femaleF))
              logger.info("  - {:,d} male F > {}".format(nbMaleThreshold, maleF))
              logger.info("  - {:,d} problems kept".format(nbProblems))
  
      except IOError:
          msg = "%(fileName)s: no such file"
  
      # Closing the output files
      idsFile.close()
      allProblemsFile.close()
  
      if nbProblems == 0:
          # There are no sex problems to investigate
          logger.info("There are no sex problem to investigate...")
          logger.info("  - Nothing else to do...")
          return False
      return True