diff --git a/test/tests_for_rate_eq_fitting.jl b/test/tests_for_rate_eq_fitting.jl index ff2b8ca..d8b4119 100644 --- a/test/tests_for_rate_eq_fitting.jl +++ b/test/tests_for_rate_eq_fitting.jl @@ -55,18 +55,22 @@ benchmark_result = @benchmark EnzymeFitting.loss_rate_equation($(kinetic_params) #TODO: make fake data with noise and known params and ensure known params are recovered fit_result = fit_rate_equation(rate_equation, data, metab_names, param_names; n_iter=20) @test isapprox(fit_result.loss, 0.08946088323758938, rtol=1e-3) -@test fit_result.params isa NamedTuple{param_names}{NTuple{length(param_names), Float64}} +@test fit_result.params isa NamedTuple{param_names}{NTuple{length(param_names),Float64}} ## #test the ability of `fit_rate_equation` to recover parameters used to generated data for an arbitrary enzyme -#TODO: use more complex test_rate_equation and add an option to fit real Vmax values instead of fixing Vmax=1.0 +#= +TODO: delete PKM2 example above after making below to use more complex test_rate_equation with 1-3 S, P and R and +randomly generated parameters and data around K values. +Add an option to fit real Vmax values instead of fixing Vmax=1.0. +=# test_rate_equation(metabs, params) = params.Vmax * (metabs.S / params.K_S) / (1 + metabs.S / params.K_S) param_names = (:Vmax, :K_S) metab_names = (:S,) -params = (Vmax = 10.0, K_S = 1.0) -data = DataFrame(S = [0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0]) +params = (Vmax=10.0, K_S=1.0) +data = DataFrame(S=[0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0]) noise_sd = 0.2 data.Rate = [test_rate_equation(row, params) * (1 + noise_sd * randn()) for row in eachrow(data)] data.source = ["Figure1" for i in 1:nrow(data)] fit_result = fit_rate_equation(test_rate_equation, data, metab_names, param_names; n_iter=20) -@test isapprox(fit_result.params.K_S, params.K_S, rtol=3*noise_sd) +@test isapprox(fit_result.params.K_S, params.K_S, rtol=3 * noise_sd)