:py:mod:`gempipe.interface.gaps` ================================ .. py:module:: gempipe.interface.gaps Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: gempipe.interface.gaps.initialize gempipe.interface.gaps.get_objectives gempipe.interface.gaps.get_solver gempipe.interface.gaps.remove_rids gempipe.interface.gaps.perform_gapfilling gempipe.interface.gaps.get_universe gempipe.interface.gaps.get_biolog_mappings gempipe.interface.gaps.add_demand gempipe.interface.gaps.can_synth gempipe.interface.gaps.check_reactants gempipe.interface.gaps.sensitivity_analysis gempipe.interface.gaps.query_pam gempipe.interface.gaps.import_from_universe gempipe.interface.gaps.ss_preview gempipe.interface.gaps.biolog_preview gempipe.interface.gaps.add_reaction gempipe.interface.gaps.add_metabolite gempipe.interface.gaps.search_similar Attributes ~~~~~~~~~~ .. autoapisummary:: gempipe.interface.gaps.__GAPSCACHE__ .. py:data:: __GAPSCACHE__ .. py:function:: initialize(outdir) Initialize the gempipe.curate API with the outputs coming from ``gempipe recon``. This function locates the draft pan-GSMM, PAM, and functional annotation table inside the `gempipe recon`` output folder (``-o``/``--outdir``). :param outdir: path to the main output folder of ``gempipe recon`` (``-o``/``--outdir``). :type outdir: str :returns: draft pan-GSMM to start the manual curation. :rtype: cobra.Model .. py:function:: get_objectives(model) Get the IDs of the current objective reactions. :param model: target model. :type model: cobra.Model :returns: IDs of the reactions set as objective. :rtype: list .. py:function:: get_solver(model) Get the ID of the solver associated to the model. :param model: target model. :type model: cobra.Model :returns: ID of the solver (for example: ``glpk_exact``). :rtype: str .. py:function:: remove_rids(model, rids, inverse=False) Remove reactions from the model given a list of reaction IDs. :param model: target model. :type model: cobra.Model :param rids: reaction IDs. :type rids: list :param inverse: if ``True``, reactions IDs contained in `rids` will be the ones to keep and not to remove. :type inverse: bool .. py:function:: perform_gapfilling(model, universe, mid=None, slim=None, minflux=1.0, exr=False, nsol=3, penalties=None, verbose=True, timeout=None, logger=None, boost=False) Propose gap-filling solutions for the specified objective. It's possible to gap-fill also for the biosynthesis of a specific metabolite. :param model: target model to gap-fill. :type model: cobra.Model :param universe: model from which to take new reactions. :type universe: cobra.Model :param mid: gap-fill for the biosynthesis of a specific metabolite having ID `mid`. Will be ignored if ``None``. :type mid: str :param slim: try to reduce the complexity of the universe, considering only its reactions carrying non-0 flux. Can be ``FBA`` or ``FVA``. Will be ignored if ``None``. :type slim: str :param minflux: minimal flux to grant through the objective reaction. :type minflux: float :param nsol: number of alternative solutions. :type nsol: int :param exr: whether to allow the opening of new EX_change reactions. :type exr: bool :param penalties: dictionary keyed by reaction ID, containing reaction-specific penalties to apply during gap-filling. :type penalties: dict :param verbose: if False, just return the lisr of reaction IDs without printing any further information. :type verbose: bool :param timeout: max seconds to wait for the gapfilling step. If ``None``, gap-filling won't be temporized. :type timeout: int :param logger: write exception on a logger instad of using print(). :type logger: logging.Logger :param boost: if ``True``, consider the current nutritive sources as unlimited (for example, if LB of ``EX_fe3_e`` is -0.0075, it will be raised to -1000). :type boost: bool :returns: IDs of reactions proposed during the 1st solution. :rtype: list .. py:function:: get_universe(staining='neg') Return a CarveMe universe. :param staining: 'pos' or 'neg'. :type staining: str :returns: the selected universe. :rtype: cobra.Model .. py:function:: get_biolog_mappings() Return the Biolog mappings internally used by gempipe. Plate information is taken from DuctApe (https://doi.org/10.1016/j.ygeno.2013.11.005). :returns: the Biolog mappings. :rtype: pandas.DataFrame .. py:function:: add_demand(model, mid) Create a demand reaction, useful for debugging models. :param model: target model. :type model: cobra.Model :param mid: metabolite ID (compartment included) for which to create the demand. :type mid: str :returns: demand reaction ID. :rtype: str .. py:function:: can_synth(model, mid) Check if the model can synthesize a given metabolite. :param model: target model. :type model: cobra.Model :param mid: metabolite ID (compartment included) for which to check the synthesis. :type mid: str :returns: `[0]` ``True`` if `mid` can be synthesized (``optimal`` status and positive flux). `[1]` maximal theoretical synthesis flux. `[2]` status of the optimizer. :rtype: (bool, float, str) .. py:function:: check_reactants(model, rid, verbose=True) Check which reactant of a given reaction cannot be synthesized. :param model: target model. :type model: cobra.Model :param rid: reaction ID for which to check the synthesis of the reactants. :type rid: str :param verbose: if False, just return the list of metabolite IDs without printing any further information. :type verbose: bool :returns: IDs of blocked reactants. :rtype: list .. py:function:: sensitivity_analysis(model, scaled=False, top=3, mid=None) Perform a sensitivity analysis (or reduced costs analysis) focused on the EX_change reaction. It is based on the current model's objective. The returned dictionary is sorted from most negative to most positive values. :param model: target model. :type model: cobra.Model :param scaled: whether to scale to the current objective value. :type scaled: bool :param top: get just the first and last `top` EX_change reactions. If ``None``, all EX_change reactions will be returned. :type top: int :param mid: instead of optimizing for the current objective reaction, do the analysis on the biosynthesis of a specific metabolite having ID `mid`. If `None` it will be ignored. :type mid: str :returns: reduced costs keyd by EX_change reaction ID. :rtype: dict .. py:function:: query_pam(name=[], ko=[], kr=[], km=[], kt=[], ec=[], des=[], pfam=[], annot=False, model=None, rid=None) Show clusters in the context of a PAM. Clusters can be selected based on thier functional annotation. :param name: preferred names to search for, eg ['fabB', 'fabG']. :type name: list :param ko: KEGG Orthologs (KOs) to search for, eg ['K00647', 'K00059']. :type ko: list :param kr: KEGG Reaction IDs to search for, eg ['R03460']. :type kr: list :param km: KEGG Module IDs to search for, eg ['M00846']. :type km: list :param kt: KEGG Transport IDs to search for, eg ['3.A.3.2']. :type kt: list :param ec: EC codes to search for, eg ['2.5.1.19']. :type ec: list :param des: gene function descriptions to search for. :type des: list :param pfam: PFAM domains to search for, eg ['Pyridox_ox_2']. :type pfam: list :param annot: if ``True``, return the functional annotation table instead of the PAM. :type annot: bool :param model: if not ``None``, create a new column `modeled` as first, revealing the presence of each cluster in the model. :type model: cobra.Model :param rid: show clusters involved in the specified reactions (provided their IDs). Requires ``model``. :type rid: list :returns: filtered PAM or annotation table. :rtype: pandas.DataFrame .. py:function:: import_from_universe(model, universe, rid, bounds=None, gpr=None) Insert a new reaction taken from a universe model. :param model: target model to expand with new reactions. :type model: cobra.Model :param universe: universe model, source of new reactions. :type universe: cobra.Model :param rid: Id of the reaction to transfer. :type rid: str :param bounds: bounds to apply to the inserted reaction, eg (0, 1000). If ``None``, bounds from universe will be retained. :type bounds: tuple :param gpr: GPR to associate to the inserted reaction. If ``None``, no GPR will be associated. :type gpr: str .. py:function:: ss_preview(panmodel, accession) Create a preview of a strain-specific model given its accession and the starting draft pan-GSMM. :param panmodel: draft pan-GSMM (ideally undergoing manual curation) from which to derive the strain-specific model. :type panmodel: cobra.Model :param accession: accession of the strain for which to derive the strain-specific model. :type accession: str :returns: strain-specific metabolic model. :rtype: cobra.Model .. py:function:: biolog_preview(model, starting_C=None, starting_N=None, starting_P=None, starting_S=None, seed=False) Get a preview of of the Biolog simulations for the provided model. :param model: target model. :type model: cobra.Model :param starting_C: starting C source; if `None`, will be assigned to `EX_glc__D_e` or `EX_cpd00027_e0` depending on the selected database. :type starting_C: str :param starting_N: starting N source; if `None`, will be assigned to `EX_nh4_e` or `EX_cpd00013_e0` depending on the selected database. :type starting_N: str :param starting_P: starting P source; if `None`, will be assigned to `EX_pi_e` or `EX_cpd00009_e0` depending on the selected database. :type starting_P: str :param starting_S: starting S source; if `None`, will be assigned to `EX_so4_e` or `EX_cpd00048_e0` depending on the selected database. :type starting_S: str :param seed: if `True`, use the SEED notation instead of the BiGG notation. :type seed: bool :returns: Biolog simulations. :rtype: pandas.DataFrame .. py:function:: add_reaction(model, rid, rstring, bounds=None, name='', gpr=None) Add a new reaction to the model. Useful for example when the universe needs to be expanded. :param model: target model to expand with the new reaction. :type model: cobra.Model :param rid: ID for the new reaction. :type rid: str :param rstring: string describing the reaction. :type rstring: str :param bounds: lower and upper bound for the new reaction. :type bounds: set :param name: a name for the new reaction. :type name: str :param gpr: string describing the GPR. :type gpr: str .. py:function:: add_metabolite(model, mid, formula=None, charge=None, name='') Add a new metabolite to the model. Useful for example when the universe needs to be expanded. :param model: target model to expand with the new metabolite. :type model: cobra.Model :param mid: ID for the new metabolite. :type mid: str :param formula: string the chemical formula. :type formula: str :param charge: charge of the metabolite. :type charge: int :param name: a name for the new metabolite. :type name: str .. py:function:: search_similar(panmodel, rid, field='ko', unmod=False, species=None, showgpr=False, forceshow=False) Search the PAM for gene clusters having functional annotation similar to that of gene clusters involved in the specified reaction of the pan-GSMM. First, the reaction `rid` is extracted from the `panmodel`. Then, gene clusters are extracted from its GPR. The PAM is finally searched for all the gene clusters having the same functional annotation in one of the following fields: 'ko', 'pfam', 'kt', and 'ec'. :param panmodel: a pan-GSMM having the reaction `rid`. :type panmodel: cobra.Model :param rid: ID of the reaction using the gene clusters on which to focus the search. :type rid: str :param field: functional annotation field to be used to extract similar gene clusters. :type field: str :param unmod: if ``True``, show only gene clusters that are not yet part of the `panmodel` (unmodeled). :type unmod: bool :param species: show only columns (genomes) having this substring in thier name (useful to filter for particular species or strains). :type species: str :param showgpr: if ``True``, show the pan-GSMM GPR of the selected reaction `rid`. :type showgpr: bool :param forceshow: if ``True``, display the results table with no limits on the number of displayable rows and columns. :type forceshow: bool :returns: PAM-derived results table, mixing presence/absence of gene clusters together with their functional annotation. :rtype: pandas.DataFrame