Repository navigation
Fix review findings, backend-independent Ids, parity tests and hybrid fixes - #57
Closed
vmspereira wants to merge 221 commits into
Closed
vmspereira wants to merge 221 commits into
vmspereira wants to merge 221 commits into
Conversation
Vpereira/dev
UPDATE Community modelling
Update notebooks
update docs
add readthedocs yaml
update docs requirements
- Identify exchange reactions via boundary property - Separate exchange reactions from metabolic DataFrame - Populate inputs DataFrame with exchange reactions having negative flux - Populate outputs DataFrame with exchange reactions having positive flux - Metabolic DataFrame now excludes exchange reactions (only internal reactions) This ensures that to_summary() properly categorizes reactions into: - metabolic: Internal reactions (non-boundary) - inputs: Exchange reactions with flux < 0 (imports) - outputs: Exchange reactions with flux > 0 (exports) - regulatory: Regulatory variables (targets/regulators)
…tegy
Add 'duplicates' parameter to from_csv() and from_dataframe() methods to handle
duplicate gene/protein identifiers in expression data files.
Available strategies:
- 'suffix' (default): Keep all rows, rename duplicates with _2, _3, etc.
Issues UserWarning listing duplicate identifiers. User-friendly approach
that preserves all data while ensuring unique identifiers.
- 'error': Raise ValueError if duplicates found (strict mode)
- 'first': Keep first occurrence of duplicates
- 'last': Keep last occurrence of duplicates
- 'mean': Average values across duplicate identifiers
- 'sum': Sum values across duplicate identifiers
Fixes issue in GERM_Models_analysis.ipynb where iNJ661_gene_expression.csv
contains duplicate 'Negative' identifiers (25 duplicate rows).
Example:
# Default (suffix with warning)
expr = ExpressionSet.from_csv('data.csv', sep=';', index_col=0)
# Strict mode
expr = ExpressionSet.from_csv('data.csv', duplicates='error')
Tests: All omics tests pass (test_f_omics.py)
Add duplicate handling to ExpressionSet with 'suffix' as default stra…
…acy GERM models and RegulatoryExtension - Handle both yield_interactions() signatures (tuples vs objects) - Update type hints to accept Union[RegulatoryExtension, RegulatoryModel] - Add test script for PROM notebook workflow - Maintains backward compatibility with both model types
…els and RegulatoryExtension - Handle both yield_targets() signatures (tuples vs objects) - Add test script for CoRegFlux notebook workflow - Maintains backward compatibility with both model types - Fixes TypeError when running GERM_Models_analysis notebook
…oryExtension APIs PROM fixes: - Handle both get_gene() method (RegulatoryExtension) and genes dict (legacy) - Access gene reactions list correctly for both APIs - Maintains backward compatibility with legacy RegulatoryMetabolicModel CoRegFlux fixes: - Handle both get_exchange_reactions() method and exchanges property - Handle both get_reaction() method and reactions dict access - Fixes build_metabolites function in analysis_utils.py All PROM and CoRegFlux notebook workflows now work correctly with both model types.
Documents all issues found, fixes applied, and required updates for the GERM_Models_analysis notebook after full testing and compatibility fixes.
Major updates: - Replace deprecated FBA/pFBA classes with Simulator API - Remove slim_fba/slim_pfba function calls (deprecated) - Update all FBA/pFBA usage to use get_simulator() + SimulationMethod enum - Add error handling to find_conflicts cell - Update documentation to reflect API changes Cells updated: - Cell 10: FBA/pFBA demo using Simulator - Cell 29: Multiple methods comparison using Simulator - Cell 30: Updated markdown to explain API changes - Cell 31: FBA via Simulator (recommended approach) - Cell 32: Removed slim_fba, use Simulator - Cell 34: pFBA via Simulator - Cell 46: Added error handling for find_conflicts The notebook now uses the current MEWpy API throughout and all working examples have been tested and validated.
Documents all API changes made to GERM_Models_analysis notebook: - Detailed before/after code examples - Cell-by-cell change descriptions - Migration guide for users - Testing validation results - Related commit references
Expressionset2
- Add compatibility for get_parsed_gpr() method - Legacy models access reaction.gpr attribute directly - RegulatoryExtension uses model.get_parsed_gpr() method - Use self._get_reaction() instead of self.model.get_reaction() - Update test script to include full PROM optimization - All 11 PROM/CoRegFlux validation tests passing ✅ Fixes: 'MetabolicRegulatoryModel' object has no attribute 'get_parsed_gpr'
Fix PROM GPR access for legacy GERM models
- Add safety checks for prom_constraints, max_rates, reference dicts - Skip reactions not in yield_reactions() when processing genes - Handle get_regulator() for both legacy models (regulators dict) and RegulatoryExtension API - Prevents KeyError 'GMPS2' and similar issues - All 11 PROM/CoRegFlux validation tests passing ✅ - Tested with SCIP solver on full PROM workflow Fixes: KeyError 'GMPS2' when running PROM optimization Fixes: AttributeError 'get_regulator' for legacy models
- Add get_parsed_gpr() compatibility check in continuous_gpr() - Handle both RegulatoryExtension (method) and legacy (attribute) APIs - Fix GPR variables extraction for dict vs Symbol objects - Add safety check in gene_state_constraints() for missing reactions - Prevents KeyError when reaction not in constraints dict Fixes CoRegFlux steady-state optimization with legacy GERM models
- slim_prom: Call PROM.optimize directly instead of using run_method_and_decode - slim_prom: Handle KOSolution return value correctly - slim_prom: Robust key lookup in solutions dict - build_biomass: Extract clean reaction ID from Variable objects or strings - Handles both Variable.id and string IDs with ' || ' separator All 11 comprehensive notebook tests now passing
Expressionset3
README.md updates: - Add detailed Key Features section with 5 subsections: * Metabolic and Integrated Modeling (GERM, PROM, CoRegFlux, GECKO, ETFL) * Strain Design Optimization (multi-objective EA, KO/OU strategies) * Community Modeling (SteadyCOM, SMETANA, cross-feeding analysis) * Kinetic Modeling (ODE simulation, parameter optimization) * Solver Support (commercial and open-source options) - Add strain design optimization Quick Start example with GKOProblem - Improve installation instructions with development options - Update solver list to include SCIP (open-source) - Fix example links to point to master branch - Fix typos: Installation, maintained - Update license information to match GPL v3.0 badge README.rst (new): - Create reStructuredText version for PyPI package page - Include all key features and examples from README.md - Proper RST formatting with badges, code blocks, and links - Comprehensive installation instructions with solver requirements
Clean up and Update README
Fixes the defects found in a full code review of master (c65887d). Each fix has a regression test that fails on the pre-fix code. See CHANGELOG.md (1.1.0) for the per-method list of results that change. - Install and runtime: drop the undeclared six import; support jmetalpy >= 1.10 and matplotlib 3.11; the COBRApy simulator works when MEWpy's default solver is SCIP; get_simulator re-raises real errors. - Results: SRFBA enforces regulation; GERM FVA honours its objective; RFBA default state; PROM/CoRegFlux knockouts; iMAT big-M; GIMME/eFlux/ iMAT build_model; SteadyCom formulation; COBRApy MOMA/ROOM reference; minimised EA fitness; GERM SBML bounds round trip; enzyme constraints. - Backends: Simulator.prefix/resolve/to_native/to_canonical own the SBML R_/M_/G_ prefixes. Simulators, omics, GERM, community, cobra utils, problems and evaluation functions accept either id form, so the same code gives the same results on COBRApy and REFRAMED. - Side effects: import mewpy no longer configures logging, the multiprocessing start method or the recursion limit. - Packaging: requires-python >= 3.9, CPLEX CE out of the test extras, an examples extra, Python 3.12 in CI. - Cleanup: remove dev notes shipped in the sdist, README.rst, tracked PKG-INFO and one-off probe scripts; add examples/11-omics.ipynb. Tests: 480 passed, 2 skipped, 0 failed (PYTHONHASHSEED 0/1/2). Examples: 24/31 pass; 6 EA runs exceed 30 min, 1 SCIP numerical error.
Library: - pFBA keeps ModelConstants.PFBA_OBJ_FRAC (0.999) of the optimum on COBRApy, REFRAMED and GERM. - One definition of transport reactions/genes for every backend (non-proton metabolites in two or more compartments, exchanges excluded). - Same result conventions on every backend: infeasible results (None), FVA layout, objective sense. - SRFBA: ko() overrides the regulatory rule, metabolite regulators follow their exchange flux, indicator tolerance 1e-5, solver= honoured; user ids with or without prefix in GERM analyses. - GERM fva keeps a user bound on the objective reaction (flux envelopes). - SteadyCom scales member bounds by abundance; big-M independent of member backends; sc_score, MRO/MIP media, iMAT high set, regComFBA on SCIP (quadratic objectives), copy() settings. - SCIP zero threshold below GECKO coefficients; REFRAMED set_objective replaces the objective. - Output independent of PYTHONHASHSEED (GERM variable classes, problem methods, serialisation). - Lazy Ray import, seeded jMetal with Ray, kinetic NaN status and plotting, smaller fixes. Tests: tests/test_parity_backends.py (COBRApy/REFRAMED/GERM parity against cobra oracles), value-asserting tests for each fix, strict xfail markers removed where fixed. Docs and examples: docs/germ.md and docs/simulation.md values re-run; all 13 notebooks re-executed and their text checked against the outputs; GERM notebooks numbered 12 and 13.
…aints - Kinetic rates (mM/s) convert as rate x 3600 / gDW. They were also multiplied by the dilution rate D (2.78e-5 1/s), about 36,000x too small; D is deprecated and unused. - One enzyme_usage_constraints() for HybridGeckoSimulation and HybridGeckoOUProblem: caps use the candidate's vmax (factors), a vmax of 0 blocks the enzyme, lb_tolerance is relative, and an enzyme of several kinetic reactions gets the sums of their bounds. - HybridSimulation fits the kinetic fluxes under the user's constraints and leaves the caller's dict unchanged; infeasible fits raise ValueError. - tests/test_hybrid.py: each test fails on the previous code.
simulate(amplitude=...) and simulate_distribution applied the kinetic flux ranges over the user's and the simulator's constraints, so a knockout of a mapped reaction did not hold. Kinetic bounds are now intersected with each reaction's current bounds (the call's constraint, else the simulator's, else the model's); without overlap those bounds are kept. Tests: ranges against call and simulator constraints, and a chemostat growth check (Chassagnole PTS as glucose uptake of E. coli core); each fails on the previous code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.