From 524a8bba89b95840b4e9215c403947a8bb76d7b2 Mon Sep 17 00:00:00 2001
From: Johannes Ranke
mkinmod( ..., use_of_ff = "max", + name = NULL, speclist = NULL, quiet = FALSE, - verbose = FALSE + verbose = FALSE, + dll_dir = NULL, + unload = FALSE, + overwrite = FALSE ) # S3 method for mkinmod @@ -200,6 +204,10 @@ formation fractions are always used (default). If "min", a minimum use of formation fractions is made, i.e. each pathway to a metabolite has its own rate constant. ++ name ++ A name for the model. Should be a valid R object name.
+ speclist The specification of the observed variables and their @@ -214,6 +222,23 @@ argument. Default is NULL.
verbose + If
TRUE
, passed toinline::cfunction()
if applicable to give detailed information about the C function being built.+ +dll_dir ++ Directory where an DLL object, if generated internally by +
inline::cfunction()
, should be saved. The DLL will only be stored in a +permanent location for use in future sessions, if 'dll_dir' and 'name' +are specified.+ +unload ++ If a DLL from the target location in 'dll_dir' is already +loaded, should that be unloaded first?
+ overwrite +If a file exists at the target DLL location in 'dll_dir', +should this be overwritten?
x @@ -299,18 +324,37 @@ Evaluating and Calculating Degradation Kinetics in Environmental Media SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) -#>+#>#> <mkinmod> model generated with +#> Use of formation fractions $use_of_ff: max +#> Specification $spec: +#> $parent +#> $type: SFO; $to: m1; $sink: TRUE +#> $m1 +#> $type: SFO; $sink: TRUE +#> Coefficient matrix $coefmat available +#> Compiled model $cf available +#> Differential equations: +#> d_parent/dt = - k_parent * parent +#> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1# \dontrun{ -# Now supplying full names used for plotting + fit_sfo_sfo <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, solution_type = "deSolve") +#> Warning: Observations with value of zero were removed from the data+ # Now supplying compound names used for plotting, and write to user defined location + # We need to choose a path outside the session tempdir because this gets removed + DLL_dir <- "~/.local/share/mkin" + if (!dir.exists(DLL_dir)) dir.create(DLL_dir) SFO_SFO.2 <- mkinmod( parent = mkinsub("SFO", "m1", full_name = "Test compound"), - m1 = mkinsub("SFO", full_name = "Metabolite M1")) -#>-# The above model used to be specified like this, before the advent of mkinsub() -SFO_SFO <- mkinmod( - parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO")) -#>+ m1 = mkinsub("SFO", full_name = "Metabolite M1"), + name = "SFO_SFO", dll_dir = DLL_dir, unload = TRUE, overwrite = TRUE) +#># Now we can save the model and restore it in a new session +saveRDS(SFO_SFO.2, file = "~/SFO_SFO.rds") +# Terminate the R session here if you would like to check, and then do +library(mkin) +SFO_SFO.3 <- readRDS("~/SFO_SFO.rds") +fit_sfo_sfo <- mkinfit(SFO_SFO.3, FOCUS_2006_D, quiet = TRUE, solution_type = "deSolve") +#> Warning: Observations with value of zero were removed from the data# Show details of creating the C function SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), @@ -330,11 +374,11 @@ Evaluating and Calculating Degradation Kinetics in Environmental Media #> 12: } #> 13: #> 14: -#> 15: void func ( int * n, double * t, double * y, double * f, double * rpar, int * ipar ) { +#> 15: void diffs ( int * n, double * t, double * y, double * f, double * rpar, int * ipar ) { #> 16: #> 17: f[0] = - k_parent * y[0]; #> 18: f[1] = + f_parent_to_m1 * k_parent * y[0] - k_m1 * y[1]; -#> 19: }#>+#> 19: }#># The symbolic solution which is available in this case is not # made for human reading but for speed of computation SFO_SFO$deg_func @@ -353,7 +397,7 @@ Evaluating and Calculating Degradation Kinetics in Environmental Media #> }) #> return(predicted) #> } -#> <environment: 0x55555c97f8d8>+#> <environment: 0x55555c5b8d68># If we have several parallel metabolites # (compare tests/testthat/test_synthetic_data_for_UBA_2014.R) m_synth_DFOP_par <- mkinmod( @@ -367,27 +411,6 @@ Evaluating and Calculating Degradation Kinetics in Environmental Media quiet = TRUE) # } - - m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), - M1 = list(type = "SFO", to = "M2"), - M2 = list(type = "SFO"), use_of_ff = "max") -#>#> <mkinmod> model generated with -#> Use of formation fractions $use_of_ff: max -#> Specification $spec: -#> $parent -#> $type: SFO; $to: M1; $sink: TRUE -#> $M1 -#> $type: SFO; $to: M2; $sink: TRUE -#> $M2 -#> $type: SFO; $sink: TRUE -#> Coefficient matrix $coefmat available -#> Compiled model $cf available -#> Differential equations: -#> d_parent/dt = - k_parent * parent -#> d_M1/dt = + f_parent_to_M1 * k_parent * parent - k_M1 * M1 -#> d_M2/dt = + f_M1_to_M2 * k_M1 * M1 - k_M2 * M2