LCSB-BioCore / COBREXA.jl

Constraint-Based Reconstruction and EXascale Analysis
https://lcsb-biocore.github.io/COBREXA.jl/
Apache License 2.0
43 stars 9 forks source link

pFBA does not fail gracefully #625

Closed stelmo closed 2 years ago

stelmo commented 2 years ago

Solving a pFBA model that does not admit an LP solution in its first stage causes an error:

julia> ecoli_sol = parsimonious_flux_balance_analysis_dict(                      
             ecoli,                                                        
     CPLEX.Optimizer;                                                      
                 modifications = [                                         
         change_constraint("EX_glc__D_e", lb = 0),                         
         change_constraint("EX_ac_e", lb = 1),                             
                         change_constraint("EX_for_e", lb = 1),            
         change_constraint("EX_etoh_e", lb = 1),                           
         change_constraint("EX_lac__D_e", lb = 1),                         
         change_constraint("EX_leu__L_e", lb = -200.0),                    
         COBREXA.silence,                                                  
     ]                                                                     
 )
ERROR: MethodError: no method matching termination_status(::Nothing)
Closest candidates are:
  termination_status(::Model) at C:\Users\stelmo\.julia\packages\JuMP\0C6kd\src\JuMP.jl:675
Stacktrace:
 [1] is_solved(opt_model::Nothing)
   @ COBREXA C:\Users\stelmo\.julia\packages\COBREXA\Eyw1f\src\base\solver.jl:45
 [2] flux_dict(model::StandardModel, opt_model::Nothing)
   @ COBREXA C:\Users\stelmo\.julia\packages\COBREXA\Eyw1f\src\base\solver.jl:126        
 [3] #parsimonious_flux_balance_analysis_dict#539
   @ C:\Users\stelmo\.julia\packages\COBREXA\Eyw1f\src\analysis\parsimonious_flux_balance_analysis.jl:120 [inlined]
 [4] top-level scope
   @ REPL[71]:1
exaexa commented 2 years ago

ah yes, either the accessor functions should be ready for nothing instead of a model, or it should just return the unsolved model.

I guess returning the unsolved model would be preferable.

exaexa commented 2 years ago

closed by #659