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

Extend community model #696

Merged
merged 7 commits into from
Nov 11, 2022
Merged

Extend community model #696

merged 7 commits into from
Nov 11, 2022

Conversation

stelmo
Copy link
Collaborator

@stelmo stelmo commented Nov 4, 2022

Currently our community model framework is rather fragile. Let's extend it to:

  • Create a community model type
  • List the joined metabolites and exchange reactions sensibly
  • Make it extensible, so any model type can be joined into a community

@stelmo stelmo mentioned this pull request Nov 4, 2022
@stelmo
Copy link
Collaborator Author

stelmo commented Nov 9, 2022

/format

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

✔️ Auto-formatting triggered by this comment succeeded, commited as b439fc8

github-actions bot pushed a commit that referenced this pull request Nov 9, 2022
triggered by @stelmo on PR #696
src/io/show/Communities.jl Outdated Show resolved Hide resolved
test/types/temp_comm.jl Outdated Show resolved Hide resolved
@stelmo
Copy link
Collaborator Author

stelmo commented Nov 9, 2022

/format

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

✔️ Auto-formatting triggered by this comment succeeded, commited as 0b51955

github-actions bot pushed a commit that referenced this pull request Nov 9, 2022
triggered by @stelmo on PR #696
test/types/temp_comm.jl Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 9, 2022

Codecov Report

Base: 90.21% // Head: 89.93% // Decreases project coverage by -0.28% ⚠️

Coverage data is based on head (9dead6f) compared to base (8c04d42).
Patch coverage: 98.90% of modified lines in pull request are covered.

❗ Current head 9dead6f differs from pull request most recent head 4a85fde. Consider uploading reports for the commit 4a85fde to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             next     #696      +/-   ##
==========================================
- Coverage   90.21%   89.93%   -0.29%     
==========================================
  Files          82       84       +2     
  Lines        2106     1977     -129     
==========================================
- Hits         1900     1778     -122     
+ Misses        206      199       -7     
Impacted Files Coverage Δ
src/types/models/BalancedGrowthCommunityModel.jl 98.18% <98.18%> (ø)
src/io/show/BalancedGrowthCommunityModel.jl 100.00% <100.00%> (ø)
src/reconstruction/ObjectModel.jl 98.90% <100.00%> (+0.16%) ⬆️
src/reconstruction/modifications/generic.jl 40.00% <100.00%> (+15.00%) ⬆️
src/types/misc/BalancedGrowthCommunityModel.jl 100.00% <100.00%> (ø)
src/types/accessors/AbstractMetabolicModel.jl 86.15% <0.00%> (-3.08%) ⬇️
src/types/wrappers/GeckoModel.jl 97.22% <0.00%> (+5.55%) ⬆️
src/utils/looks_like.jl 44.44% <0.00%> (+11.11%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@stelmo
Copy link
Collaborator Author

stelmo commented Nov 9, 2022

/format

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

✔️ Auto-formatting triggered by this comment succeeded, commited as 9dead6f

github-actions bot pushed a commit that referenced this pull request Nov 9, 2022
triggered by @stelmo on PR #696
Copy link
Collaborator

@exaexa exaexa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in, I added some TODOs for myself for later.

(I'll convert them to issues)

test/types/temp_comm.jl Outdated Show resolved Hide resolved
@@ -0,0 +1,333 @@
@testset "BalancedGrowthCommunityModel: simple model" begin
m1 = ObjectModel(id = "Model1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you technically reuse some of the models in data_static ? (possibly just adding a few genes to them?)

A helper function to get the unique environmental metabolites.
"""
get_env_mets(cm::BalancedGrowthCommunityModel) =
unique(hcat([get_exchange_mets(m) for m in cm.members]...))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_env_mets is pretty slow and it's repeated everywhere, it might be much better to cache the result in the model structure directly

appended as a prefix with the delimiter `#`.
"""
Accessors.genes(cm::BalancedGrowthCommunityModel) =
[m.id * "#" * gid for m in cm.members for gid in genes(m.model)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[m.id * "#" * gid for m in cm.members for gid in genes(m.model)]
["$(m.id)#$gid" for m in cm.members for gid in genes(m.model)]

delimiter `#`. The environmental metabolites have no prefix.
"""
function Accessors.metabolites(cm::BalancedGrowthCommunityModel)
mets = [m.id * "#" * mid for m in cm.members for mid in metabolites(m.model)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mets = [m.id * "#" * mid for m in cm.members for mid in metabolites(m.model)]
mets = ["$(m.id)#$mid" for m in cm.members for mid in metabolites(m.model)]

io,
"A balanced growth community model comprised of $(length(cm.members)) underlying models.",
)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't very useful, I guess the generic show will suffice for now. I'll eventually make a bigger PR with MultiModelWrapper that fixes this forever

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as in, pls remove the custom shows here)

"""
Base.@kwdef mutable struct CommunityMember
"Name of model appended to intracellular reactions and metabolites."
id::String
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for myself, for later:
id should be outside of the community member, making the members a dict.

"List of all exchange reactions in model."
exchange_reaction_ids::Vector{String}
"ID of biomass metabolite."
biomass_metabolite_id::String
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for myself later: biomass balancing is a function of the class that provides the balance, so the metabolite (= equality constraint) should be created externally, not by the community member.

@exaexa exaexa merged commit ca12017 into next Nov 11, 2022
@exaexa exaexa deleted the mo-community branch November 11, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add_model_with_exchanges produces an invalid model
3 participants