Unverified Commit 7d61877b authored by St. Elmo's avatar St. Elmo
Browse files

added reviews

parent 86d2f860
...@@ -81,12 +81,12 @@ community = add_model(community, model, exchange_rxn_ids, exchange_met_ids; spec ...@@ -81,12 +81,12 @@ community = add_model(community, model, exchange_rxn_ids, exchange_met_ids; spec
""" """
function add_model( function add_model(
community::CoreModel, community::CoreModel,
model::M, model::MetabolicModel,
exchange_rxn_ids::Vector{String}, exchange_rxn_ids::Vector{String},
exchange_met_ids::Vector{String}; exchange_met_ids::Vector{String};
species_name = "", species_name="unknown_species",
biomass_id = "", biomass_id=nothing,
) where {M<:MetabolicModel} )::CoreModel
exchange_met_community_inds = indexin(exchange_met_ids, metabolites(community)) exchange_met_community_inds = indexin(exchange_met_ids, metabolites(community))
exchange_rxn_community_inds = indexin(exchange_rxn_ids, reactions(community)) exchange_rxn_community_inds = indexin(exchange_rxn_ids, reactions(community))
...@@ -148,7 +148,7 @@ function add_model( ...@@ -148,7 +148,7 @@ function add_model(
ubs = [ubs; ubsadd] ubs = [ubs; ubsadd]
rxnsadd = "$(species_name)_" .* reactions(model) rxnsadd = "$(species_name)_" .* reactions(model)
if biomass_id != "" if !isnothing(biomass_id)
metsadd = metsadd =
["$(species_name)_" .* metabolites(model); "$(species_name)_" * biomass_id] ["$(species_name)_" .* metabolites(model); "$(species_name)_" * biomass_id]
else else
...@@ -219,7 +219,7 @@ reaction in the community model, if desired. Refer to the tutorial if this is ...@@ -219,7 +219,7 @@ reaction in the community model, if desired. Refer to the tutorial if this is
unclear. unclear.
# Example # Example
```jldoctest; output = false ```
m1 = load_model(core_model_path) m1 = load_model(core_model_path)
m2 = load_model(CoreModel, core_model_path) m2 = load_model(CoreModel, core_model_path)
...@@ -236,24 +236,6 @@ community = join_with_exchanges( ...@@ -236,24 +236,6 @@ community = join_with_exchanges(
add_biomass_objective = true, add_biomass_objective = true,
biomass_ids = biomass_ids, biomass_ids = biomass_ids,
) )
# output
Metabolic model of type CoreModel
⠤⡤⣤⣼⢤⣤⠀⢘⡄⢤⡼⢷⣦⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢸⣘⢀⢛⣠⠘⠀⠀⢡⠀⠻⠒⢛⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢚⢛⢙⢹⡨⢌⡀⠀⠰⠹⠚⢈⠒⠔⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣭⣨⣦⣯⠕⢺⢌⠀⠀⠒⢠⣀⠃⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡶⠘⠉⠻⠃⡶⠮⡀⠀⢦⡀⠈⠊⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠈⠀⠀⠈⠀⠈⠁⠁⠀⠁⠉⠀⠀⢀⣄⣠⣤⣦⣤⡀⠀⢆⠠⣠⣲⣦⣀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢔⠂⠐⠆⣁⠆⠀⠈⡄⠸⠶⠾⠻⡂⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠛⠜⠗⣏⣬⢂⠀⠀⠲⡼⠗⡡⢥⠄⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢐⣘⣥⣱⡲⠒⡯⡁⠀⠐⠂⣀⢐⠀⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠕⠍⠙⠟⠠⠷⢢⠀⢰⡠⠉⠙⠉⠃⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠲⣄⠀⠀⠀⠀⠀⠀⠂⠀⠀⠃⠈⠙⢮⡀⠈⠙⠃⠀⠀⠲⣄⠀⠀
⠀⠀⠀⢀⠀⠀⠀⠈⠳⠄⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠙⠦⠀⠀⠀⠀⠀⠈⠳⠄
Number of reactions: 211
Number of metabolites: 166
``` ```
""" """
function join_with_exchanges( function join_with_exchanges(
......
...@@ -4,12 +4,8 @@ ex = quote ...@@ -4,12 +4,8 @@ ex = quote
using COBREXA, Tulip using COBREXA, Tulip
include(joinpath(dirname(pathof(COBREXA)), "..", "test", "data_static.jl")) include(joinpath(dirname(pathof(COBREXA)), "..", "test", "data_static.jl"))
model = test_LP() model = test_LP()
core_model_path = include(joinpath(dirname(pathof(COBREXA)), "..", "test", "test_functions.jl")) # expose functions for downloading
joinpath(dirname(pathof(COBREXA)), "..", "test", "data", "e_coli_core.json") include(joinpath(dirname(pathof(COBREXA)), "..", "test", "doctest_models.jl"))
Downloads.download(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
core_model_path,
)
end end
# set module-level metadata # set module-level metadata
......
core_path = download_data_file(
"http://bigg.ucsd.edu/static/models/e_coli_core.json",
joinpath("data", "e_coli_core.json"),
"7bedec10576cfe935b19218dc881f3fb14f890a1871448fc19a9b4ee15b448d8",
)
function run_test_file(path...)
fn = joinpath(path...)
t = @elapsed include(fn)
@info "$(fn) done in $(round(t; digits = 2))s"
end
function run_test_dir(dir, comment = "Directory $dir/")
@testset "$comment" begin
run_test_file.(joinpath.(dir, filter(fn -> endswith(fn, ".jl"), readdir(dir))))
end
end
function check_data_file_hash(path, expected_checksum)
actual_checksum = bytes2hex(sha256(open(path)))
if actual_checksum != expected_checksum
@error "The downloaded data file `$path' seems to be different from the expected one. Tests will likely fail." actual_checksum expected_checksum
end
end
function download_data_file(url, path, hash)
if isfile(path)
check_data_file_hash(path, hash)
@info "using cached `$path'"
return path
end
Downloads.download(url, path)
check_data_file_hash(path, hash)
return path
end
Supports Markdown
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