biosustain / cameo

cameo - computer aided metabolic engineering & optimization
http://cameo.bio
Apache License 2.0
114 stars 44 forks source link

pathways.plot_production_envelopes() does not pass plotter to plot() #288

Open djinnome opened 3 years ago

djinnome commented 3 years ago

Hi folks,

When attempting to plot the phenotypic phase plane of a predicted pathway,

import gurobipy
model=read_sbml_model('data/iMM904.xml.gz')
model.solver = 'gurobi'
from cameo.visualizations.plotting.with_plotly import PlotlyPlotter
plotter = PlotlyPlotter()
predictor = pathway_prediction.PathwayPredictor(model)
pathways = predictor.run(product='vanillin', max_predictions=3)
pathways.plot_production_envelopes(plotter=plotter, model=model, objective=model.reactions.BIOMASS_SC5_notrace)

We get the following error:

182  ppp = pathway.production_envelop(model, objective=objective)
183  ppp.plot(grid=grid, width=450, title = "Pathway %i" % (i+1))

TypeError: plot() missing 1 required positional argument: 'plotter'
PastedGraphic-1

I think the problem is that plot() needs a plotter argument:

https://github.com/biosustain/cameo/blob/8b1adb78867f6339542a597c86be7fbb53b45308/cameo/flux_analysis/analysis.py#L762

So the solution would be that line 183 in :

https://github.com/biosustain/cameo/blob/8b1adb78867f6339542a597c86be7fbb53b45308/cameo/strain_design/pathway_prediction/pathway_predictor.py#L183

needs to be:

ppp.plot(plotter=plotter, grid=grid, width=450, title = "Pathway %i" % (i+1))