Runs step 3 (clean no call and hetero).

    :param in_prefix: the prefix of the input files.
    :param in_type: the type of the input files.
    :param out_prefix: the output prefix.
    :param base_dir: the output directory.
    :param options: the options needed.

    :type in_prefix: str
    :type in_type: str
    :type out_prefix: str
    :type base_dir: str
    :type options: list

    :returns: a tuple containing the prefix of the output files (the input
              prefix for the next script) and the type of the output files
              (``tfile``).

    This function calls the
    :py:mod:`pyGenClean.NoCallHetero.clean_noCall_hetero_snps` module. The
    required file type for this module is ``tfile``, hence the need to use the
    :py:func:`check_input_files` to check if the file input file type is the
    good one, or to create it if needed.

def run_noCall_hetero_snps(in_prefix, in_type, out_prefix, base_dir, options):
    """Runs step 3 (clean no call and hetero).

    :param in_prefix: the prefix of the input files.
    :param in_type: the type of the input files.
    :param out_prefix: the output prefix.
    :param base_dir: the output directory.
    :param options: the options needed.

    :type in_prefix: str
    :type in_type: str
    :type out_prefix: str
    :type base_dir: str
    :type options: list

    :returns: a tuple containing the prefix of the output files (the input
              prefix for the next script) and the type of the output files
              (``tfile``).

    This function calls the
    :py:mod:`pyGenClean.NoCallHetero.clean_noCall_hetero_snps` module. The
    required file type for this module is ``tfile``, hence the need to use the
    :py:func:`check_input_files` to check if the file input file type is the
    good one, or to create it if needed.

    """
    # Creating the output directory
    os.mkdir(out_prefix)

    # We know we need a tfile
    required_type = "tfile"
    check_input_files(in_prefix, in_type, required_type)

    # We need to inject the name of the input file and the name of the output
    # prefix
    script_prefix = os.path.join(out_prefix, "clean_noCall_hetero")
    options += ["--{}".format(required_type), in_prefix,
                "--out", script_prefix]

    # We run the script
    try:
        noCall_hetero_snps.main(options)
    except noCall_hetero_snps.ProgramError as e:
        msg = "noCall_hetero_snps: {}".format(e)
        raise ProgramError(msg)

    # We want to save in a file the markers and samples that were removed
    # There are two files to look at, which contains only one row, the name of
    # the markers:
    #     - prefix.allFailed
    #     - prefix.allHetero
    nb_all_failed = 0
    nb_all_hetero = 0
    o_filename = os.path.join(base_dir, "excluded_markers.txt")
    with open(o_filename, "a") as o_file:
        # The first file
        i_filename = script_prefix + ".allFailed"
        if os.path.isfile(i_filename):
            with open(i_filename, "r") as i_file:
                for line in i_file:
                    nb_all_failed += 1
                    print >>o_file, line.rstrip("\r\n") + "\tall failed"

        # The second file
        i_filename = os.path.join(script_prefix + ".allHetero")
        if os.path.isfile(i_filename):
            with open(i_filename, "r") as i_file:
                for line in i_file:
                    nb_all_hetero += 1
                    print >>o_file, line.rstrip("\r\n") + "\tall hetero"

    # We write a LaTeX summary
    latex_file = os.path.join(script_prefix + ".summary.tex")
    try:
        with open(latex_file, "w") as o_file:
            print >>o_file, latex_template.subsection(
                noCall_hetero_snps.pretty_name,
            )
            text = (
                "After scrutiny, {:,d} marker{} {} excluded from the "
                "dataset because of a call rate of 0. Also, {:,d} marker{} "
                "{} excluded from the dataset because all samples were "
                "heterozygous (excluding the mitochondrial "
                "chromosome)".format(nb_all_failed,
                                     "s" if nb_all_failed > 1 else "",
                                     "were" if nb_all_failed > 1 else "was",
                                     nb_all_hetero,
                                     "s" if nb_all_hetero > 1 else "",
                                     "were" if nb_all_hetero > 1 else "was")
            )
            print >>o_file, latex_template.wrap_lines(text, 80)

    except IOError:
        msg = "{}: cannot write LaTeX summary".format(latex_file)
        raise ProgramError(msg)

    # Writing the summary results
    with open(os.path.join(base_dir, "results_summary.txt"), "a") as o_file:
        print >>o_file, "# {}".format(script_prefix)
        print >>o_file, ("Number of completely failed markers\t"
                         "{nb:,d}\t-{nb:,d}".format(nb=nb_all_failed))
        print >>o_file, "---"
        print >>o_file, ("Number of all heterozygous markers\t"
                         "{nb:,d}\t-{nb:,d}".format(nb=nb_all_hetero))
        print >>o_file, "---"

    # We know this step does produce a new data set (tfile), so we return it
    # along with the report name
    return _StepResult(
        next_file=os.path.join(out_prefix, "clean_noCall_hetero"),
        next_file_type="tfile",
        latex_summary=latex_file,
        description=noCall_hetero_snps.desc,
        long_description=noCall_hetero_snps.long_desc,
        graph_path=None,
    )