From 300b4b9ceae587bcef2b9f44eba1f47b519732cb Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Mon, 14 Aug 2023 01:15:34 +0000 Subject: [PATCH 01/11] CompatHelper: bump compat for PikaParser to 0.6, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ee3a4ea68..da8d53afb 100644 --- a/Project.toml +++ b/Project.toml @@ -33,7 +33,7 @@ JuMP = "1" MAT = "0.10" MacroTools = "0.5.6" OrderedCollections = "1.4" -PikaParser = "0.5" +PikaParser = "0.5, 0.6" SBML = "~1.3, ~1.4" StableRNGs = "1.0" Tulip = "0.7.0, 0.8.0, 0.9.2" From e6e60a4f7574a72d1c4c08cbc3bd28742c099925 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 31 Aug 2023 01:15:33 +0000 Subject: [PATCH 02/11] CompatHelper: bump compat for SBML to 1, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index da8d53afb..87453a5bf 100644 --- a/Project.toml +++ b/Project.toml @@ -34,7 +34,7 @@ MAT = "0.10" MacroTools = "0.5.6" OrderedCollections = "1.4" PikaParser = "0.5, 0.6" -SBML = "~1.3, ~1.4" +SBML = "~1.3, ~1.4, 1" StableRNGs = "1.0" Tulip = "0.7.0, 0.8.0, 0.9.2" julia = "1.5" From 2c91b6625ade9059370085ce5a6aa1fe2c92e215 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 7 Sep 2023 01:19:25 +0000 Subject: [PATCH 03/11] CompatHelper: bump compat for HDF5 to 0.17, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index da8d53afb..5243df4b6 100644 --- a/Project.toml +++ b/Project.toml @@ -27,7 +27,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Clarabel = "0.3" DistributedData = "0.1.4, 0.2" DocStringExtensions = "0.8, 0.9" -HDF5 = "0.16" +HDF5 = "0.16, 0.17" JSON = "0.21" JuMP = "1" MAT = "0.10" From a264175952d6f02e9774f01b6f9113dcbfc90c03 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Mon, 11 Sep 2023 09:11:17 +0200 Subject: [PATCH 04/11] keep SBML.jl bound to minor versions --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 87453a5bf..34e05ff9a 100644 --- a/Project.toml +++ b/Project.toml @@ -34,7 +34,7 @@ MAT = "0.10" MacroTools = "0.5.6" OrderedCollections = "1.4" PikaParser = "0.5, 0.6" -SBML = "~1.3, ~1.4, 1" +SBML = "~1.3, ~1.4, ~1.5" StableRNGs = "1.0" Tulip = "0.7.0, 0.8.0, 0.9.2" julia = "1.5" From 9887ca2af7a9e4aad24552ce0e17bb82b6b47ad8 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Sun, 29 Oct 2023 01:21:31 +0000 Subject: [PATCH 05/11] CompatHelper: add new compat entry for Statistics at version 1, (keep existing compat) --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 115eeb022..5fba32d38 100644 --- a/Project.toml +++ b/Project.toml @@ -36,6 +36,7 @@ OrderedCollections = "1.4" PikaParser = "0.5, 0.6" SBML = "~1.3, ~1.4, ~1.5" StableRNGs = "1.0" +Statistics = "1" Tulip = "0.7.0, 0.8.0, 0.9.2" julia = "1.5" From 2f6f7044ee8be3c5e4928bf2b15a9a0ddbb2cae0 Mon Sep 17 00:00:00 2001 From: Jose Antonio Pereiro Morejon <44244693+josePereiro@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:23:40 -0500 Subject: [PATCH 06/11] Add `dflt` option argument --- src/base/types/abstract/Maybe.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/types/abstract/Maybe.jl b/src/base/types/abstract/Maybe.jl index 7b5df0a39..4f00527dd 100644 --- a/src/base/types/abstract/Maybe.jl +++ b/src/base/types/abstract/Maybe.jl @@ -18,8 +18,8 @@ end """ $(TYPEDSIGNATURES) -Apply a function to `x` only if it is not `nothing`. +Apply a function to `x` only if it is not `nothing`. Returns `f(x)` when applied, otherwise returns `dflt`. """ -function _maybemap(f, x::Maybe)::Maybe - isnothing(x) ? nothing : f(x) +function _maybemap(f, x::Maybe, dflt = nothing)::Maybe + isnothing(x) ? dflt : f(x) end From 9c00f9f2655cfd3e44be246a32c84f4f97a48b1f Mon Sep 17 00:00:00 2001 From: Jose Antonio Pereiro Morejon <44244693+josePereiro@users.noreply.github.com> Date: Sun, 11 Feb 2024 09:27:32 -0500 Subject: [PATCH 07/11] Add defaults to accessors To avoid that missing data crash conversions --- src/base/types/JSONModel.jl | 38 +++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/base/types/JSONModel.jl b/src/base/types/JSONModel.jl index 03ab30a5d..4c66cb05c 100644 --- a/src/base/types/JSONModel.jl +++ b/src/base/types/JSONModel.jl @@ -62,8 +62,10 @@ JSONModel(json::Dict{String,Any}) = begin end function _parse_annotations(x)::Annotations - Annotations([k => if typeof(v) == String + Annotations([k => if v isa String [v] + elseif v isa AbstractDict + string.(collect(v)) else convert(Vector{String}, v) end for (k, v) in x]) @@ -161,6 +163,7 @@ Parses the `.gene_reaction_rule` from reactions. reaction_gene_association(model::JSONModel, rid::String) = _maybemap( _parse_grr, get(model.rxns[model.rxn_index[rid]], "gene_reaction_rule", nothing), + nothing ) """ @@ -176,8 +179,11 @@ $(TYPEDSIGNATURES) Parse and return the metabolite `.formula` """ -metabolite_formula(model::JSONModel, mid::String) = - _maybemap(_parse_formula, get(model.mets[model.met_index[mid]], "formula", nothing)) +metabolite_formula(model::JSONModel, mid::String) = _maybemap( + _parse_formula, + get(model.mets[model.met_index[mid]], "formula", nothing), + nothing +) """ $(TYPEDSIGNATURES) @@ -203,6 +209,7 @@ Gene annotations from the [`JSONModel`](@ref). gene_annotations(model::JSONModel, gid::String)::Annotations = _maybemap( _parse_annotations, get(model.genes[model.gene_index[gid]], "annotation", nothing), + Annotations() ) """ @@ -210,8 +217,11 @@ $(TYPEDSIGNATURES) Gene notes from the [`JSONModel`](@ref). """ -gene_notes(model::JSONModel, gid::String)::Notes = - _maybemap(_parse_notes, get(model.genes[model.gene_index[gid]], "notes", nothing)) +gene_notes(model::JSONModel, gid::String)::Notes = _maybemap( + _parse_notes, + get(model.genes[model.gene_index[gid]], "notes", nothing), + Notes() +) """ $(TYPEDSIGNATURES) @@ -221,6 +231,7 @@ Reaction annotations from the [`JSONModel`](@ref). reaction_annotations(model::JSONModel, rid::String)::Annotations = _maybemap( _parse_annotations, get(model.rxns[model.rxn_index[rid]], "annotation", nothing), + Annotations() ) """ @@ -228,8 +239,11 @@ $(TYPEDSIGNATURES) Reaction notes from the [`JSONModel`](@ref). """ -reaction_notes(model::JSONModel, rid::String)::Notes = - _maybemap(_parse_notes, get(model.rxns[model.rxn_index[rid]], "notes", nothing)) +reaction_notes(model::JSONModel, rid::String)::Notes = _maybemap( + _parse_notes, + get(model.rxns[model.rxn_index[rid]], "notes", nothing), + Notes() +) """ $(TYPEDSIGNATURES) @@ -239,6 +253,7 @@ Metabolite annotations from the [`JSONModel`](@ref). metabolite_annotations(model::JSONModel, mid::String)::Annotations = _maybemap( _parse_annotations, get(model.mets[model.met_index[mid]], "annotation", nothing), + Annotations() ) """ @@ -246,15 +261,18 @@ $(TYPEDSIGNATURES) Metabolite notes from the [`JSONModel`](@ref). """ -metabolite_notes(model::JSONModel, mid::String)::Notes = - _maybemap(_parse_notes, get(model.mets[model.met_index[mid]], "notes", nothing)) +metabolite_notes(model::JSONModel, mid::String)::Notes = _maybemap( + _parse_notes, + get(model.mets[model.met_index[mid]], "notes", nothing), + Notes() +) """ $(TYPEDSIGNATURES) Return the stoichiometry of reaction with ID `rid`. """ -reaction_stoichiometry(model::JSONModel, rid::String)::Dict{String,Float64} = +reaction_stoichiometry(model::JSONModel, rid::String)::Dict{String, Float64} = model.rxns[model.rxn_index[rid]]["metabolites"] """ From 2c9ed882f671cac0a35c98026c6d9aab436b17d4 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 2 Mar 2024 14:13:14 +0100 Subject: [PATCH 08/11] apply formatting --- src/base/types/JSONModel.jl | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/base/types/JSONModel.jl b/src/base/types/JSONModel.jl index 4c66cb05c..1d9e4343e 100644 --- a/src/base/types/JSONModel.jl +++ b/src/base/types/JSONModel.jl @@ -163,7 +163,7 @@ Parses the `.gene_reaction_rule` from reactions. reaction_gene_association(model::JSONModel, rid::String) = _maybemap( _parse_grr, get(model.rxns[model.rxn_index[rid]], "gene_reaction_rule", nothing), - nothing + nothing, ) """ @@ -180,9 +180,9 @@ $(TYPEDSIGNATURES) Parse and return the metabolite `.formula` """ metabolite_formula(model::JSONModel, mid::String) = _maybemap( - _parse_formula, + _parse_formula, get(model.mets[model.met_index[mid]], "formula", nothing), - nothing + nothing, ) """ @@ -209,7 +209,7 @@ Gene annotations from the [`JSONModel`](@ref). gene_annotations(model::JSONModel, gid::String)::Annotations = _maybemap( _parse_annotations, get(model.genes[model.gene_index[gid]], "annotation", nothing), - Annotations() + Annotations(), ) """ @@ -218,9 +218,9 @@ $(TYPEDSIGNATURES) Gene notes from the [`JSONModel`](@ref). """ gene_notes(model::JSONModel, gid::String)::Notes = _maybemap( - _parse_notes, + _parse_notes, get(model.genes[model.gene_index[gid]], "notes", nothing), - Notes() + Notes(), ) """ @@ -231,7 +231,7 @@ Reaction annotations from the [`JSONModel`](@ref). reaction_annotations(model::JSONModel, rid::String)::Annotations = _maybemap( _parse_annotations, get(model.rxns[model.rxn_index[rid]], "annotation", nothing), - Annotations() + Annotations(), ) """ @@ -240,9 +240,9 @@ $(TYPEDSIGNATURES) Reaction notes from the [`JSONModel`](@ref). """ reaction_notes(model::JSONModel, rid::String)::Notes = _maybemap( - _parse_notes, - get(model.rxns[model.rxn_index[rid]], "notes", nothing), - Notes() + _parse_notes, + get(model.rxns[model.rxn_index[rid]], "notes", nothing), + Notes(), ) """ @@ -253,7 +253,7 @@ Metabolite annotations from the [`JSONModel`](@ref). metabolite_annotations(model::JSONModel, mid::String)::Annotations = _maybemap( _parse_annotations, get(model.mets[model.met_index[mid]], "annotation", nothing), - Annotations() + Annotations(), ) """ @@ -262,9 +262,9 @@ $(TYPEDSIGNATURES) Metabolite notes from the [`JSONModel`](@ref). """ metabolite_notes(model::JSONModel, mid::String)::Notes = _maybemap( - _parse_notes, + _parse_notes, get(model.mets[model.met_index[mid]], "notes", nothing), - Notes() + Notes(), ) """ @@ -272,7 +272,7 @@ $(TYPEDSIGNATURES) Return the stoichiometry of reaction with ID `rid`. """ -reaction_stoichiometry(model::JSONModel, rid::String)::Dict{String, Float64} = +reaction_stoichiometry(model::JSONModel, rid::String)::Dict{String,Float64} = model.rxns[model.rxn_index[rid]]["metabolites"] """ From 83b81de52c6a5af065e310fa7102421a48898ca6 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 2 Mar 2024 14:20:20 +0100 Subject: [PATCH 09/11] bump version for later release --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a854e547c..7357157b2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "COBREXA" uuid = "babc4406-5200-4a30-9033-bf5ae714c842" authors = ["The developers of COBREXA.jl"] -version = "1.5.1" +version = "1.5.2" [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" From f7b9e8f6d7f19ea11138a11b7c55ae12fa597cd7 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 2 Mar 2024 17:41:01 +0100 Subject: [PATCH 10/11] minor style changes `dflt` somehow triggers `deflate` in my brain instead of `default` :D --- src/base/types/abstract/Maybe.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/base/types/abstract/Maybe.jl b/src/base/types/abstract/Maybe.jl index 4f00527dd..c861a2af1 100644 --- a/src/base/types/abstract/Maybe.jl +++ b/src/base/types/abstract/Maybe.jl @@ -18,8 +18,9 @@ end """ $(TYPEDSIGNATURES) -Apply a function to `x` only if it is not `nothing`. Returns `f(x)` when applied, otherwise returns `dflt`. +Apply a function to `x` only if it is not `nothing`. Returns `f(x)` when +applied, otherwise returns `default`. """ -function _maybemap(f, x::Maybe, dflt = nothing)::Maybe - isnothing(x) ? dflt : f(x) +function _maybemap(f, x::Maybe, default = nothing)::Maybe + isnothing(x) ? default : f(x) end From 50f6ffa21f189b37faed1ad01ded793c3f558764 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Tue, 23 Apr 2024 09:50:01 +0200 Subject: [PATCH 11/11] add some extra symbols to GRR parsing --- src/base/utils/gene_associations.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/base/utils/gene_associations.jl b/src/base/utils/gene_associations.jl index de4532eaf..f61f6520a 100644 --- a/src/base/utils/gene_associations.jl +++ b/src/base/utils/gene_associations.jl @@ -95,6 +95,8 @@ const _grr_grammar = begin x == '-' || x == ':' || x == '.' || + x == '@' || + x == '#' || x == '\'' || x == '[' || x == ']' ||