示例#1
0
def parse_stdout_file(curr_timestep=0, stdout_filename="test.txt", debug=False):
    """
    :param curr_timestep:   first timestep from config
    :param stdout_filename: file to parse (test.txt)
    :param debug:           whether or not we write an additional file that's full of the matched lines
    :return:                an array of lines of interest
    """
    filtered_lines = []
    update_time = "Update(): Time:"
    incubation_timer = "Incubation_timer calculated as"
    art_notify_event = "notifyOnEvent"
    incubation_timer_update = "LifeCourseLatencyTimerUpdate"
    time = 0
    with open(stdout_filename) as logfile:
        for line in logfile:
            if update_time in line:
                time += 1
            elif incubation_timer_update in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)
            elif incubation_timer in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)
            elif art_notify_event in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)

    if debug:
        with open("filtered_lines.txt", "w") as outfile:
            outfile.writelines(filtered_lines)

    return filtered_lines
示例#2
0
def parse_stdout_file(curr_timestep=0,
                      stdout_filename="test.txt",
                      debug=False):
    """
    :param curr_timestep:   first timestep from config
    :param stdout_filename: file to parse (test.txt)
    :param debug:           whether or not we write an additional file that's full of the matched lines
    :return:                array of lines of interest
    """
    died_of_coinfection = "died of CoInfection"
    state_active_symptomatic = "infectionstatechange TBActivation "
    filtered_lines = []
    update_time = "Update(): Time:"
    time = 0
    with open(stdout_filename) as logfile:
        for line in logfile:
            if update_time in line:
                time += 1
            elif died_of_coinfection in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)
            elif state_active_symptomatic in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)
    if debug:
        with open("filtered_lines.txt", "w") as outfile:
            outfile.writelines(filtered_lines)

    return filtered_lines
示例#3
0
def parse_stdout_file(curr_timestep=0,
                      stdout_filename="test.txt",
                      debug=False):
    """
    :param curr_timestep:   first timestep from config
    :param stdout_filename: file to parse (test.txt)
    :param debug:           whether or not we write an additional file that's full of the matched lines
    :return:                array of lines of interest
    """
    new_infection_state = "SetNewInfectionState"
    filtered_lines = []
    update_time = "Update(): Time:"
    incubation_timer = "InitializeLatentInfection"
    time = 0
    with open(stdout_filename) as logfile:
        for line in logfile:
            if update_time in line:
                time += 1
            elif new_infection_state in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)
            elif incubation_timer in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)

    if debug:
        with open("filtered_lines.txt", "w") as outfile:
            outfile.writelines(filtered_lines)

    return filtered_lines
示例#4
0
def parse_stdout_file(curr_timestep=0,
                      stdout_filename="test.txt",
                      debug=False):
    """
    :param curr_timestep:   first timestep from config
    :param stdout_filename: file to parse (test.txt)
    :param debug:           whether or not we write an additional file that's full of the matched lines
    :return:                array of lines of interest
    """
    expose = "Expose: Individual"
    filtered_lines = []
    update_time = "Update(): Time:"
    time = 0
    with open(stdout_filename) as logfile:
        for line in logfile:
            if update_time in line:
                time += 1
            if expose in line:
                ind = int(dtk_sft.get_val("Individual ", line))
                if ind <= 100:  # do not look at imported people
                    new_line = dtk_sft.add_time_stamp(time, line)
                    filtered_lines.append(new_line)

    if debug:
        with open("filtered_lines.txt", "w") as outfile:
            outfile.writelines(filtered_lines)

    return filtered_lines
示例#5
0
def parse_stdout_file(curr_timestep=0,
                      stdout_filename="test.txt",
                      debug=False):
    """
    :param curr_timestep:   first timestep from config
    :param stdout_filename: file to parse (test.txt)
    :param debug:           whether or not we write an additional file that's full of the matched lines
    :return:                an array of filtered lines
    """
    update_infectiousness = "UpdateInfectiousness Individual"
    update_time = "Update(): Time:"
    time = 0
    filtered_lines = []
    with open(stdout_filename) as logfile:
        for line in logfile:
            if update_time in line:
                time += 1
            if update_infectiousness in line:
                new_line = dtk_sft.add_time_stamp(time, line)
                filtered_lines.append(new_line)

    if debug:
        with open("filtered_lines.txt", "w") as outfile:
            outfile.writelines(filtered_lines)

    return filtered_lines