Repository navigation
Same results as GECKO for subsets, subsystems, uniprot cells, FSEOF and pFBA; scipy solver support - #72
Merged
Conversation
…concs and sensitivity_tuning
…uals from HiGHS, build large models sparsely optlang's scipy interface renumbers variable columns wrongly after a removal and keeps a dense matrix that it copies on every edit. An EcModel now moves its scipy problem to a sparse class with correct renumbering whenever model.solver is read, Enzyme.shadow_price, get_enzyme_bottlenecks and relax_proteomics_greedy read HiGHS row marginals on scipy, and load_conventional_gem and make_ec_model build on glpk and convert to scipy at the end.
…st the flexibilize start on scipy
… keep the ec rows of a light model A reaction that survives the removal of a gene of its rule lost the gene from model.genes but not from its rule, so removing it later raised that the gene was not found. The ec rows of a gecko-light model carry a 001_ prefix and were all dropped.
…a value, as GECKO's loadEcModel does
getSubsetEcModel's removeGenes and removeReactions calls drop every metabolite and gene without a reaction. get_subset_ec_model left the pseudo-gene standard and six unused metabolites in the HT29-GEM subset of the light Human-GEM ecModel.
…lone load_ec_model reads the file on glpk and converts the ecModel when scipy is cobra's default solver, and setting EcModel.solver to scipy builds the sparse problem of switch_to_scipy. Loading ecYeastGEM on scipy did not finish in 25 minutes before.
optlang restores a pickled or copied scipy model by adding every variable and constraint to a dense problem, which took tens of minutes per ec_fva worker on ecYeastGEM.
optlang's scipy interface ignores every tolerance, so a model set to 1e-9 was solved at the HiGHS default of 1e-7.
…sport targets, as ecFSEOF does
…nstraints, and populate the sparse problem in one pass optlang's scipy interface removes constraints through a loop that calls the generic removal once per constraint with the whole list, so removing two or more constraints raised LookupError; the sparse model removes them correctly. Removals, and the coefficient rewrites of apply_kcat_constraints, run on glpk and the model is converted back with switch_to_scipy, which now creates each constraint with its whole expression.
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.
geckopy gives the same results as GECKO on the cases the comparison in CompMetEng/raven-gecko-parity#141 turned up, and works on the scipy (HiGHS) solver. Needs CompMetEng/raven-toolbox#185 (
fseof(..., equality=True), the pFBA top level and the YAML readers); the minimumraven-toolboxversion is raised once a release contains it.Solver status.
flexibilize_enz_concsandsensitivity_tuningdecide an infeasible start from the solver status, so Gurobi, GLPK and scipy behave alike.flexibilize_enz_concswarns and returns an empty result, asflexibilizeEnzConcsdoes.sensitivity_tuningstill raisesValueErrorat the start and warns and stops inside the loop.scipy. optlang's scipy interface keeps a dense matrix that it copies on every edit, renumbers columns wrongly after a variable removal, removes several constraints at once incorrectly, ignores
model.toleranceand returns no duals. The newgeckopy.solver_supportmodule works around this:EcModel.solverrepairs a stale index map when it is read.load_conventional_gemandload_ec_modelbuild on GLPK and convert at the end, andget_subset_ec_modelandapply_kcat_constraints(for 100 or more ec reactions) edit on GLPK and convert back.get_enzyme_bottlenecks,Enzyme.shadow_priceandrelax_proteomics_greedyuse them.relax_proteomics_greedytakes one price vector per iteration and breaks ties by lowest ID.model.tolerancereaches HiGHS, and a solve that ends with numerical difficulties is repeated at the default tolerance. An infeasible solve returns a solution with its status.get_subset_ec_modelfinishes in about 5 minutes (it took 65 min). ecYeastGEM loads in 25 to 36 s.ec_fvaon ecYeastGEM takes 52 to 81 minutes on scipy, against 9 minutes on Gurobi, and its bounds differ from Gurobi's by up to 0.15 percent because HiGHS is less accurate on these LPs.Same results as GECKO.
get_subset_ec_modelremoves genes asremoveGenesdoes, keeps the ec rows of a light ecModel (the001_prefix) and drops the metabolites and genes no reaction uses. It raisedValueError: <gene> not foundon the light Human-GEM ecModel.assign_standard_kcatcompares subsystem names without regard to letter case, and a reaction without a subsystem gets the model-wide standard kcat.load_uniprot_tsvandget_uniprot_ids_from_tableread the cells liketextscanwith%q: quotes are removed and tabs inside quotes belong to the cell. A quoted EC cell such as"1.1.1.25; 2.5.1.19"kept its quotes and changed the BRENDA matches of 44 reactions in the Yarrowia build.load_ec_modelreads a file with an emptyenzymes: !!omapand with unescaped quotes in a value, asloadEcModeldoes. This stays in geckopy until the minimumraven-toolboxversion contains the same repair.pfba_enzymesholds the objective at 0.999999 of its optimum, asgetPfbaEnzymesdoes. Passfraction_of_optimum=1.0for the previous behaviour.ec_fseoffixes the target flux at each level by equality, asecFSEOFdoes. Thetargetstable lists reaction targets before transport targets, each group in score order, and has a new boolean columntransport. This changes the row order for callers that take the top N rows.