Skip to content

Commit

Permalink
automatic formatting
Browse files Browse the repository at this point in the history
triggered by @stelmo on PR #696
  • Loading branch information
stelmo committed Nov 9, 2022
1 parent b917671 commit 9dead6f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
10 changes: 8 additions & 2 deletions src/io/show/BalancedGrowthCommunityModel.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
function Base.show(io::Base.IO, ::MIME"text/plain", cm::CommunityMember)
println(io, "A $(typeof(cm.model)) community member with $(n_reactions(cm.model)) reactions, $(n_metabolites(cm.model)) metabolites, and abundance $(cm.abundance*100)%.")
println(
io,
"A $(typeof(cm.model)) community member with $(n_reactions(cm.model)) reactions, $(n_metabolites(cm.model)) metabolites, and abundance $(cm.abundance*100)%.",
)
end

function Base.show(io::Base.IO, ::MIME"text/plain", cm::BalancedGrowthCommunityModel)
println(io, "A balanced growth community model comprised of $(length(cm.members)) underlying models.")
println(
io,
"A balanced growth community model comprised of $(length(cm.members)) underlying models.",
)
end
3 changes: 2 additions & 1 deletion src/reconstruction/ObjectModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ function add_biomass_metabolite(

m.reactions = copy(model.reactions)
m.reactions[biomass_rxn_id] = copy(model.reactions[biomass_rxn_id])
m.reactions[biomass_rxn_id].metabolites = copy(model.reactions[biomass_rxn_id].metabolites)
m.reactions[biomass_rxn_id].metabolites =
copy(model.reactions[biomass_rxn_id].metabolites)
m.reactions[biomass_rxn_id].metabolites[biomass_metabolite_id] = 1.0

m
Expand Down
7 changes: 6 additions & 1 deletion src/types/misc/BalancedGrowthCommunityModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ $(TYPEDSIGNATURES)
A helper function to find the index of the appropriate model. Assumes each `id`
is delimited by `#` that separates the model ID prefix and the original id.
"""
function access_community_member(cm::BalancedGrowthCommunityModel, id::String, accessor::Function; default=nothing)
function access_community_member(
cm::BalancedGrowthCommunityModel,
id::String,
accessor::Function;
default = nothing,
)
id_split = split(id, "#")
idx = findfirst(startswith(first(id_split)), m.id for m in cm.members)
isnothing(idx) && return default # can only access inside community member
Expand Down
12 changes: 7 additions & 5 deletions src/types/models/BalancedGrowthCommunityModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ respective underlying [`CommunityMember`](@ref) appended as a prefix with the
delimiter `#`. The environmental metabolites have no prefix.
"""
function Accessors.metabolites(cm::BalancedGrowthCommunityModel)
mets = [add_community_prefix(m, mid) for m in cm.members for mid in metabolites(m.model)]
mets =
[add_community_prefix(m, mid) for m in cm.members for mid in metabolites(m.model)]
return [mets; "ENV_" .* get_env_mets(cm)]
end

Expand Down Expand Up @@ -256,14 +257,14 @@ Return the semantically meaningful reactions of the model.
Accessors.n_fluxes(cm::BalancedGrowthCommunityModel) =
sum(n_fluxes(m.model) for m in cm.members) + length(get_env_mets(cm)) + 1

#=
#=
This loops implements the rest of the accssors through access_community_member.
Since most of the environmental reactions are generated programmtically, they
will not have things like annotations etc. For this reason, these methods will
only work if they access something inside the community members.
only work if they access something inside the community members.
=#
for (func, def) in (
(:reaction_gene_association, nothing),
(:reaction_gene_association, nothing),
(:reaction_subsystem, nothing),
(:reaction_stoichiometry, nothing),
(:metabolite_formula, nothing),
Expand All @@ -280,6 +281,7 @@ for (func, def) in (
(:gene_name, nothing),
)
@eval begin # TODO add docstrings somehow
Accessors.$func(cm::BalancedGrowthCommunityModel, id::String) = access_community_member(cm, id, $func; default=$def)
Accessors.$func(cm::BalancedGrowthCommunityModel, id::String) =
access_community_member(cm, id, $func; default = $def)
end
end
5 changes: 1 addition & 4 deletions test/types/BalancedGrowthCommunityModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@
members = [cm1, cm2],
env_met_flux_bounds = Dict("Ae" => (-10, 10)),
)
@test contains(
sprint(show, MIME("text/plain"), cm),
"balanced growth",
)
@test contains(sprint(show, MIME("text/plain"), cm), "balanced growth")

@test issetequal(
reactions(cm),
Expand Down

0 comments on commit 9dead6f

Please sign in to comment.