Monomer counts update merge#415
Conversation
…ified_proteins.tsv raw data file correctly.
…le IDs in get_monomer_counts_listener_config().
…ep to accurately account for monomers within complexes and unique molecules.
🔍 Vulnerabilities of
|
| digest | sha256:315ea9cbea98728fb51ebd747faaf2588a0f6016a688d433c830f3160f3b7fab |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 959 MB |
| packages | 905 |
📦 Base Image debian:13-slim
| also known as |
|
| digest | sha256:e18da95f66066b7c5fa31491b524e83121271eca59a3d140f4906c8d0a090367 |
| vulnerabilities |
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
|
There was a problem hiding this comment.
Pull request overview
This PR fixes protein monomer counting in the simulation listener by ensuring nested complex types (TCS, equilibrium, unique-molecule complexes, complexation) are unpacked in an order that fully decomposes to base monomers. It also extends monomer counting to include promoter-bound transcription factors and updates TCS reconstruction logic to better align the modeled molecule pool with modified-protein definitions.
Changes:
- Reorders complex “unpacking” in
monomer_counts.pyand adds promoter-bound TFs into the monomer counting pipeline. - Updates TCS reconstruction to build a complex→monomer mapping with compartment-tag correction and expands the TCS molecule list to include additional modified-protein-derived monomers.
- Updates monomer-counts listener config to use the expanded TCS molecule list and to pass TF IDs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
reconstruction/ecoli/dataclasses/process/two_component_system.py |
Builds/extends TCS complex→monomer mapping and exposes an expanded molecule list for monomer stoich mapping. |
ecoli/processes/listeners/monomer_counts.py |
Reorders unpacking steps and includes promoter-bound TFs in monomer counts. |
ecoli/library/sim_data.py |
Wires listener config to new TCS molecule list and TF IDs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| n_bound_TFs = attrs(states["promoters"], ["bound_TF"]) | ||
|
|
||
| # Account for monomers in bulk molecule complexes | ||
| complex_monomer_counts = np.dot( | ||
| self.complexation_stoich, | ||
| np.negative(bulkMoleculeCounts[self.complexation_complex_idx]), | ||
| # Calculate the counts of subunits in active unique molecule complexes: | ||
| n_ribosome_subunit = n_active_ribosome * self.ribosome_stoich | ||
| n_rnap_subunit = n_active_rnap * self.rnap_stoich | ||
| n_replisome_subunit = n_active_replisome * self.replisome_stoich | ||
| n_bound_TF_subunit = np.array(n_bound_TFs).astype(np.int32).sum(axis=(0, 1)) | ||
|
|
||
| # Add the counts of all active unique molecule complex subunits to the | ||
| # free counts of each "inactive" subunit in the bulk (note this must | ||
| # happen before the bulk molecule complexes are unpacked, as some of | ||
| # these subunits are bulk molecule complexes): | ||
| bulkMoleculeCounts[self.ribosome_subunit_idx] += n_ribosome_subunit.astype( | ||
| np.int32 | ||
| ) | ||
| equilibrium_monomer_counts = np.dot( | ||
| self.equilibrium_stoich, | ||
| np.negative(bulkMoleculeCounts[self.equilibrium_complex_idx]), | ||
| bulkMoleculeCounts[self.rnap_subunit_idx] += n_rnap_subunit.astype(np.int32) | ||
| bulkMoleculeCounts[self.replisome_subunit_idx] += n_replisome_subunit.astype( | ||
| np.int32 | ||
| ) | ||
| bulkMoleculeCounts[self.tf_subunit_idx] += n_bound_TF_subunit.astype(np.int32) |
thalassemia
left a comment
There was a problem hiding this comment.
Thanks for finding these incredibly nontrivial bugs and thoroughly documenting your proposed fixes! I just have a few questions and suggestions.
|
|
||
| This function also handles correcting compartment tags for subunits | ||
| where the compartment tag listed in the raw_data.modified_proteins table | ||
| is inconsistent with the molecule's tag saved in the bulk molecule data. |
There was a problem hiding this comment.
This is a great catch! What do you think about making these discrepancies raise a error? Users could then "fix" the issue by updating reconstruction/ecoli/flat/modified_proteins.tsv to match the bulk molecule compartment(s).
I think the only discrepancies right now are DCUS-MONOMER and PHOR-MONOMER, which are both assigned to the cytoplasmic compartment [c] in the bulk molecule data (by these lines) and the inner membrane compartment [i] in modified_proteins.tsv.
There was a problem hiding this comment.
This is a great idea! I just updated the code to raise some errors in case molecules manually written in the modified_proteins.tsv file fall out of sync with future model/EcoCyc updates that may affect how these molecules are handled in the simulation. Let me know what you think of these when you get a chance.
…ER from [i] to [c] so that they match the tag used in the simulation for those monomers and are recognized when read in to two_component_systems.py.
…d up at each time step.
…ins.tsv either are not found in the bulk molecule simulation data or have compartment tags that do not match those expected by the simulaiton.
…proteins.tsv file that were already correct in another function (but are now also manually corrected in the raw file).
…te-merge Merging most recent master into branch.
thalassemia
left a comment
There was a problem hiding this comment.
LGTM. Thanks for following up on my suggestions!
This PR corrects how protein counts are calculated at each time step for all monomers in the simulation. Previously, some equilibrium, two component system (TCS), and unique molecule complexes were not being fully decomposed to their base monomers correctly. This occurred because these complexes contain subunits that are themselves other types of complexes, and their individual stoichiometric matrices do not recursively break down these intermediate complexes to the monomer level. For example, if complexation complexes are unpacked before a unique molecule complex containing complexation complex subunits is, the monomer counts from those subunits are effectively "lost" because unique molecule's stoichiometric matrix does not fully decompose the complexation subunits to base monomers.
To properly handle the unpacking of complexes that contain subunits of another complex type, the order of unpacking execution for the unique molecule complexes, TCS complexes, equilibrium, and complexation complexes has been rearranged to ensure that all possible complexes are properly unpacked to their base monomers. These changes are detailed further in the
monomer_counts.pylistener's code comments (ecoli/processes/listeners/monomer_counts.py).Transcription unit-bound transcription factors (TFs) are now also included in the
monomer_counts.pylistener as another unique molecule type to be broken down to their base monomer subunits at each time step. Since active TFs can be monomers, complexation complexes, equilibrium complexes, or TCS complexes, their counts are first added to the corresponding inactive (free) TF counts from bulk molecules near the top of theupdate()function (just like how the other complex types are handled). This ensures they are properly decomposed to base monomer subunits when bound to transcription units.Additionally, some fixes were made to the TCS ParCa process as well to correct how data was read in from the raw files for populating the TCS stoichiometric matrices (these changes are indicated in
reconstruction/ecoli/dataclasses/process/two_component_system.py).The plot below shows a comparison of total monomer counts for the simulation before and after these changes were implemented, which the subunit type of each monomer highlighted, if applicable (each simulation is averaged over 4 seeds with 7 generations each (28 cells total)):
