How to use the cameo.util.in_ipnb function in cameo

To help you get started, we’ve selected a few cameo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github biosustain / cameo / cameo / api / designer.py View on Github external
def __display_compound(inchi):
        if util.in_ipnb():
            Designer.__display_compound_html(inchi)
github biosustain / cameo / cameo / flux_analysis / simulation.py View on Github external
dict(type='value', value=scale[1][0], color=scale[1][1], size=16),
                              dict(type='value', value=scale[2][0], color=scale[2][1], size=8),
                              dict(type='value', value=scale[3][0], color=scale[3][1], size=16),
                              dict(type='value', value=scale[4][0], color=scale[4][1], size=21),
                              dict(type='max', color=scale[4][1], size=24)]

            active_fluxes = {rid: round(flux, ndecimals) for rid, flux in six.iteritems(self.fluxes)
                             if abs(flux) > 10 ** -ndecimals}

            active_fluxes['min'] = min(values)
            active_fluxes['max'] = max(values)

            builder = escher.Builder(map_name=map_name, map_json=map_json, reaction_data=active_fluxes,
                                     reaction_scale=reaction_scale)

            if in_ipnb():
                from IPython.display import display
                display(builder.display_in_notebook())
            else:
                builder.display_in_browser()

        except ImportError:
            print("Escher must be installed in order to visualize maps")
github biosustain / cameo / cameo / api / designer.py View on Github external
def __display_pathways_information(predicted_pathways, host, original_model):
        if util.in_ipnb():
            title = "Production envelopes for %s (%s)" % (host.name, original_model.id)
            predicted_pathways.plot_production_envelopes(original_model, title=title, objective=original_model.biomass)
github biosustain / cameo / cameo / visualization / plotting.py View on Github external
def _plot_grid(self):
        if util.in_ipnb():
            if config.use_bokeh:
                self._plot_bokeh_grid()
            elif config.use_matplotlib:
                self._plot_matplotlib_grid()
        else:
            self._plot_cli_grid()
github biosustain / cameo / cameo / strain_design / heuristic / evolutionary / optimization.py View on Github external
def _set_observer(self):
        self.observers = []

        if in_ipnb() and self.plot:
            if config.use_bokeh:
                if len(self.objective_function) > 1:
                    self.observers.append(plotters.IPythonBokehParetoPlotter(self.objective_function))
                else:
                    self.observers.append(plotters.IPythonBokehFitnessPlotter())

        else:
            if config.use_bokeh:
                pass
            else:
                pass
        if self.progress:
            self.observers.append(observers.ProgressObserver())
github biosustain / cameo / cameo / strain_design / deterministic / flux_variability_based.py View on Github external
reaction_data['min'] = -reaction_data['max']

            scale = self.plot_scale(palette)

            reaction_scale = [dict(type='min', color=scale[0][1], size=24),
                              dict(type='value', value=scale[0][0], color=scale[0][1], size=21),
                              dict(type='value', value=scale[1][0], color=scale[1][1], size=16),
                              dict(type='value', value=scale[2][0], color=scale[2][1], size=8),
                              dict(type='value', value=scale[3][0], color=scale[3][1], size=16),
                              dict(type='value', value=scale[4][0], color=scale[4][1], size=21),
                              dict(type='max', color=scale[4][1], size=24)]

            builder = escher.Builder(map_name=map_name, map_json=map_json, reaction_data=reaction_data,
                                     reaction_scale=reaction_scale)

            if in_ipnb():
                from IPython.display import display
                display(builder.display_in_notebook())
            else:
                builder.display_in_browser()

        except ImportError:
            print("Escher must be installed in order to visualize maps")
github biosustain / cameo / cameo / api / designer.py View on Github external
def __display_product_search_result(search_result):
        if util.in_ipnb():
            Designer.__display_product_search_results_html(search_result)
        else:
            Designer.__display_product_search_results_cli(search_result)