From a36f397c34b114fbbaff8f3a371e0cd109ec54c5 Mon Sep 17 00:00:00 2001
From: st elmo <stelmozors@gmail.com>
Date: Wed, 31 Mar 2021 08:40:15 +0200
Subject: [PATCH] implement suggestions

---
 src/io/{matlab_reader.jl => m_reader.jl}      |  0
 src/io/{matlab_writer.jl => m_writer.jl}      |  0
 .../{cobraModel.jl => metabolicModel.jl}      |  0
 test/analysis/fba.jl                          | 52 +++++++++++++++++++
 test/analysis/fba2.jl                         | 51 ------------------
 test/analysis/fva.jl                          | 33 ++++++++++++
 test/analysis/fva2.jl                         | 32 ------------
 7 files changed, 85 insertions(+), 83 deletions(-)
 rename src/io/{matlab_reader.jl => m_reader.jl} (100%)
 rename src/io/{matlab_writer.jl => m_writer.jl} (100%)
 rename src/types/{cobraModel.jl => metabolicModel.jl} (100%)
 delete mode 100644 test/analysis/fba2.jl
 delete mode 100644 test/analysis/fva2.jl

diff --git a/src/io/matlab_reader.jl b/src/io/m_reader.jl
similarity index 100%
rename from src/io/matlab_reader.jl
rename to src/io/m_reader.jl
diff --git a/src/io/matlab_writer.jl b/src/io/m_writer.jl
similarity index 100%
rename from src/io/matlab_writer.jl
rename to src/io/m_writer.jl
diff --git a/src/types/cobraModel.jl b/src/types/metabolicModel.jl
similarity index 100%
rename from src/types/cobraModel.jl
rename to src/types/metabolicModel.jl
diff --git a/test/analysis/fba.jl b/test/analysis/fba.jl
index f4904c029..ccf7c5163 100644
--- a/test/analysis/fba.jl
+++ b/test/analysis/fba.jl
@@ -38,3 +38,55 @@
     # rxns = reactions(cp)
     # @test all([fluxesDict[rxns[i]] == sol[i] for i in eachindex(rxns)])
 end
+
+@testset "Flux balance analysis with CobraModel" begin
+    model = read_model(
+        Downloads.download(
+            "http://bigg.ucsd.edu/static/models/e_coli_core.json",
+            joinpath("data", "e_coli_core.json"),
+        ),
+    )
+    @test length(model.reactions) == 95 # read in correctly
+
+    # FBA
+    biomass = findfirst(model.reactions, "BIOMASS_Ecoli_core_w_GAM")
+    cons = Dict("EX_glc__D_e" => (-12.0, -12.0))
+    optimizer = Tulip.Optimizer # quiet by default
+    sol = fba(model, optimizer; objective_func = biomass, constraints = cons)
+    pfl = findfirst(model.reactions, "PFL")
+    solmulti = fba(model, optimizer; objective_func = [biomass, pfl], weights = [0.8, 0.2]) # classic flux balance analysis
+
+
+    flux_vec = [sol[rxn.id] for rxn in model.reactions]
+    sol_mapped = map_fluxes(flux_vec, model)
+    @test isapprox(sol_mapped["BIOMASS_Ecoli_core_w_GAM"], 1.0572509997013568, atol = 1e-6)
+    @test isapprox(sol["BIOMASS_Ecoli_core_w_GAM"], 1.0572509997013568, atol = 1e-6)
+    @test !isempty(solmulti)
+
+    sol = fba(model, optimizer; objective_func = biomass)
+
+    # atom tracker
+    atom_fluxes = atom_exchange(sol, model)
+    @test isapprox(atom_fluxes["C"], -37.1902, atol = 1e-3)
+
+    # exchange trackers
+    consuming, producing = exchange_reactions(sol; verbose = false)
+    @test isapprox(consuming["EX_nh4_e"], -4.76532, atol = 1e-3)
+
+    # metabolite trackers
+    consuming, producing = metabolite_fluxes(sol, model)
+    @test isapprox(consuming["atp_c"]["PFK"], -7.47738, atol = 1e-3)
+    @test isapprox(producing["atp_c"]["PYK"], 1.75818, atol = 1e-3)
+
+    # set bounds
+    cbm, v, mb, lbs, ubs = makeOptimizationModel(model, optimizer)
+    glucose_index = model[findfirst(model.reactions, "EX_glc__D_e")]
+    o2_index = model[findfirst(model.reactions, "EX_o2_e")]
+    atpm_index = model[findfirst(model.reactions, "ATPM")]
+    set_bound(glucose_index, lbs, ubs; ub = -1.0, lb = -1.0)
+    @test normalized_rhs(ubs[glucose_index]) == -1.0
+    @test normalized_rhs(lbs[glucose_index]) == 1.0
+    set_bound(o2_index, lbs, ubs; ub = 1.0, lb = 1.0)
+    @test normalized_rhs(ubs[o2_index]) == 1.0
+    @test normalized_rhs(lbs[o2_index]) == -1.0
+end
diff --git a/test/analysis/fba2.jl b/test/analysis/fba2.jl
deleted file mode 100644
index 8d71e752d..000000000
--- a/test/analysis/fba2.jl
+++ /dev/null
@@ -1,51 +0,0 @@
-@testset "Flux balance analysis with CobraModel" begin
-    model = read_model(
-        Downloads.download(
-            "http://bigg.ucsd.edu/static/models/e_coli_core.json",
-            joinpath("data", "e_coli_core.json"),
-        ),
-    )
-    @test length(model.reactions) == 95 # read in correctly
-
-    # FBA
-    biomass = findfirst(model.reactions, "BIOMASS_Ecoli_core_w_GAM")
-    cons = Dict("EX_glc__D_e" => (-12.0, -12.0))
-    optimizer = Tulip.Optimizer # quiet by default
-    sol = fba(model, optimizer; objective_func = biomass, constraints = cons)
-    pfl = findfirst(model.reactions, "PFL")
-    solmulti = fba(model, optimizer; objective_func = [biomass, pfl], weights = [0.8, 0.2]) # classic flux balance analysis
-
-
-    flux_vec = [sol[rxn.id] for rxn in model.reactions]
-    sol_mapped = map_fluxes(flux_vec, model)
-    @test isapprox(sol_mapped["BIOMASS_Ecoli_core_w_GAM"], 1.0572509997013568, atol = 1e-6)
-    @test isapprox(sol["BIOMASS_Ecoli_core_w_GAM"], 1.0572509997013568, atol = 1e-6)
-    @test !isempty(solmulti)
-
-    sol = fba(model, optimizer; objective_func = biomass)
-
-    # atom tracker
-    atom_fluxes = atom_exchange(sol, model)
-    @test isapprox(atom_fluxes["C"], -37.1902, atol = 1e-3)
-
-    # exchange trackers
-    consuming, producing = exchange_reactions(sol; verbose = false)
-    @test isapprox(consuming["EX_nh4_e"], -4.76532, atol = 1e-3)
-
-    # metabolite trackers
-    consuming, producing = metabolite_fluxes(sol, model)
-    @test isapprox(consuming["atp_c"]["PFK"], -7.47738, atol = 1e-3)
-    @test isapprox(producing["atp_c"]["PYK"], 1.75818, atol = 1e-3)
-
-    # set bounds
-    cbm, v, mb, lbs, ubs = makeOptimizationModel(model, optimizer)
-    glucose_index = model[findfirst(model.reactions, "EX_glc__D_e")]
-    o2_index = model[findfirst(model.reactions, "EX_o2_e")]
-    atpm_index = model[findfirst(model.reactions, "ATPM")]
-    set_bound(glucose_index, lbs, ubs; ub = -1.0, lb = -1.0)
-    @test normalized_rhs(ubs[glucose_index]) == -1.0
-    @test normalized_rhs(lbs[glucose_index]) == 1.0
-    set_bound(o2_index, lbs, ubs; ub = 1.0, lb = 1.0)
-    @test normalized_rhs(ubs[o2_index]) == 1.0
-    @test normalized_rhs(lbs[o2_index]) == -1.0
-end
diff --git a/test/analysis/fva.jl b/test/analysis/fva.jl
index 142e5f9b4..1bb309d43 100644
--- a/test/analysis/fva.jl
+++ b/test/analysis/fva.jl
@@ -59,3 +59,36 @@ end
     ]
     rmprocs(pids)
 end
+
+@testset "Flux variability analysis with CobraModel" begin
+    model = read_model(
+        Downloads.download(
+            "http://bigg.ucsd.edu/static/models/e_coli_core.json",
+            joinpath("data", "e_coli_core.json"),
+        ),
+    )
+    @test length(model.reactions) == 95 # read in correctly
+
+    biomass = findfirst(model.reactions, "BIOMASS_Ecoli_core_w_GAM")
+    pfl = findfirst(model.reactions, "PFL")
+
+    # FVA
+    optimizer = Tulip.Optimizer
+    atts = Dict("IPM_IterationsLimit" => 500)
+    cons = Dict("EX_glc__D_e" => (-10.0, -10.0))
+    fva_max, fva_min =
+        fva(model, optimizer; objective_func = biomass, solver_attributes = atts)
+    fva_max2, fva_min2 = fva(
+        model,
+        optimizer;
+        objective_func = [biomass, pfl],
+        weights = [0.5, 0.5],
+        constraints = cons,
+    )
+    @testset "FVA" begin
+        @test isapprox(fva_max["PDH"]["PDH"], 9.338922420065819, atol = 1e-6)
+        @test isapprox(fva_min["PDH"]["PDH"], 9.270274952732315, atol = 1e-6)
+        @test !isempty(fva_max2)
+        @test !isempty(fva_min2)
+    end
+end
diff --git a/test/analysis/fva2.jl b/test/analysis/fva2.jl
deleted file mode 100644
index b55acf46e..000000000
--- a/test/analysis/fva2.jl
+++ /dev/null
@@ -1,32 +0,0 @@
-@testset "Flux variability analysis with CobraModel" begin
-    model = read_model(
-        Downloads.download(
-            "http://bigg.ucsd.edu/static/models/e_coli_core.json",
-            joinpath("data", "e_coli_core.json"),
-        ),
-    )
-    @test length(model.reactions) == 95 # read in correctly
-
-    biomass = findfirst(model.reactions, "BIOMASS_Ecoli_core_w_GAM")
-    pfl = findfirst(model.reactions, "PFL")
-
-    # FVA
-    optimizer = Tulip.Optimizer
-    atts = Dict("IPM_IterationsLimit" => 500)
-    cons = Dict("EX_glc__D_e" => (-10.0, -10.0))
-    fva_max, fva_min =
-        fva(model, optimizer; objective_func = biomass, solver_attributes = atts)
-    fva_max2, fva_min2 = fva(
-        model,
-        optimizer;
-        objective_func = [biomass, pfl],
-        weights = [0.5, 0.5],
-        constraints = cons,
-    )
-    @testset "FVA" begin
-        @test isapprox(fva_max["PDH"]["PDH"], 9.338922420065819, atol = 1e-6)
-        @test isapprox(fva_min["PDH"]["PDH"], 9.270274952732315, atol = 1e-6)
-        @test !isempty(fva_max2)
-        @test !isempty(fva_min2)
-    end
-end
-- 
GitLab