---
  output:
  pdf_document: default
  html_document: default
---

library(BacArena)

diet = read.csv("S1_Table.csv", header = T)
load("S1_Data.Rdata")

arena <- Arena(n = 30, m = 30)

for (i in 1 : length(sihumi)){
  model = sihumi[[i]]
  bac = Bac(model = model, growtype = "exponential", speed = 10)
  arena = addOrg(arena ,bac ,amount=10)
}

diet <-  diet[which(diet$Exchange %in% arena@mediac),]
arena <- addSubs(arena, smax = diet$concentration.im.mM/4, difspeed = diet$diffconstant. unit = "mM",mediac = as.character(diet$Exchange))

sim <- simEnv(arena, time=37, with_shadow=TRUE)
save(sim, file ="sim_notmanipulated.rda")


model_manipulated <- sihumi[[5]]
model_manipulated@S[901,911] <- -1000

sim1 <- get(load("sim_notmanipulated.rda"))

add_subs <- c("EX_pi(e)", "EX_glu_L(e)")

add_spec = Bac(model = model_manipulated, growtype = "exponential", speed  = 10)

arena2 <- getArena(sim1, 27)

arena2 <- addSubs(arena2, smax = c(0.625,6.25), difspeed = 6.70E-06, mediac = add_subs, unit = "fmol/cell")

arena2 <- addOrg(arena2, specI = addspec, amount = 20)

sim <- simEnv(arena2, time = 10, with_shadow=TRUE)
save(sim, file ="sim_manipulated.rda")