brianjamesschmidt / gim3e

Gene Inactivation Moderated by Metabolism, Metabolomics, and Expression (COBRApy)
10 stars 7 forks source link

Unknown parameters, old cobrapy codes? #4

Open sshameer opened 8 years ago

sshameer commented 8 years ago

Hi

I managed to get gim3e to run, however I had to make some fixes on the way (please let me know if my actions disturbed the algorithm). I'll try listing them here

1) Unknown parameters for glpk solver

While running gim3e I got an error as follows

result = gim3e.gim3e(cobra_model,expData) Switched solver from cplex to glpk. Determining the best objective value... Cannot optimize the original problem, even without metabolite constraints! Exiting...

I found the problem occurs at this block at line 2232 -2241

try:
  if not (alt_cplex_flag | alt_gurobi_flag):
    status = the_solver.solve_problem(lp, **configuration_parameters)
  elif alt_cplex_flag:
    status = local_solve_cplex_problem(lp, **configuration_parameters)
  else:
    status = local_solve_gurobi_problem(lp, **configuration_parameters)
except:
  status = 'failed'

the_solver.solve_problem(lp, **configuration_parameters) (I use glpk) returns the following

print the_solver.solve_problem(lp, **configuration_parameters)

File "/usr/local/lib/python2.7/dist-packages/cobra-0.4.0b4-py2.7-linux-x86_64.egg/cobra/solvers/glpk_solver.py", line 307, in solve_problem raise ValueError("Unknown parameters: " + ", ".join(parameters)) ValueError: Unknown parameters: the_problem, tolerance_optimality

I replaced the line 2234 by status = the_solver.solve_problem(lp)

This solved this problem

2) Legacy cobrapy calls

line 2550 for the_gene in test_reaction.get_gene(): needed to be replaced by for the_gene in test_reaction.genes:

line 2565 and line 2583 same as above

line 550 current_metabolites = [x for x in (reaction.get_products() + reaction.get_reactants())] needed to be replaced by current_metabolites = [x for x in (reaction.products + reaction.reactants)]

3) KWARGS new objective issue

I got the following error Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/gim3e-1.0.3-py2.7.egg/gim3e/core/gim3e.py", line 373, in gim3e verbose = FVA_verbose) File "/usr/local/lib/python2.7/dist-packages/gim3e-1.0.3-py2.7.egg/gim3e/core/gim3e.py", line 958, in irreversible_flux_variability_analysis error_reporting = error_reporting)
File "/usr/local/lib/python2.7/dist-packages/gim3e-1.0.3-py2.7.egg/gim3e/core/gim3e.py", line 2133, in gim3e_optimize reaction.objective_coefficient = value

I printed out the kwargs and it was {'objective_sense': 'minimize', 'the_problem': None, 'new_objective': <Reaction COAtg at 0x7fe4b114c810>, 'tolerance_optimality': 1e-07, 'tolerance_feasibility': 1e-07, 'tolerance_integer': 1e-09}

So to get it working line 2129 for reaction, value in kwargs.pop('new_objective').items(): line 2130 reaction.objective_coefficient = value needed to be replaced by for reaction in [kwargs.pop('new_objective')]: reaction.objective_coefficient = 1

Hope this helps, Keep up the good work, Sanu