<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _create_summary_table(fn, template, nb_samples, nb_markers):
 """Creates the final table. :param fn: the name of the file containing the summary. :param template: the Jinja2 template. :param nb_samples: the final number of samples. :param nb_markers: the final number of markers. :type fn: str :type template: Jinja2.template :type nb_samples: str :type nb_markers: str """

    # The final data
    table_data = []

    # Reading the summary file
    with open(fn, "r") as i_file:
        data = None

        line = i_file.readline()
        while line != "":
            if line.startswith("#"):
                # If there is data, this isn't the first line, so we save
                if data:
                    table_data.append(data)

                # This is the 'header' of a section (hence a new section)
                data = dict(
                    header=line.rstrip("\r\n").split(" ")[1],
                    data=[],
                )

                # Changing to next line
                line = i_file.readline()
                continue

            # If the line starts with '---', then it's a horizontal line
            if line.startswith("---"):
                data["data"].append(dict(hline=True))

                # Changing to next line
                line = i_file.readline()
                continue

            # If the line starts with '  -', then it's a sub section
            if line.startswith("  -"):
                tmp = line[4:].rstrip("\r\n").split("\t")
                if data["header"].endswith("/subset"):
                    if tmp[0].startswith("_file_path:"):
                        tmp[0] = r"\path{" + tmp[0][11:] + "}"
                elif data["header"].endswith("/flag_hw"):
                    tmp[0] = latex.format_numbers(tmp[0], prefix="p < ")
                else:
                    tmp = map(latex.sanitize_tex, tmp)
                    if tmp[0].startswith("x"):
                        tmp[0] = latex.inline_math(r"\times " + tmp[0][1:])

                data["data"].append(dict(
                    hline=False,
                    multicol=False,
                    row_data=tmp,
                ))

                # Changing to next line
                line = i_file.readline()
                continue

            # This is a regular line
            data["data"].append(dict(
                hline=False,
                multicol=True,
                row_data=map(
                    latex.sanitize_tex,
                    line.rstrip("\r\n").split("\t"),
                ),
            ))

            # Skipping to next line
            line = i_file.readline()

    # We add the last entry
    table_data.append(data)

    # Rendering
    return template.render(table_data=table_data, final_nb_markers=nb_markers,
                           final_nb_samples=nb_samples)