:py:mod:`micom.solution` ======================== .. py:module:: micom.solution .. autoapi-nested-parse:: A community solution object. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: micom.solution.CommunitySolution Functions ~~~~~~~~~ .. autoapisummary:: micom.solution._group_taxa micom.solution.add_pfba_objective micom.solution.solve micom.solution.reset_solver micom.solution.optimize_with_retry micom.solution.crossover micom.solution.optimize_with_fraction Attributes ~~~~~~~~~~ .. autoapisummary:: micom.solution.good .. py:data:: good Solver states that permit returning the solution. .. py:function:: _group_taxa(values, ids, taxa, what='reaction') Format a list of values by id and taxa. .. py:class:: CommunitySolution(community, slim=False, reactions=None, metabolites=None) Bases: :py:obj:`cobra.core.Solution` An FBA solution for an entire community. .. attribute:: objective_value The (optimal) value for the objective function. :type: float .. attribute:: members Contains basic info about the individual compartments/members of the community such as id, abundance and growth rates. Will also include one row for the external medium (without abundance and growth rate). :type: pandas.Series .. attribute:: growth_rate The overall growth rate for the community normalized to 1 gDW. :type: float .. attribute:: status The solver status related to the solution. :type: str .. attribute:: strategy The optimization strategy used to obtain the solution (may be empty). :type: str .. attribute:: fluxes Contains the reaction fluxes (primal values of variables) stratified by compartment. Columns denote individual fluxes and rows denote compartments: one for every taxon plus one for the external medium. Fluxes will be NA if the reaction does not exist in the organism. :type: pandas.DataFrame .. attribute:: reduced_costs Contains reaction reduced costs (dual values of variables) stratified by taxa. Columns denote individual fluxes and rows denote taxa. Reduced costs will be NA if the reaction does not exist in the organism. :type: pandas.Series .. attribute:: shadow_prices Contains metabolite shadow prices (dual values of constraints) stratified by taxa. Columns denote individual metabolites and rows denote taxa. Shadow prices will be NA if the metabolite does not exist in the organism. :type: pandas.Series .. py:method:: _repr_html_() Return a rich HTML representation of the solution. .. py:method:: __repr__() Convert CommunitySolution instance to string representation. .. py:function:: add_pfba_objective(community, atol=1e-06, rtol=1e-06) Add pFBA objective. Add objective to minimize the summed flux of all reactions to the current objective. This one will work with any objective (even non-linear ones). .. seealso:: :obj:`pfba` :param community: The community to add the objective to. :type community: micom.Community .. py:function:: solve(community, fluxes=True, pfba=True, raise_error=False, atol=1e-06, rtol=1e-06) Get all fluxes stratified by taxa. .. py:function:: reset_solver(community) Reset the solver. .. py:function:: optimize_with_retry(com, message='could not get optimum.') Try to reset the solver. .. py:function:: crossover(community, sol, fluxes=False) Get the crossover solution. .. py:function:: optimize_with_fraction(com, fraction, growth_rate=None, fluxes=False) Optimize with a constrained community growth rate.