diff --git a/src/Consistency Checking/SwiftCC.jl b/src/Consistency Checking/SwiftCC.jl index 8544d04..3c79f64 100644 --- a/src/Consistency Checking/SwiftCC.jl +++ b/src/Consistency Checking/SwiftCC.jl @@ -11,21 +11,22 @@ module SwiftCC export swiftCC -using GLPK, JuMP, COBREXA, LinearAlgebra, SparseArrays +using Distributed -include("../pre_processing.jl") +@everywhere using GLPK, JuMP, COBREXA, LinearAlgebra, SparseArrays -using .pre_processing +include("../Data Processing/pre_processing.jl") +using .pre_processing """ - swiftCC(myModel) + swiftCC(ModelObject) -Function that finds blocked reactions in metabolic network. +Function that finds blocked reactions for a metabolic network. # INPUTS -- `myModel`: A model that has been built using COBREXA's `load_model` function. +- `ModelObject`: a newly object of MyModel. # OPTIONAL INPUTS @@ -39,19 +40,24 @@ Function that finds blocked reactions in metabolic network. - Full input/output example ```julia -julia> blocked_reactions = swiftCC(myModel) +julia> blocked_reactions = swiftCC(ModelObject) ``` -See also: `dataOfModel()`, 'getTolerance()', `reversibility()`, `homogenization()` +See also: `MyModel`, myModel_Constructor(), 'getTolerance()', `reversibility()`, `homogenization()` """ +@everywhere function swiftCC(ModelObject::MyModel) -function swiftCC(myModel) - - # Exporting data from model: + # Exporting data from ModelObject: - S, Metabolites, Reactions, Genes, m, n, lb, ub = dataOfModel(myModel) + S = ModelObject.S + Metabolites = ModelObject.Metabolites + Reactions = ModelObject.Reactions + m = ModelObject.m + n = ModelObject.n + lb = ModelObject.lb + ub = ModelObject.ub # assigning a small value to Tolerance representing the level of error tolerance: diff --git a/src/pre_processing.jl b/src/Data Processing/pre_processing.jl similarity index 76% rename from src/pre_processing.jl rename to src/Data Processing/pre_processing.jl index 1339c75..a967c41 100644 --- a/src/pre_processing.jl +++ b/src/Data Processing/pre_processing.jl @@ -9,9 +9,69 @@ #------------------------------------------------------------------------------------------- module pre_processing -export dataOfModel, getM, getTolerance, reversibility, check_duplicate_reaction, homogenization, reversibility_checking, reversibility_correction +export MyModel, myModel_Constructor, dataOfModel, getM, getTolerance, reversibility, check_duplicate_reaction, homogenization, reversibility_checking, reversibility_correction -using GLPK, JuMP, COBREXA +using Distributed + +@everywhere using GLPK, JuMP, COBREXA + +""" + MyModel(S, Metabolites, Reactions, Genes, m, n, lb, ub) + +General type for storing a StandardModel which contains the following fields: + +- `S`: LHS matrix (m x n) +- `Metabolites`: List of metabolic network metabolites. +- `Reactions`: List of metabolic network reactions. +- `Genes`: List of metabolic network reactions. +- `m`: Number of rows of stoichiometric matrix. +- `n`: Number of columns of stoichiometric matrix. +- `lb`: Lower bound vector (n x 1) +- `ub`: Upper bound vector (n x 1) + +""" + +@everywhere mutable struct MyModel + S ::Union{SparseMatrixCSC{Float64,Int64}, AbstractMatrix} + Metabolites ::Array{String,1} + Reactions ::Array{String,1} + Genes ::Array{String,1} + m ::Int + n ::Int + lb ::Array{Float64,1} + ub ::Array{Float64,1} +end + +""" + myModel_Constructor(ModelObject, S, Metabolites, Reactions, Genes, m, n, lb, ub) + +Function that initializes a newly created object of MyModel. + +# INPUTS + +-'ModelObject' a newly object of MyModel. +- `S`: LHS matrix (m x n) +- `Metabolites`: List of metabolic network metabolites. +- `Reactions`: List of metabolic network reactions. +- `Genes`: List of metabolic network reactions. +- `m`: Number of rows of stoichiometric matrix. +- `n`: Number of columns of stoichiometric matrix. +- `lb`: Lower bound vector (n x 1) +- `ub`: Upper bound vector (n x 1) + +""" + +@everywhere function myModel_Constructor(ModelObject::MyModel, S::Union{SparseMatrixCSC{Float64,Int64}, AbstractMatrix}, Metabolites::Array{String,1}, Reactions::Array{String,1}, + Genes::Array{String,1}, m::Int, n::Int, lb::Array{Float64,1}, ub::Array{Float64,1}) + ModelObject.S = S + ModelObject.Metabolites = Metabolites + ModelObject.Reactions = Reactions + ModelObject.Genes = Genes + ModelObject.m = m + ModelObject.n = n + ModelObject.lb = lb + ModelObject.ub = ub +end """ dataOfModel(myModel) @@ -34,8 +94,8 @@ Function that exports essential data from StandardModel that has been built usin - `Genes`: List of metabolic network reactions. - `m`: Number of rows of stoichiometric matrix. - `n`: Number of columns of stoichiometric matrix. -- `lb`: LowerBound Of Reactions. -- `ub`: UpperBound of Reactions. +- `lb`: Lower bound vector (n x 1) +- `ub`: Upper bound vector (n x 1) # EXAMPLES @@ -86,7 +146,7 @@ julia> M = getM() """ -function getM() +@everywhere function getM() f = open("../config/ConfigFile.txt", "r") c = 0 for lines in readlines(f) @@ -104,7 +164,7 @@ end #------------------------------------------------------------------------------------------- """ - getTolerance(x) + getTolerance() Function that returns a small value to set Tolerance representing the level of error tolerance. @@ -129,7 +189,7 @@ julia> Tolerance = getTolerance() """ -function getTolerance() +@everywhere function getTolerance() f = open("../config/ConfigFile.txt", "r") c = 0 for lines in readlines(f) @@ -175,7 +235,7 @@ See also: `dataOfModel()` """ -function reversibility(lb) +@everywhere function reversibility(lb::Array{Float64,1}) n = length(lb) irreversible_reactions_id = [] reversible_reactions_id = [] @@ -220,7 +280,7 @@ See also: `dataOfModel()` """ -function check_duplicate_reaction(Reactions) +function check_duplicate_reaction(Reactions::Array{String,1}) n = length(Reactions) unique_reactions = unique!(Reactions) n_unique = length(unique_reactions) @@ -263,7 +323,7 @@ See also: `dataOfModel()`, 'getM()' """ -function homogenization(lb,ub) +@everywhere function homogenization(lb::Array{Float64,1}, ub::Array{Float64,1}) n = length(lb) # Set a large number for M: M = getM() @@ -318,7 +378,7 @@ See also: `dataOfModel()`, `reversibility()`, 'getTolerance()' """ -function reversibility_checking(S, lb, ub, reversible_reactions_id) +function reversibility_checking(S::Union{SparseMatrixCSC{Float64,Int64}, AbstractMatrix}, lb::Array{Float64,1}, ub::Array{Float64,1}, reversible_reactions_id::Vector{Int64}) Reactions = reactions(myModel) n = length(Reactions) @@ -407,7 +467,8 @@ See also: `dataOfModel()`, `homogenization()`, `reversibility()`, reversibility_ """ -function reversibility_correction(S, lb, ub, irreversible_reactions_id, reversible_reactions_id, rev_blocked_fwd, rev_blocked_back) +function reversibility_correction(S::Union{SparseMatrixCSC{Float64,Int64}, AbstractMatrix}, lb::Array{Float64,1}, ub::Array{Float64,1}, irreversible_reactions_id::Vector{Int64}, + reversible_reactions_id::Vector{Int64}, rev_blocked_fwd::Vector{Int64}, rev_blocked_back::Vector{Int64}) corrected_reversible_reactions_id = [] diff --git a/src/QFCA/distributedQFCA.jl b/src/QFCA/distributedQFCA.jl new file mode 100644 index 0000000..0f064bd --- /dev/null +++ b/src/QFCA/distributedQFCA.jl @@ -0,0 +1,289 @@ +#------------------------------------------------------------------------------------------- + +#= + Purpose: QFCA computes the table of flux coupling relations for a metabolic network + Author: Iman Ghadimi, Mojtaba Tefagh - Sharif University of Technology - Iran + Date: October 2022 +=# + +#------------------------------------------------------------------------------------------- + +module DistributedQFCA +export addQFCAProcs, removeQFCAProcs, distributedQFCA + +using Distributed + +@everywhere using GLPK, JuMP, COBREXA, LinearAlgebra, SparseArrays, Distributed, SharedArrays + +include("../Data Processing/pre_processing.jl") + +using .pre_processing + +include("../Consistency Checking/SwiftCC.jl") + +using .SwiftCC + +""" + addQFCAProcs(n) + +Function that adds n-1 processes to System. + +# INPUTS + +- `n`: Number of processes to add. + +# OPTIONAL INPUTS + +- + +# OUTPUTS + +- + +# EXAMPLES + +- Full input/output example +```julia +julia> addQFCAProcs(n) +``` + +See also: `` + +""" + +function addQFCAProcs(n::Int) + addprocs(n-1) + return +end + +""" + removeQFCAProcs() + +Function that removes n-1 processes from Systems. + +# INPUTS + +- + +# OPTIONAL INPUTS + +- + +# OUTPUTS + +- + +# EXAMPLES + +- Full input/output example +```julia +julia> removeQFCAProcs() +``` + +See also: `` + +""" + +function removeQFCAProcs() + procs_vector = procs() + for i in procs_vector[2:end] + rmprocs(i) + end + return +end + +""" + distributedQFCA(myModel) + +Function that computes the table of flux coupling relations for a metabolic network. + +# INPUTS + +- `myModel`: A model that has been built using COBREXA's `load_model` function. + +# OPTIONAL INPUTS + +- + +# OUTPUTS + +- `fctable`: The resulting flux coupling matrix. + The meaning of the entry (i, j) is: + * 0 - uncoupled reactions + * 1 - fully coupled reactions + * 2 - partially coupled reactions + * 3 - reaction i is directionally coupled to reaction j + * 4 - reaction j is directionally coupled to reaction i + +# EXAMPLES + +- Full input/output example +```julia +julia> fctable = distributedQFCA(myModel) +``` + +See also: `dataOfModel()`, `reversibility()`, `homogenization()`, `MyModel`, `myModel_Constructor()` + +""" + +function distributedQFCA(myModel) + + # Exporting data from StandardModel: + + S, Metabolites, Reactions, Genes, m, n, lb, ub = dataOfModel(myModel) + + # Determining the reversibility of a reaction: + + irreversible_reactions_id, reversible_reactions_id = reversibility(lb) + + # Determining the number of irreversible and reversible reactions: + + n_irr = length(irreversible_reactions_id) + n_rev = length(reversible_reactions_id) + + # Homogenizing the upper_bound and lower_bound of reactions: + + lb, ub = homogenization(lb, ub) + + # Creating a newly object of MyModel: + + ModelObject = MyModel(S, Metabolites, Reactions, Genes, m, n, lb, ub) + + # Removing blocked reactions from metabolic network: + + blocked_index = swiftCC(ModelObject) + n_blocked = length(blocked_index) + Reactions_noBlocked = Reactions[setdiff(range(1, n), blocked_index)] + lb_noBlocked = lb[setdiff(1:end, blocked_index)] + ub_noBlocked = ub[setdiff(1:end, blocked_index)] + S_noBlocked = S[:, setdiff(1:end, blocked_index)] + row_noBlocked, col_noBlocked = size(S_noBlocked) + + # Determining Coupling by using swiftCC function: + + @everywhere D = Dict() + + # Defining a SharedMatrix: + + @time begin + + DC_Matrix = SharedArray{Int,2}((col_noBlocked, col_noBlocked), init = false) + + # Finding Coupling between reactions by using swiftCC functions in Parallel: + + @sync @distributed for i in range(1, col_noBlocked) + lb_temp = lb_noBlocked[i] + ub_temp = ub_noBlocked[i] + lb_noBlocked[i] = 0.0 + ub_noBlocked[i] = 0.0 + myModel_Constructor(ModelObject ,S_noBlocked, Metabolites, Reactions_noBlocked, Genes, row_noBlocked, col_noBlocked, lb_noBlocked, ub_noBlocked) + blocked = swiftCC(ModelObject) + D[i] = blocked + D_values = collect(values(D[i])) + DC_Matrix[i,D_values] .= 1.0 + lb_noBlocked[i] = lb_temp + ub_noBlocked[i] = ub_temp + end + + end + + # Defining a matrix to save coupling relations: + + fctable = zeros(col_noBlocked, col_noBlocked) + + # Directional Coupling: + + # i-->j + + for i in range(1, col_noBlocked) + for j in range(1, col_noBlocked) + if DC_Matrix[i, j] == 1 + fctable[j,i] = 3.0 + end + end + end + + # Self-Coupling: + + fctable[diagind(fctable)] .= 1.0 + + # Distingushing between (DC, FC or PC) kinds of coupling: + + for i in range(1, col_noBlocked) + for j in range(i+1, col_noBlocked) + + # i--->j + + if fctable[i,j] == 3.0 && fctable[j,i] == 0.0 + fctable[j,i] = 4.0 + + # j--->i + + elseif fctable[i,j] == 0.0 && fctable[j,i] == 3.0 + fctable[i,j] = 4.0 + + # i--->j && j--->i ----> Partially Coupling + + elseif fctable[i,j] == 3.0 && fctable[j,i] == 3.0 + fctable[i,j] = fctable[j,i] = 2.0 + else + continue + end + end + end + + # Determining Partial Couples: + + PC = Dict() + + s = 1 + Partially_Couples = [] + + for i in range(1, col_noBlocked) + for j in range(1, col_noBlocked) + if fctable[i,j] == fctable[j,i] == 2.0 + Partially_Couples = i,j + PC[s] = Partially_Couples + s = s + 1 + end + end + end + + # Solving a LU for each pair to determine Fully Coupling: + + for key in sort(collect(keys(PC))) + + # Transposing S: + + S_noBlocked_transpose = S_noBlocked' + + # CO + + CO = zeros(col_noBlocked) + + # Setting CO vector: + + CO[PC[key][1]] = -1 + + # Removing C: + + S_noBlocked_transpose = S_noBlocked_transpose[1:end .!= PC[key][2], :] + + CO = CO[setdiff(1:end, PC[key][2])] + + # Using Gaussian elimination: + + X = S_noBlocked_transpose \ CO + + Sol = (S_noBlocked_transpose*X) - (CO) + + # Determining Fully Coupling: + + if isapprox(norm(Sol), 0.0, atol = 1e-8) + fctable[PC[key][1],PC[key][2]] = 1.0 + end + end + + return fctable + +end diff --git a/test/Models/e_coli_core.xml b/test/Models/e_coli_core.xml new file mode 100644 index 0000000..b1ee5c6 --- /dev/null +++ b/test/Models/e_coli_core.xml @@ -0,0 +1,9898 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/find_blocked_data.jl b/test/TestData.jl similarity index 59% rename from test/find_blocked_data.jl rename to test/TestData.jl index bbfa824..77e2d6c 100644 --- a/test/find_blocked_data.jl +++ b/test/TestData.jl @@ -1,13 +1,14 @@ -module find_blocked_data +module TestData -export myModel_iAM_Pv461, myModel_iAT_PLT_636, myModel_iNJ661, - blockedTest_iAM_Pv461, blockedTest_iAT_PLT_636, blockedTest_iNJ661 +export myModel_e_coli_core, myModel_iAM_Pv461, myModel_iAT_PLT_636, myModel_iNJ661, + distributedQFCATest_e_coli_core, blockedTest_iAM_Pv461, blockedTest_iAT_PLT_636, blockedTest_iNJ661 using COBREXA, DelimitedFiles # Loading Metabolic Networks: +myModel_e_coli_core = load_model(StandardModel,"Models/e_coli_core.xml") myModel_iAM_Pv461 = load_model(StandardModel,"Models/iAM_Pv461.xml") myModel_iAT_PLT_636 = load_model(StandardModel,"Models/iAT_PLT_636.xml") myModel_iNJ661 = load_model(StandardModel,"Models/iNJ661.xml") @@ -17,5 +18,6 @@ myModel_iNJ661 = load_model(StandardModel,"Models/iNJ661.xml") blockedTest_iAM_Pv461(list_TheNaive, list_SwiftCC) = all(list_TheNaive .== list_SwiftCC) blockedTest_iAT_PLT_636(list_TheNaive, list_SwiftCC) = all(list_TheNaive .== list_SwiftCC) blockedTest_iNJ661(list_TheNaive, list_SwiftCC) = all(list_TheNaive .== list_SwiftCC) +distributedQFCATest_e_coli_core(fctable_seq, fctable_4P, fctable_8P) = all(fctable_seq .== fctable_4P .== fctable_8P) end diff --git a/test/ecoli.jl b/test/ecoli.jl index e4be0f8..ea04635 100644 --- a/test/ecoli.jl +++ b/test/ecoli.jl @@ -15,4 +15,4 @@ fctest(table) = all(table .== fctable) palette = distinguishable_colors(5) fcfig = map(x -> palette[convert(Int64, x+1)], fctable) -end \ No newline at end of file +end diff --git a/test/runtests.jl b/test/runtests.jl index 80a02f7..dce30c9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -11,11 +11,11 @@ fctable = @time QFCA(S, rev)[end] # importing the example model and the TheNaiveApproach library: -include("find_blocked_data.jl") -include("../src/pre_processing.jl") +include("TestData.jl") +include("../src/Data Processing/pre_processing.jl") include("../src/Consistency Checking/TheNaiveApproach.jl") include("../src/Consistency Checking/SwiftCC.jl") -using .find_blocked_data, .pre_processing, .TheNaiveApproach, .SwiftCC +using .TestData, .pre_processing, .TheNaiveApproach, .SwiftCC # Comparing TheNaiveApproach and SwiftCC Outputs: @@ -36,3 +36,46 @@ blockedList_swiftCC_iAT_PLT_636 = @time swiftCC(myModel_iAT_PLT_636) blockedList_TheNaive_iNJ661 = @time find_blocked_reactions(myModel_iNJ661) blockedList_swiftCC_iNJ661 = @time swiftCC(myModel_iNJ661) @test blockedTest_iNJ661(blockedList_TheNaive_iNJ661, blockedList_swiftCC_iNJ661) + +## Comparing fctable among 1P and 4P and 8P: + +# 1P + +include("TestData.jl") +include("../src/Data Processing/pre_processing.jl") +include("../src/Consistency Checking/SwiftCC.jl") +using .TestData, .pre_processing, .SwiftCC + +fctable_seq_e_coli_core = @time distributedQFCA(myModel_e_coli_core) + +# 4P + +n = 4 +addQFCAProcs(n) + +include("TestData.jl") +include("../src/Data Processing/pre_processing.jl") +include("../src/Consistency Checking/SwiftCC.jl") +using .TestData, .pre_processing, .SwiftCC + +fctable_4P_e_coli_core = @time distributedQFCA(myModel_e_coli_core) + +removeQFCAProcs() + +# 8P + +n = 8 +addQFCAProcs(n) + +include("TestData.jl") +include("../src/Data Processing/pre_processing.jl") +include("../src/Consistency Checking/SwiftCC.jl") +using .TestData, .pre_processing, .SwiftCC + +fctable_8P_e_coli_core = @time distributedQFCA(myModel_e_coli_core) + +removeQFCAProcs() + +# Test + +@test distributedQFCATest_e_coli_core(fctable_seq_e_coli_core, fctable_4P_e_coli_core, fctable_8P_e_coli_core)