Commit bb1a48a4 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil Committed by Miroslav Kratochvil
Browse files

[WIP] DistributedData FVA

parent 52246334
......@@ -7,6 +7,7 @@ version = "0.1.0"
Clp = "e2554f3b-3117-50c0-817c-e040a3ddf72d"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
DistributedData = "f6a0035f-c5ac-4ad0-b410-ad102ced35df"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
......
......@@ -8,6 +8,7 @@ using JuMP
using MAT
using Distributed
using SBML
using DistributedData
import Pkg
# import src files
......@@ -45,8 +46,8 @@ export speye, LinearModel, nReactions, nMetabolites, nCouplingConstraints,
removeCouplingConstraints!, removeCouplingConstraints,
changeCouplingBounds!, changeCouplingBounds,
verifyConsistency, findExchangeReactions, findExchangeMetabolites,
solveLP, loadModel, loadSBMLModel, writeModel,
fluxBalanceAnalysis, fluxVariabilityAnalysis, parFVA,
solveLP, loadModel, loadSBMLmodel, writeModel,
fluxBalanceAnalysis, fluxVariabilityAnalysis, parFVA, parFVA2,
convertToExportable, createParPool
end
......@@ -87,3 +87,34 @@ function allocateReacs(reactions::Array{Int64, 1}, nWorkers::Int)
return allocatedReacs
end
function parFVA2(model::LinearModel, reactions::Vector{Int}, optimizer, workers)
if any(reactions .> length(model.rxns))
throw(ArgumentError("reactions contain an out-of-bounds index"))
end
γ = 1.
fluxes = zeros(length(reactions), 2)
(optimization_model, x₀) = fluxBalanceAnalysis(model::LinearModel, optimizer)
Z₀ = JuMP.objective_value(optimization_model)
x = JuMP.all_variables(optimization_model)
@constraint(optimization_model, model.c' * x γ * Z₀)
fetch.([save_at(w, :cobrexa_parfva_model, optimization_model) for w in workers])
fluxes = vcat(dpmap(reactions, rid -> :(begin
var = JuMP.all_variables(cobrexa_parfva_model)[$rid]
@objective(cobrexa_parfva_model, MOI.MIN_SENSE, var)
JuMP.optimize!(cobrexa_parfva_model)
min_flux = JuMP.objective_value(cobrexa_parfva_model)
@objective(cobrexa_parfva_model, MOI.MIN_SENSE, var)
JuMP.optimize!(cobrexa_parfva_model)
max_flux = JuMP.objective_value(cobrexa_parfva_model)
[min_flux max_flux]
end), workers)...)
fetch.([remove_from(w, :cobrexa_parfva_model) for w in workers])
return fluxes
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment