n_islands=number_of_processes,
    max_cycles_without_improvement=max_cycles_without_improvement,
    stop_criteria_relative=0.01,
    initial_archi_x=[],
    lb_list=[],
    ub_list=[],
    max_flux=1e6,
    label_problem_parameters=label_problem_parameters)

label_model.best_chi2 = optimal_solution

flux_sd_dict, hessian, inverse_hessian, covariance = get_std_deviation(
    label_model, optimal_variables, initial_step=1e-3)

export_flux_results(label_model,
                    optimal_variables,
                    fn=output_prefix + "_fluxes.csv",
                    flux_sd_dict=flux_sd_dict)
objfunc(label_model, optimal_variables)
export_label_results(label_model,
                     fn=output_prefix + "_label.csv",
                     show_chi=True,
                     show_emu=False,
                     show_fluxes=False)
np.savetxt(output_prefix + "_variables.txt", optimal_variables)
reference_parameters = [optimal_variables]
label_model.best_label_variables = optimal_variables

save_iso2flux_model(label_model,
                    name=output_prefix + ".iso2flux",
                    write_sbml=True,
                    ask_sbml_name=False,
예제 #2
0
best_flux=initial_flux_estimation
best_variables=None


for iteration in range(0,n_iterations):
    flux_objective,variables=minimize_fluxes(label_model,iso2flux_problem,label_problem_parameters,max_chi=max_chi,flux_penalty_dict=flux_penalty_dict ,pop_size=pop_size ,n_gen=n_gen ,n_islands=number_of_processes ,max_cycles_without_improvement=max_cycles_without_improvement ,max_evolve_cycles=999 ,stop_criteria_relative=0.0005 ,max_iterations=1,  initial_flux_estimation=initial_flux_estimation,log_name=file_name.replace(".iso2flux","_p13cmfa_log.txt"),migrate="one_direction",max_flux_sampling=max_flux_for_sampling)
    print "flux minimized to " + str(round(flux_objective,3))
    if flux_objective<best_flux:
       initial_flux_estimation=best_best_flux=flux_objective
       label_problem_parameters={"label_weight":0.0001,"target_flux_dict":None,"max_chi":max_chi,"max_flux":best_flux,"flux_penalty_dict":flux_penalty_dict,"verbose":True,"flux_weight":1,"flux_unfeasible_penalty":25,"label_unfeasible_penalty":5}
       best_best_flux=flux_objective
       best_variables=variables



export_flux_results(label_model,best_variables,fn=output_prefix+"_p13cmfa_fluxes.csv")
export_flux_results(label_model,best_variables,fn=output_prefix+"_p13cmfa_fluxes_irreversible.csv",reversible=False)

objfunc(label_model,best_variables)
export_label_results(label_model,fn=output_prefix+"_p13cmfa_label.csv",show_chi=True,show_emu=True,show_fluxes=False)
np.savetxt(output_prefix+"_p13cmfa_variables.txt",best_variables)
label_model.best_p13cmfa_variables=best_variables
label_model.label_tolerance=max_chi
label_model.best_flux=flux_objective

print label_model.label_tolerance

save_iso2flux_model(label_model,name=output_prefix+".iso2flux",write_sbml=True,ask_sbml_name=False,gui=False)

예제 #3
0
파일: p13cmfa.py 프로젝트: cfoguet/iso2flux
label_problem_parameters={"label_weight":0.0001,"target_flux_dict":None,"max_chi":max_chi,"max_flux":initial_flux_estimation,"flux_penalty_dict":flux_penalty_dict,"verbose":True,"flux_weight":1,"flux_unfeasible_penalty":25,"label_unfeasible_penalty":5}

best_flux=initial_flux_estimation
best_variables=None


for iteration in range(0,n_iterations):
    flux_objective,variables=minimize_fluxes(label_model,iso2flux_problem,label_problem_parameters,max_chi=max_chi,flux_penalty_dict=flux_penalty_dict ,pop_size=pop_size ,n_gen=n_gen ,n_islands=number_of_processes ,max_cycles_without_improvement=max_cycles_without_improvement ,max_evolve_cycles=999 ,stop_criteria_relative=0.000001 ,max_iterations=1,  initial_flux_estimation=initial_flux_estimation,log_name=file_name.replace(".iso2flux","_p13cmfa_log.txt"),migrate="one_direction")
    print "flux minimized to " + str(round(flux_objective,3))
    if flux_objective<best_flux:
       initial_flux_estimation=best_best_flux=flux_objective
       label_problem_parameters={"label_weight":0.0001,"target_flux_dict":None,"max_chi":max_chi,"max_flux":best_flux,"flux_penalty_dict":flux_penalty_dict,"verbose":True,"flux_weight":1,"flux_unfeasible_penalty":25,"label_unfeasible_penalty":5}
       best_best_flux=flux_objective
       best_variables=variables



export_flux_results(label_model,best_variables,fn=output_prefix+"_p13cmfa_fluxes.csv")
objfunc(label_model,best_variables)
export_label_results(label_model,fn=output_prefix+"_p13cmfa_label.csv",show_chi=True,show_emu=True,show_fluxes=False)
np.savetxt(output_prefix+"_p13cmfa_variables.txt",best_variables)
label_model.best_p13cmfa_variables=best_variables
label_model.label_tolerance=max_chi
label_model.best_flux=flux_objective

print label_model.label_tolerance

save_iso2flux_model(label_model,name=output_prefix+".iso2flux",write_sbml=True,ask_sbml_name=False,gui=False)

예제 #4
0
    max_flux=1e6,
    label_problem_parameters=label_problem_parameters,
    migrate="one_direction",
    max_flux_sampling=max_flux_for_sampling)

label_model.best_chi2 = optimal_solution

try:
    flux_sd_dict, hessian, inverse_hessian, covariance = get_std_deviation(
        label_model, optimal_variables, initial_step=1e-3)
except:
    flux_sd_dict = {}

export_flux_results(label_model,
                    optimal_variables,
                    fn=output_prefix + "_fluxes.csv",
                    flux_sd_dict=flux_sd_dict,
                    reversible=True)

export_flux_results(label_model,
                    optimal_variables,
                    fn=output_prefix + "_irreversible_fluxes.csv",
                    flux_sd_dict={},
                    reversible=False)

objfunc(label_model, optimal_variables)
export_label_results(label_model,
                     fn=output_prefix + "_label.csv",
                     show_chi=True,
                     show_emu=True,
                     show_fluxes=False)
   if passed_flag==True:
      print "Validation passed"
   sys.exit(2)


label_problem_parameters={"label_weight":1,"target_flux_dict":None,"max_chi":1e6,"max_flux":1e6,"flux_penalty_dict":{},"verbose":True,"flux_weight":0.0,"label_unfeasible_penalty":1,"flux_unfeasible_penalty":10}


iso2flux_problem=define_isoflux_problem(label_model)
optimal_solution,optimal_variables=optimize(label_model,iso2flux_problem,pop_size = pop_size,n_gen = n_gen,n_islands=number_of_processes ,max_cycles_without_improvement=max_cycles_without_improvement,stop_criteria_relative=0.01,initial_archi_x=[],lb_list=[],ub_list=[],max_flux=1e6,label_problem_parameters=label_problem_parameters)

label_model.best_chi2=optimal_solution

flux_sd_dict, hessian,inverse_hessian,covariance=get_std_deviation(label_model,optimal_variables,initial_step=1e-3)

export_flux_results(label_model,optimal_variables,fn=output_prefix+"_fluxes.csv",flux_sd_dict=flux_sd_dict)
objfunc(label_model,optimal_variables)
export_label_results(label_model,fn=output_prefix+"_label.csv",show_chi=True,show_emu=False,show_fluxes=False)
np.savetxt(output_prefix+"_variables.txt",optimal_variables)
reference_parameters=[optimal_variables]
label_model.best_label_variables=optimal_variables

save_iso2flux_model(label_model,name=output_prefix+".iso2flux",write_sbml=True,ask_sbml_name=False,gui=False)
if not compute_intervals:
   output_model=label_model.constrained_model.copy()
   for reaction in output_model.reactions:
        if reaction.id in label_model.reversible_flux_dict:
           reaction.lower_bound=max(round_down(label_model.reversible_flux_dict[reaction.id],6),reaction.lower_bound)
           reaction.upper_bound=min(round_up(label_model.reversible_flux_dict[reaction.id],6),reaction.upper_bound)

예제 #6
0
        label_problem_parameters = {
            "label_weight": 0.0001,
            "target_flux_dict": None,
            "max_chi": max_chi,
            "max_flux": best_flux,
            "flux_penalty_dict": flux_penalty_dict,
            "verbose": True,
            "flux_weight": 1,
            "flux_unfeasible_penalty": 25,
            "label_unfeasible_penalty": 5
        }
        best_best_flux = flux_objective
        best_variables = variables

export_flux_results(label_model,
                    best_variables,
                    fn=output_prefix + "_p13cmfa_fluxes.csv")
objfunc(label_model, best_variables)
export_label_results(label_model,
                     fn=output_prefix + "_p13cmfa_label.csv",
                     show_chi=True,
                     show_emu=True,
                     show_fluxes=False)
np.savetxt(output_prefix + "_p13cmfa_variables.txt", best_variables)
label_model.best_p13cmfa_variables = best_variables
label_model.label_tolerance = max_chi
label_model.best_flux = flux_objective

print label_model.label_tolerance

save_iso2flux_model(label_model,