From d7384cf2609e5a8dfa13a4c86e82f531001b3d9c Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 11:24:45 +0330 Subject: [PATCH 1/7] Adding MyModel struct and Editng functions to be compatible with distributedQFCA --- src/pre_processing.jl | 85 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/src/pre_processing.jl b/src/pre_processing.jl index 1339c75..a967c41 100644 --- a/src/pre_processing.jl +++ b/src/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 = [] From f4ed170e400a16be124053430e116774e8a7969d Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 11:37:56 +0330 Subject: [PATCH 2/7] Editing swiftCC to be compatible with MyModel struct and distributedQFCA --- src/Consistency Checking/SwiftCC.jl | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Consistency Checking/SwiftCC.jl b/src/Consistency Checking/SwiftCC.jl index 8544d04..b8a4b61 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 + +@everywhere using GLPK, JuMP, COBREXA, LinearAlgebra, SparseArrays include("../pre_processing.jl") using .pre_processing - """ - swiftCC(myModel) + swiftCC(ModelObject) Function that finds blocked reactions in 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: From 4bc6d56711753027db42fd9bf55547f432bf006e Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 11:48:46 +0330 Subject: [PATCH 3/7] Adding QFCA and Data Processing folders --- src/{ => Data Processing}/pre_processing.jl | 0 src/{ => QFCA}/sparseQFCA.jl | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/{ => Data Processing}/pre_processing.jl (100%) rename src/{ => QFCA}/sparseQFCA.jl (100%) diff --git a/src/pre_processing.jl b/src/Data Processing/pre_processing.jl similarity index 100% rename from src/pre_processing.jl rename to src/Data Processing/pre_processing.jl diff --git a/src/sparseQFCA.jl b/src/QFCA/sparseQFCA.jl similarity index 100% rename from src/sparseQFCA.jl rename to src/QFCA/sparseQFCA.jl From 7ad757e45a9bf80a407560310007c699f687ae4c Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 12:33:46 +0330 Subject: [PATCH 4/7] Adding distributedQFCA --- src/Consistency Checking/SwiftCC.jl | 4 +- src/QFCA/distributedQFCA.jl | 221 ++++++++++++++++++++++++++++ 2 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 src/QFCA/distributedQFCA.jl diff --git a/src/Consistency Checking/SwiftCC.jl b/src/Consistency Checking/SwiftCC.jl index b8a4b61..3c79f64 100644 --- a/src/Consistency Checking/SwiftCC.jl +++ b/src/Consistency Checking/SwiftCC.jl @@ -15,14 +15,14 @@ using Distributed @everywhere using GLPK, JuMP, COBREXA, LinearAlgebra, SparseArrays -include("../pre_processing.jl") +include("../Data Processing/pre_processing.jl") using .pre_processing """ swiftCC(ModelObject) -Function that finds blocked reactions in metabolic network. +Function that finds blocked reactions for a metabolic network. # INPUTS diff --git a/src/QFCA/distributedQFCA.jl b/src/QFCA/distributedQFCA.jl new file mode 100644 index 0000000..a9b9986 --- /dev/null +++ b/src/QFCA/distributedQFCA.jl @@ -0,0 +1,221 @@ +#------------------------------------------------------------------------------------------- + +#= + 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 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 + +""" + distributedQFCA(myModel) + +Function 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 QFCA(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 From 25c4051516c6b6bdb26071acbc5a1923b58a9086 Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 12:53:58 +0330 Subject: [PATCH 5/7] Adding two functions to create and remove procs to DistributedQFCA --- src/QFCA/distributedQFCA.jl | 76 +++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/src/QFCA/distributedQFCA.jl b/src/QFCA/distributedQFCA.jl index a9b9986..0f064bd 100644 --- a/src/QFCA/distributedQFCA.jl +++ b/src/QFCA/distributedQFCA.jl @@ -9,7 +9,7 @@ #------------------------------------------------------------------------------------------- module DistributedQFCA -export distributedQFCA +export addQFCAProcs, removeQFCAProcs, distributedQFCA using Distributed @@ -23,10 +23,79 @@ 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 computes the table of flux coupling relations for a metabolic network. +Function that computes the table of flux coupling relations for a metabolic network. # INPUTS @@ -57,8 +126,7 @@ See also: `dataOfModel()`, `reversibility()`, `homogenization()`, `MyModel`, `my """ - -function QFCA(myModel) +function distributedQFCA(myModel) # Exporting data from StandardModel: From 32122bc931ced1357cef18013e409f19f36b277e Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 13:21:19 +0330 Subject: [PATCH 6/7] Testing distributedQFCA --- test/Models/e_coli_core.xml | 9898 ++++++++++++++++++++ test/{find_blocked_data.jl => TestData.jl} | 8 +- test/ecoli.jl | 2 +- test/runtests.jl | 49 +- 4 files changed, 9950 insertions(+), 7 deletions(-) create mode 100644 test/Models/e_coli_core.xml rename test/{find_blocked_data.jl => TestData.jl} (59%) 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) From 8e65e66eea9b88de4a281c53a2e46a038e45b90d Mon Sep 17 00:00:00 2001 From: iManGHD Date: Fri, 21 Oct 2022 13:35:45 +0330 Subject: [PATCH 7/7] Updating directories --- src/{QFCA => }/sparseQFCA.jl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{QFCA => }/sparseQFCA.jl (100%) diff --git a/src/QFCA/sparseQFCA.jl b/src/sparseQFCA.jl similarity index 100% rename from src/QFCA/sparseQFCA.jl rename to src/sparseQFCA.jl