foodnet 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. foodnet-0.1.0/LICENSE +201 -0
  2. foodnet-0.1.0/NOTICE +17 -0
  3. foodnet-0.1.0/PKG-INFO +182 -0
  4. foodnet-0.1.0/README.md +164 -0
  5. foodnet-0.1.0/pyproject.toml +41 -0
  6. foodnet-0.1.0/setup.cfg +4 -0
  7. foodnet-0.1.0/src/foodnet/__init__.py +3 -0
  8. foodnet-0.1.0/src/foodnet/__main__.py +253 -0
  9. foodnet-0.1.0/src/foodnet/app.py +46 -0
  10. foodnet-0.1.0/src/foodnet/attribution.py +27 -0
  11. foodnet-0.1.0/src/foodnet/brand.py +207 -0
  12. foodnet-0.1.0/src/foodnet/compounds.py +79 -0
  13. foodnet-0.1.0/src/foodnet/crm.py +93 -0
  14. foodnet-0.1.0/src/foodnet/cytoscape.py +338 -0
  15. foodnet-0.1.0/src/foodnet/derive.py +510 -0
  16. foodnet-0.1.0/src/foodnet/export.py +107 -0
  17. foodnet-0.1.0/src/foodnet/fetch.py +92 -0
  18. foodnet-0.1.0/src/foodnet/figure.py +294 -0
  19. foodnet-0.1.0/src/foodnet/gui.py +841 -0
  20. foodnet-0.1.0/src/foodnet/help.py +233 -0
  21. foodnet-0.1.0/src/foodnet/legend.py +79 -0
  22. foodnet-0.1.0/src/foodnet/matrix.py +448 -0
  23. foodnet-0.1.0/src/foodnet/media.py +147 -0
  24. foodnet-0.1.0/src/foodnet/mgrowthdb.py +272 -0
  25. foodnet-0.1.0/src/foodnet/model.py +209 -0
  26. foodnet-0.1.0/src/foodnet/phase.py +165 -0
  27. foodnet-0.1.0/src/foodnet/rates.py +259 -0
  28. foodnet-0.1.0/src/foodnet/rbridge.py +102 -0
  29. foodnet-0.1.0/src/foodnet/reading.py +276 -0
  30. foodnet-0.1.0/src/foodnet/report.py +117 -0
  31. foodnet-0.1.0/src/foodnet/schema.py +163 -0
  32. foodnet-0.1.0/src/foodnet/search.py +386 -0
  33. foodnet-0.1.0/src/foodnet/selection.py +98 -0
  34. foodnet-0.1.0/src/foodnet/stats.py +122 -0
  35. foodnet-0.1.0/src/foodnet/taxonomy.py +218 -0
  36. foodnet-0.1.0/src/foodnet.egg-info/PKG-INFO +182 -0
  37. foodnet-0.1.0/src/foodnet.egg-info/SOURCES.txt +55 -0
  38. foodnet-0.1.0/src/foodnet.egg-info/dependency_links.txt +1 -0
  39. foodnet-0.1.0/src/foodnet.egg-info/entry_points.txt +2 -0
  40. foodnet-0.1.0/src/foodnet.egg-info/requires.txt +4 -0
  41. foodnet-0.1.0/src/foodnet.egg-info/top_level.txt +1 -0
  42. foodnet-0.1.0/tests/test_app.py +35 -0
  43. foodnet-0.1.0/tests/test_cli.py +67 -0
  44. foodnet-0.1.0/tests/test_compounds.py +35 -0
  45. foodnet-0.1.0/tests/test_derive.py +336 -0
  46. foodnet-0.1.0/tests/test_figure.py +113 -0
  47. foodnet-0.1.0/tests/test_gate.py +15 -0
  48. foodnet-0.1.0/tests/test_gui.py +137 -0
  49. foodnet-0.1.0/tests/test_help.py +61 -0
  50. foodnet-0.1.0/tests/test_matrix.py +128 -0
  51. foodnet-0.1.0/tests/test_media.py +61 -0
  52. foodnet-0.1.0/tests/test_outputs.py +79 -0
  53. foodnet-0.1.0/tests/test_palette.py +83 -0
  54. foodnet-0.1.0/tests/test_phase.py +89 -0
  55. foodnet-0.1.0/tests/test_rbridge.py +66 -0
  56. foodnet-0.1.0/tests/test_reading.py +65 -0
  57. foodnet-0.1.0/tests/test_release.py +65 -0
foodnet-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 The crossfeed authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
foodnet-0.1.0/NOTICE ADDED
@@ -0,0 +1,17 @@
1
+ foodnet
2
+ Copyright 2026 The foodnet authors (KU Leuven, Lab of Molecular Bacteriology).
3
+
4
+ foodnet is derived in part from grownet (https://github.com/crossfeed-bio/crossfeed),
5
+ Copyright 2026 The crossfeed authors, licensed under the Apache License, Version 2.0.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
foodnet-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: foodnet
3
+ Version: 0.1.0
4
+ Summary: Build taxon and metabolite networks (who produces and who consumes what) from mGrowthDB batch monocultures, with the parameters of a consumer-resource model.
5
+ Author: KU Leuven, Lab of Molecular Bacteriology
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hallucigenia-sparsa/foodnet
8
+ Project-URL: Repository, https://github.com/hallucigenia-sparsa/foodnet
9
+ Keywords: metabolites,cross-feeding,consumer-resource-model,mGrowthDB,microbial-ecology,open-science
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=8; extra == "dev"
16
+ Requires-Dist: ruff>=0.6; extra == "dev"
17
+ Dynamic: license-file
18
+
19
+ # foodnet: who produces and who consumes which metabolite
20
+
21
+ [![ci](https://github.com/hallucigenia-sparsa/foodnet/actions/workflows/ci.yml/badge.svg)](https://github.com/hallucigenia-sparsa/foodnet/actions/workflows/ci.yml)
22
+ [![license: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
23
+ [![python: 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
24
+
25
+ food**net** builds bipartite taxon and metabolite networks from the batch monocultures in
26
+ [mGrowthDB](https://mgrowthdb.gbiomed.kuleuven.be/): which taxon produces which compound, and which consumes
27
+ it, with the amount moved in each growth phase. It hands the result to Cytoscape, to graph formats, to two
28
+ matrix formats, and to R as the parameters of a consumer-resource model (CRM), with
29
+ [miaSim](https://bioconductor.org/packages/release/bioc/html/miaSim.html) as the example simulator.
30
+
31
+ It is the sister tool of [grow**net**](https://github.com/crossfeed-bio/crossfeed), which builds
32
+ interaction networks from co-cultures, and is built the same way: a thin client with no runtime
33
+ dependencies, a local page and a command line, nothing hosted and nothing uploaded.
34
+
35
+ ## Contents
36
+
37
+ - [Install](#install)
38
+ - [Quickstart](#quickstart)
39
+ - [What it does](#what-it-does)
40
+ - [The outputs](#the-outputs)
41
+ - [Consumer-resource models in R](#consumer-resource-models-in-r)
42
+ - [The command line](#the-command-line)
43
+ - [Guardrails](#guardrails)
44
+ - [License](#license)
45
+
46
+ ## Install
47
+
48
+ With [uv](https://docs.astral.sh/uv/), which fetches a suitable Python by itself:
49
+
50
+ ```bash
51
+ uv tool install foodnet
52
+ ```
53
+
54
+ or with pipx (`pipx install foodnet`), or from a clone (`pip install -e .`). Each release also carries
55
+ `foodnet-<version>-windows.zip`, the whole program in one folder with Python included: unzip it and
56
+ double-click `foodnet.exe`. Windows warns about a program few people have run yet; click the small "More
57
+ info" link, then "Run anyway".
58
+
59
+ ## Quickstart
60
+
61
+ ```bash
62
+ foodnet gui
63
+ ```
64
+
65
+ opens the page in your browser. Type taxa in the first box (a species, a strain, a genus or an NCBI taxon
66
+ id, one per line), or press Example, and press Get taxon-metabolite network. The consumed and produced
67
+ matrices appear first under the settings, then the taxa and the arcs with the downloads.
68
+
69
+ ![the legend](docs/legend.svg)
70
+
71
+ ## What it does
72
+
73
+ 1. **Taxa to monocultures.** Names resolve to the strains mGrowthDB holds (a species name to all its
74
+ strains). food**net** reads every batch monoculture of those strains that has metabolite measurements.
75
+ A culture-level growth curve counts in a monoculture, since it measures the one strain.
76
+ 2. **Growth phases.** Exponential growth ends at the first sample where the culture reaches 90% of its
77
+ maximal abundance; the stationary phase runs from there to the last metabolite sample. Below the boxes,
78
+ choose Exponential phase (the default), Stationary phase or Both. A time window in Advanced settings
79
+ replaces the phases, and a second window can be given to metabolites named there (trehalose over the whole
80
+ run, for example), so no compound needs a window of its own. Diauxic shifts are not detected.
81
+ 3. **A change per phase.** For each replicate and metabolite, the concentration at the end of the phase
82
+ minus the concentration at its start (interpolated between samples), averaged over replicates. A mean
83
+ change below the detection limit (0.2 mM, a setting) is no change. A metabolite series shorter than
84
+ 24 h is used, and flagged.
85
+ 4. **Values from one medium, presence from the others.** With the second box empty, all data are
86
+ considered: the values come from the medium that holds data for the most taxa, and every other medium
87
+ only says whether a compound was produced or consumed (`presence_only` arcs, NA matrix cells). A filled
88
+ second box limits the data to what matches it: study or experiment ids, or a medium name, which gives the
89
+ values from the medium it matches for the most taxa; with ids and no medium, the majority rule runs within
90
+ the ids. "Include supporting evidence outside the
91
+ second box" adds the rest as presence. Because mGrowthDB does not report a medium's composition
92
+ systematically, an experiment whose description says something was added or taken away ("WC plus mucin
93
+ beads", "without glucose", "+Ac"), or whose recorded atmosphere differs, counts as another medium; this
94
+ can be switched off, and experiments can be excluded by id. "Ignore media differences" pools
95
+ every medium; "Report everything as booleans" drops the amounts.
96
+ 5. **Pooling, with what does not agree reported.** Studies in the value medium are pooled. Experiments
97
+ that disagree on what happened make a `conflict`, named in the report. The same experiment deposited
98
+ under two studies is counted once.
99
+ 6. **Arcs.** A produced arc runs from the taxon to the metabolite, a consumed arc from the metabolite to
100
+ the taxon, and its width is the amount in mM. One arc per study by default; "Merge arcs across studies"
101
+ and "Merge to genus" are advanced settings, as in grow**net**.
102
+
103
+ **What a taxon produces and consumes alone is not necessarily what it does in a community.** Competition,
104
+ cross-feeding, pH and regulation all change it, so the network is a map of capabilities and candidate links,
105
+ and a consumer-resource model built from it is a hypothesis to check against the community itself.
106
+
107
+ Acid and base forms of one compound are one metabolite (acetic acid and acetate), since mGrowthDB records
108
+ both and an HPLC measures one pool. A compound that was never assayed for a taxon is never written as zero.
109
+ Every decision and its reason is in [docs/METHOD_NOTES.md](docs/METHOD_NOTES.md).
110
+
111
+ ## The outputs
112
+
113
+ - **The matrices as an image**, shown first under the settings: consumed and produced side by side (or one
114
+ above the other when they are wide): a number on a gray for a change, white for
115
+ measured without one, pale orange for not assayed, an open circle for a change seen only in another medium.
116
+ Downloadable as SVG, and in the matrices zip. Hovering over a cell shows its value, its replicates and the
117
+ studies, experiments and medium behind it (also in the downloaded SVG, opened in a browser).
118
+ - **Network**: JSON (the canonical format, [schema](schema/metabolite_network.schema.json)) or GraphML.
119
+ - **Taxa x metabolites matrix** (CSV): one cell per taxon and metabolite, the mean change in mM, positive
120
+ when produced and negative when consumed.
121
+ - **Consumed and produced matrices** (zip): two matrices of non-negative amounts, an evidence matrix for
122
+ each (`measured`, `below_limit`, `presence_only`, `not_assayed`), and a README.
123
+ - **Send to Cytoscape**: the network in a running Cytoscape, in the style of the legend. A downloaded
124
+ GraphML takes the same style from `foodnet style`.
125
+ - **Report**: every setting, every arc, and every record left out with its reason.
126
+
127
+ Every arc also says how long its cultures grew exponentially (`exponential_h`, in hours), in the result
128
+ table and in every file.
129
+
130
+ In every matrix a number is a change beyond the detection limit, 0 is measured without one, and NA is no
131
+ value. A change seen only in another medium is NA by default; Advanced settings can write it as TRUE or as
132
+ the amount measured there (drawn on a background of its own in the image), and the evidence matrices mark
133
+ it `presence_only` either way. With Both, each metabolite has a column per phase.
134
+
135
+ ## Consumer-resource models in R
136
+
137
+ CRM mode collects growth rates: from the replicates whose metabolites gave the values, else from another
138
+ monoculture in the same medium. Get CRM parameters then downloads the matrices, the growth rates and the
139
+ initial medium concentrations, or sends them to R. Install the companion package once:
140
+
141
+ ```r
142
+ remotes::install_github("hallucigenia-sparsa/foodnet", subdir = "r")
143
+ ```
144
+
145
+ then:
146
+
147
+ ```r
148
+ library(foodnet)
149
+ crm <- foodnet_listen() # and press Send to R on the page
150
+ E <- crm_efficiency(crm) # positive for consumption, negative for production
151
+ args <- as_miasim(crm) # stops if a taxon has no growth rate
152
+ tse <- do.call(miaSim::simulateConsumerResource, c(args, list(t_end = 48, t_store = 100)))
153
+ ```
154
+
155
+ The matrices are measured amounts, not model parameters: `crm_efficiency()` turns them into an efficiency
156
+ matrix, and how to scale it is a modeling choice. With the phase choice Both, the CRM parameters use the
157
+ exponential phase, since a consumer-resource model describes growth. See [r/README.md](r/README.md).
158
+
159
+ ## The command line
160
+
161
+ ```bash
162
+ foodnet derive --taxa "Escherichia coli LF82" "Bacteroides fragilis" --out network.json --report report.txt
163
+ foodnet derive --taxa Roseburia --phase both --format matrices --out roseburia.zip
164
+ foodnet derive --taxa Blautia Roseburia --conditions "Wilkins-Chalgren" --crm-mode --crm crm.zip
165
+ foodnet validate network.json
166
+ ```
167
+
168
+ `foodnet derive --help` lists every option, with examples.
169
+
170
+ ## Guardrails
171
+
172
+ The same as grow**net**'s: no real data in git (only synthetic fixtures under `tests/fixtures/`), no
173
+ runtime dependencies, the network format is a contract checked against its schema, and `make check` runs
174
+ lint, the guardrail gate and the tests, in CI and before every commit. See [AGENTS.md](AGENTS.md) and
175
+ [CONTRIBUTING.md](CONTRIBUTING.md).
176
+
177
+ Every arc cites the studies behind it, so attribution resolves at the arc level; see
178
+ [docs/DATA_GOVERNANCE.md](docs/DATA_GOVERNANCE.md).
179
+
180
+ ## License
181
+
182
+ Apache License 2.0; see [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,164 @@
1
+ # foodnet: who produces and who consumes which metabolite
2
+
3
+ [![ci](https://github.com/hallucigenia-sparsa/foodnet/actions/workflows/ci.yml/badge.svg)](https://github.com/hallucigenia-sparsa/foodnet/actions/workflows/ci.yml)
4
+ [![license: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
5
+ [![python: 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
6
+
7
+ food**net** builds bipartite taxon and metabolite networks from the batch monocultures in
8
+ [mGrowthDB](https://mgrowthdb.gbiomed.kuleuven.be/): which taxon produces which compound, and which consumes
9
+ it, with the amount moved in each growth phase. It hands the result to Cytoscape, to graph formats, to two
10
+ matrix formats, and to R as the parameters of a consumer-resource model (CRM), with
11
+ [miaSim](https://bioconductor.org/packages/release/bioc/html/miaSim.html) as the example simulator.
12
+
13
+ It is the sister tool of [grow**net**](https://github.com/crossfeed-bio/crossfeed), which builds
14
+ interaction networks from co-cultures, and is built the same way: a thin client with no runtime
15
+ dependencies, a local page and a command line, nothing hosted and nothing uploaded.
16
+
17
+ ## Contents
18
+
19
+ - [Install](#install)
20
+ - [Quickstart](#quickstart)
21
+ - [What it does](#what-it-does)
22
+ - [The outputs](#the-outputs)
23
+ - [Consumer-resource models in R](#consumer-resource-models-in-r)
24
+ - [The command line](#the-command-line)
25
+ - [Guardrails](#guardrails)
26
+ - [License](#license)
27
+
28
+ ## Install
29
+
30
+ With [uv](https://docs.astral.sh/uv/), which fetches a suitable Python by itself:
31
+
32
+ ```bash
33
+ uv tool install foodnet
34
+ ```
35
+
36
+ or with pipx (`pipx install foodnet`), or from a clone (`pip install -e .`). Each release also carries
37
+ `foodnet-<version>-windows.zip`, the whole program in one folder with Python included: unzip it and
38
+ double-click `foodnet.exe`. Windows warns about a program few people have run yet; click the small "More
39
+ info" link, then "Run anyway".
40
+
41
+ ## Quickstart
42
+
43
+ ```bash
44
+ foodnet gui
45
+ ```
46
+
47
+ opens the page in your browser. Type taxa in the first box (a species, a strain, a genus or an NCBI taxon
48
+ id, one per line), or press Example, and press Get taxon-metabolite network. The consumed and produced
49
+ matrices appear first under the settings, then the taxa and the arcs with the downloads.
50
+
51
+ ![the legend](docs/legend.svg)
52
+
53
+ ## What it does
54
+
55
+ 1. **Taxa to monocultures.** Names resolve to the strains mGrowthDB holds (a species name to all its
56
+ strains). food**net** reads every batch monoculture of those strains that has metabolite measurements.
57
+ A culture-level growth curve counts in a monoculture, since it measures the one strain.
58
+ 2. **Growth phases.** Exponential growth ends at the first sample where the culture reaches 90% of its
59
+ maximal abundance; the stationary phase runs from there to the last metabolite sample. Below the boxes,
60
+ choose Exponential phase (the default), Stationary phase or Both. A time window in Advanced settings
61
+ replaces the phases, and a second window can be given to metabolites named there (trehalose over the whole
62
+ run, for example), so no compound needs a window of its own. Diauxic shifts are not detected.
63
+ 3. **A change per phase.** For each replicate and metabolite, the concentration at the end of the phase
64
+ minus the concentration at its start (interpolated between samples), averaged over replicates. A mean
65
+ change below the detection limit (0.2 mM, a setting) is no change. A metabolite series shorter than
66
+ 24 h is used, and flagged.
67
+ 4. **Values from one medium, presence from the others.** With the second box empty, all data are
68
+ considered: the values come from the medium that holds data for the most taxa, and every other medium
69
+ only says whether a compound was produced or consumed (`presence_only` arcs, NA matrix cells). A filled
70
+ second box limits the data to what matches it: study or experiment ids, or a medium name, which gives the
71
+ values from the medium it matches for the most taxa; with ids and no medium, the majority rule runs within
72
+ the ids. "Include supporting evidence outside the
73
+ second box" adds the rest as presence. Because mGrowthDB does not report a medium's composition
74
+ systematically, an experiment whose description says something was added or taken away ("WC plus mucin
75
+ beads", "without glucose", "+Ac"), or whose recorded atmosphere differs, counts as another medium; this
76
+ can be switched off, and experiments can be excluded by id. "Ignore media differences" pools
77
+ every medium; "Report everything as booleans" drops the amounts.
78
+ 5. **Pooling, with what does not agree reported.** Studies in the value medium are pooled. Experiments
79
+ that disagree on what happened make a `conflict`, named in the report. The same experiment deposited
80
+ under two studies is counted once.
81
+ 6. **Arcs.** A produced arc runs from the taxon to the metabolite, a consumed arc from the metabolite to
82
+ the taxon, and its width is the amount in mM. One arc per study by default; "Merge arcs across studies"
83
+ and "Merge to genus" are advanced settings, as in grow**net**.
84
+
85
+ **What a taxon produces and consumes alone is not necessarily what it does in a community.** Competition,
86
+ cross-feeding, pH and regulation all change it, so the network is a map of capabilities and candidate links,
87
+ and a consumer-resource model built from it is a hypothesis to check against the community itself.
88
+
89
+ Acid and base forms of one compound are one metabolite (acetic acid and acetate), since mGrowthDB records
90
+ both and an HPLC measures one pool. A compound that was never assayed for a taxon is never written as zero.
91
+ Every decision and its reason is in [docs/METHOD_NOTES.md](docs/METHOD_NOTES.md).
92
+
93
+ ## The outputs
94
+
95
+ - **The matrices as an image**, shown first under the settings: consumed and produced side by side (or one
96
+ above the other when they are wide): a number on a gray for a change, white for
97
+ measured without one, pale orange for not assayed, an open circle for a change seen only in another medium.
98
+ Downloadable as SVG, and in the matrices zip. Hovering over a cell shows its value, its replicates and the
99
+ studies, experiments and medium behind it (also in the downloaded SVG, opened in a browser).
100
+ - **Network**: JSON (the canonical format, [schema](schema/metabolite_network.schema.json)) or GraphML.
101
+ - **Taxa x metabolites matrix** (CSV): one cell per taxon and metabolite, the mean change in mM, positive
102
+ when produced and negative when consumed.
103
+ - **Consumed and produced matrices** (zip): two matrices of non-negative amounts, an evidence matrix for
104
+ each (`measured`, `below_limit`, `presence_only`, `not_assayed`), and a README.
105
+ - **Send to Cytoscape**: the network in a running Cytoscape, in the style of the legend. A downloaded
106
+ GraphML takes the same style from `foodnet style`.
107
+ - **Report**: every setting, every arc, and every record left out with its reason.
108
+
109
+ Every arc also says how long its cultures grew exponentially (`exponential_h`, in hours), in the result
110
+ table and in every file.
111
+
112
+ In every matrix a number is a change beyond the detection limit, 0 is measured without one, and NA is no
113
+ value. A change seen only in another medium is NA by default; Advanced settings can write it as TRUE or as
114
+ the amount measured there (drawn on a background of its own in the image), and the evidence matrices mark
115
+ it `presence_only` either way. With Both, each metabolite has a column per phase.
116
+
117
+ ## Consumer-resource models in R
118
+
119
+ CRM mode collects growth rates: from the replicates whose metabolites gave the values, else from another
120
+ monoculture in the same medium. Get CRM parameters then downloads the matrices, the growth rates and the
121
+ initial medium concentrations, or sends them to R. Install the companion package once:
122
+
123
+ ```r
124
+ remotes::install_github("hallucigenia-sparsa/foodnet", subdir = "r")
125
+ ```
126
+
127
+ then:
128
+
129
+ ```r
130
+ library(foodnet)
131
+ crm <- foodnet_listen() # and press Send to R on the page
132
+ E <- crm_efficiency(crm) # positive for consumption, negative for production
133
+ args <- as_miasim(crm) # stops if a taxon has no growth rate
134
+ tse <- do.call(miaSim::simulateConsumerResource, c(args, list(t_end = 48, t_store = 100)))
135
+ ```
136
+
137
+ The matrices are measured amounts, not model parameters: `crm_efficiency()` turns them into an efficiency
138
+ matrix, and how to scale it is a modeling choice. With the phase choice Both, the CRM parameters use the
139
+ exponential phase, since a consumer-resource model describes growth. See [r/README.md](r/README.md).
140
+
141
+ ## The command line
142
+
143
+ ```bash
144
+ foodnet derive --taxa "Escherichia coli LF82" "Bacteroides fragilis" --out network.json --report report.txt
145
+ foodnet derive --taxa Roseburia --phase both --format matrices --out roseburia.zip
146
+ foodnet derive --taxa Blautia Roseburia --conditions "Wilkins-Chalgren" --crm-mode --crm crm.zip
147
+ foodnet validate network.json
148
+ ```
149
+
150
+ `foodnet derive --help` lists every option, with examples.
151
+
152
+ ## Guardrails
153
+
154
+ The same as grow**net**'s: no real data in git (only synthetic fixtures under `tests/fixtures/`), no
155
+ runtime dependencies, the network format is a contract checked against its schema, and `make check` runs
156
+ lint, the guardrail gate and the tests, in CI and before every commit. See [AGENTS.md](AGENTS.md) and
157
+ [CONTRIBUTING.md](CONTRIBUTING.md).
158
+
159
+ Every arc cites the studies behind it, so attribution resolves at the arc level; see
160
+ [docs/DATA_GOVERNANCE.md](docs/DATA_GOVERNANCE.md).
161
+
162
+ ## License
163
+
164
+ Apache License 2.0; see [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "foodnet"
7
+ version = "0.1.0"
8
+ description = "Build taxon and metabolite networks (who produces and who consumes what) from mGrowthDB batch monocultures, with the parameters of a consumer-resource model."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ authors = [
14
+ { name = "KU Leuven, Lab of Molecular Bacteriology" },
15
+ ]
16
+ keywords = ["metabolites", "cross-feeding", "consumer-resource-model", "mGrowthDB", "microbial-ecology", "open-science"]
17
+ dependencies = []
18
+
19
+ [project.optional-dependencies]
20
+ dev = ["pytest>=8", "ruff>=0.6"]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/hallucigenia-sparsa/foodnet"
24
+ Repository = "https://github.com/hallucigenia-sparsa/foodnet"
25
+
26
+ [project.scripts]
27
+ foodnet = "foodnet.__main__:main"
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+
32
+ [tool.pytest.ini_options]
33
+ pythonpath = ["src", "."]
34
+ testpaths = ["tests"]
35
+
36
+ [tool.ruff]
37
+ line-length = 120
38
+ target-version = "py310"
39
+
40
+ [tool.ruff.lint]
41
+ select = ["E", "F", "I", "W", "B", "UP"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """foodnet: bipartite taxon and metabolite networks from mGrowthDB batch monocultures."""
2
+
3
+ __version__ = "0.1.0"