Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Performance #31

Merged
merged 6 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/ConfigFile.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1000000
1e-8
1e-6
28 changes: 9 additions & 19 deletions src/Consistency Checking/SwiftCC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ See also: `MyModel`, myModel_Constructor(), 'getTolerance()', `reversibility()`,
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)

# Calculating the dimensions of the S matrix:

row_num, col_num = size(S)
Expand Down Expand Up @@ -120,12 +116,12 @@ See also: `MyModel`, myModel_Constructor(), 'getTolerance()', `reversibility()`,

# Constructing the I_reversible Matrix:

unit_vector(i,n) = [zeros(i-1); 1 ; zeros(n-i)]
reversible_reactions_id = sort(reversible_reactions_id)
I_reversible = unit_vector(reversible_reactions_id[1], n)
for i in range(2, n_rev; step=1)
a = unit_vector(reversible_reactions_id[i], n)
I_reversible = hcat(I_reversible, a)
I_reversible = zeros(n, n_rev)

rev_id = 1
for col in eachcol(I_reversible)
col[reversible_reactions_id[rev_id]] = 1.0
rev_id = rev_id + 1
end

# Removing irrevesible blocked from I_reversible Matrix:
Expand Down Expand Up @@ -169,16 +165,10 @@ See also: `MyModel`, myModel_Constructor(), 'getTolerance()', `reversibility()`,
blocked_index = []
blocked_index = union(rev_blocked_reactions, irr_blocked_reactions)

blocked_names = []
for i in blocked_index
r_name = reactions(myModel)[i]
push!(blocked_names, r_name)
end

# Returning a list consist of the names of the blocked reactions:
# Returning a list consist of the Ids of the blocked reactions:

blocked_names = sort(blocked_names)
return blocked_names
blocked_index = sort(blocked_index)
return blocked_index
end

end
15 changes: 3 additions & 12 deletions src/Consistency Checking/TheNaiveApproach.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ function find_blocked_reactions(myModel::StandardModel)

# Determining the reversibility of a reaction:

irreversible_reactions_id = []
reversible_reactions_id = []
irreversible_reactions_id, reversible_reactions_id = reversibility(lb)

# Homogenizing the upper_bound and lower_bound of reactions:
Expand Down Expand Up @@ -140,17 +138,10 @@ function find_blocked_reactions(myModel::StandardModel)
end
end

blocked_reactions = union(reversible_blocked_reactions_id, irreversible_blocked_reactions_id)
blocked_names = []
blocked_index = union(reversible_blocked_reactions_id, irreversible_blocked_reactions_id)
blocked_index = sort(blocked_index)

for i in blocked_reactions
r_name = reactions(myModel)[i]
push!(blocked_names, r_name)
end

blocked_names = sort(blocked_names)

return blocked_names
return blocked_index

end

Expand Down
11 changes: 10 additions & 1 deletion src/Data Processing/pre_processing.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------------------

#=
Purpose: Preprocessing functions of metabolic networks
Purpose: Preprocessing functions of metabolic networks analysis
Author: Iman Ghadimi, Mojtaba Tefagh - Sharif University of Technology - Iran
Date: April 2022
=#
Expand Down Expand Up @@ -107,6 +107,8 @@ julia> S, Metabolites, Reactions, Genes, m, n, lb, ub = dataOfModel(myModel)
"""

function dataOfModel(myModel::StandardModel)

# Extracting Data:
S = stoichiometry(myModel)
Metabolites = metabolites(myModel)
Reactions = reactions(myModel)
Expand All @@ -115,6 +117,13 @@ function dataOfModel(myModel::StandardModel)
n = length(reactions(myModel))
lb = lower_bounds(myModel)
ub = upper_bounds(myModel)

# Sorting Reactions:
p = sortperm(Reactions)
Reactions = Reactions[p]
lb = lb[p]
ub = ub[p]
S = S[:,p]
return S, Metabolites, Reactions, Genes, m, n, lb, ub
end

Expand Down
18 changes: 9 additions & 9 deletions src/QFCA/distributedQFCA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ function distributedQFCA(myModel::StandardModel, removing::Bool=false)

lb, ub = homogenization(lb, ub)

# assigning a small value to Tolerance representing the level of error tolerance:

Tolerance = getTolerance()

# Creating a newly object of MyModel:

ModelObject = MyModel(S, Metabolites, Reactions, Genes, m, n, lb, ub)
Expand All @@ -165,8 +169,6 @@ function distributedQFCA(myModel::StandardModel, removing::Bool=false)

# 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:
Expand Down Expand Up @@ -233,11 +235,9 @@ function distributedQFCA(myModel::StandardModel, removing::Bool=false)
end
end

end

# Defining a matrix to save coupling relations:
# Defining a matrix to show coupling relations

fctable = zeros(col_noBlocked, col_noBlocked)
fctable = SharedArray{Int,2}((col_noBlocked, col_noBlocked), init = false)

# Directional Coupling:

Expand Down Expand Up @@ -282,7 +282,7 @@ function distributedQFCA(myModel::StandardModel, removing::Bool=false)

# Determining Partial Couples:

PC = Dict()
@everywhere PC = Dict()

s = 1
Partially_Couples = []
Expand All @@ -299,7 +299,7 @@ function distributedQFCA(myModel::StandardModel, removing::Bool=false)

# Solving a LU for each pair to determine Fully Coupling:

for key in sort(collect(keys(PC)))
@sync @distributed for key in sort(collect(keys(PC)))

# Transposing S:

Expand Down Expand Up @@ -327,7 +327,7 @@ function distributedQFCA(myModel::StandardModel, removing::Bool=false)

# Determining Fully Coupling:

if isapprox(norm(Sol), 0.0, atol = 1e-8)
if isapprox(norm(Sol), 0.0, atol = Tolerance)
fctable[PC[key][1],PC[key][2]] = 1.0
end
end
Expand Down
Loading