Ejemplo n.º 1
0
def v1_kcat_mwc_ident():
    name = MPI.Get_processor_name()
    rank = MPI.COMM_WORLD.Get_rank()
    size = MPI.COMM_WORLD.Get_size()

    if rank == 0:  # master
        print('I am %s Master with rank %s of %s' %
              (name, str(rank), str(size)))
        v1_obj = ModelIdent(
            ident_fun=kotte_model.flux_1_kcat_ident,
            arranged_data_file_name=os.path.join(
                os.getcwd(), 'exp/exp_v1_2_experiments_mwc'),
            ident_data_file_name=os.path.join(os.getcwd(),
                                              'ident/ident_v1_kcat_mwc'),
            **{
                'original_exp_file':
                os.path.join(os.getcwd(), 'exp/experiments_mwc'),
                'flux_id':
                1,
                'flux_choice':
                2,
                'values_figure':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_parameter_values.eps'),
                'ident_figure':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_ident.eps'),
                'exp_figure':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_exp.eps'),
                'figure_format':
                'eps'
            })
        exp_df = v1_obj.retrieve_df_from_file()

        job = ParallelProcess(slaves=range(1, size))

        ident_result = job.run_all(task='ident',
                                   **{
                                       'exp_df': exp_df,
                                       'ident_fun': v1_obj.ident_fun,
                                       'flux_id': v1_obj.flux_id,
                                       'flux_choice': v1_obj.flux_choice
                                   })

        job.terminate_slaves()

        # process ident data
        ident_processing(v1_obj, ident_result)

    else:
        print('I am %s Slave with rank %s of %s' %
              (name, str(rank), str(size)))
        ProcessSlave().run()

    return None
Ejemplo n.º 2
0
def v1_kcat_mwc_validate():
    name = MPI.Get_processor_name()
    rank = MPI.COMM_WORLD.Get_rank()
    size = MPI.COMM_WORLD.Get_size()

    if rank == 0:
        # create ident object first
        v1_ident = ModelIdent(
            ident_fun=kotte_model.flux_1_kcat_ident,
            arranged_data_file_name=os.path.join(
                os.getcwd(), 'exp/exp_v1_2_experiments_mwc'),
            ident_data_file_name=os.path.join(os.getcwd(),
                                              'ident/ident_v1_kcat_mwc'),
            **{
                'original_exp_file':
                os.path.join(os.getcwd(), 'exp/experiments_mwc'),
                'flux_id':
                1,
                'flux_choice':
                2,
                'values_figure':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_parameter_values.eps'),
                'ident_figure':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_ident.eps'),
                'exp_figure':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_exp.eps'),
                'figure_format':
                'eps',
                'ident_index_label': ['sample_name', 'data_set_id']
            })

        # retrieve identifiability data and process it for validation
        v1_ident.validation_info()

        user_ode_opts = {
            'iter': 'Newton',
            'discr': 'Adams',
            'atol': 1e-10,
            'rtol': 1e-10,
            'time_points': 200,
            'display_progress': True,
            'verbosity': 30
        }
        # initial ss to begin all simulations from
        y0 = np.array([5, 1, 1])
        # get and set true parameter values, if available separately
        default_parameters = true_parameter_values()

        v1_valid_obj = ValidateSim(
            kotte_model.kotte_ode, kotte_model.kotte_flux, **{
                'kinetics':
                1,
                'ode_opts':
                user_ode_opts,
                't_final':
                200,
                'wt_y0':
                y0,
                'i_parameter':
                default_parameters,
                'sample_size':
                1,
                'noise_std':
                0.05,
                'validate_index_label':
                ['estimate_id', 'sample_name', 'data_set_id', 'experiment_id'],
                'validate_file_name':
                os.path.join(os.getcwd(), 'validate/v1_kcat_mwc_validate'),
                'original_exp_file':
                v1_ident.original_exp_file,
                'c_validate_file':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_c_validate.eps'),
                'f_validate_file':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_f_validate.eps'),
                'c_exp_file':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_c_exp.eps'),
                'v_exp_file':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_f_exp.eps'),
                'format':
                v1_ident.figure_format
            })

        parameter_estimates, estimate_info = v1_valid_obj.create_parameter_list(
            v1_ident.select_values)

        job = ParallelValidate(slaves=range(1, size))

        validate_results = job.run_all(task='initial_sim',
                                       **{
                                           'parameters': parameter_estimates,
                                           'estimate_info': estimate_info,
                                           'sim_obj': v1_valid_obj
                                       })
        job.terminate_slaves()

        # process validation data for plots
        validate_processing(v1_valid_obj, validate_results)

    else:

        print('I am %s Slave with rank %s of %s' %
              (name, str(rank), str(size)))
        ValidateSlave().run()

    return None