diff --git a/README.rst b/README.rst old mode 100644 new mode 100755 diff --git a/docs/index.rst b/docs/index.rst index 0a704754..2c8f67e4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,21 +1,21 @@ -.. sample documentation master file, created by - sphinx-quickstart on Mon Apr 16 21:22:43 2012. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to sample's documentation! -================================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` +.. sample documentation master file, created by + sphinx-quickstart on Mon Apr 16 21:22:43 2012. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to sample's documentation! +================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/source/api.rst b/docs/source/api.rst index db18e3e7..d453fd2c 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -1,12 +1,90 @@ -ModelSEEDpy API -________________________________________________________________________ - -The detailed documentation of all user-operable classes and functions in the ModelSEEDpy library are provided. - -.. toctree:: - - contents - core/core_index - community/community_index - fbapkg/fbapkg_index - ml/ml_index +ModelSEEDpy API +________________________________________________________________________ + +The detailed documentation of all user-operable classes and functions in the ModelSEEDpy library are provided. + + +core +--------- + +The ``core`` sub-library permits parsing and manipulating metabolic models:: + + from modelseedpy.core import * + + +.. toctree:: + :includehidden: + + core/biology_api + core/fbahelper_api + core/gapfillinghelper_api + core/msatpcorrection_api + core/msbuilder_api + core/mseditorapi_api + core/msgenome_api + core/msgapfill_api + core/msgenomeclassifier_api + core/msgrowthphenotypes_api + core/msmedia_api + core/msmodel_api + core/msmodelutils_api + core/mstemplate_api + core/rpcclient_api + core/template_api + + +community +------------ + +The ``community`` sub-library compatibilizes transport reactions of individual models for a community model and simulates interactions amongst community members:: + + from modelseedpy.community import * + + +.. toctree:: + :includehidden: + + community/commkineticpkg_api + community/dfbapkg_api + community/mssmetana_api + community/mscommphitting_api + community/mscommunity_api + community/mscompatibility_api + + +fbapkg +------------ + +The ``fbapkg`` sub-library constrains and investigates metabolic models through Flux Balance Analysis methods:: + + from modelseedpy.fbapkg import * + +.. toctree:: + :includehidden: + + fbapkg/bilevel_api + fbapkg/changeoptpkg_api + fbapkg/drainfluxes_api + fbapkg/elementuptakepkg_api + fbapkg/flexiblebiomass_api + fbapkg/fluxfitting_api + fbapkg/gapfillingpkg_api + fbapkg/kbasemedia_api + fbapkg/metabofba_api + fbapkg/proteomefitting_api + fbapkg/reactionuse_api + fbapkg/tfa_api + + +ml +------------ + +The ``ml`` sub-library supports parsing features from genomes, with accessibility to KBase:: + + from modelseedpy.ml import * + + +.. toctree:: + :includehidden: + + ml/predict_phenotypes_api diff --git a/docs/source/build.rst b/docs/source/build.rst index 38c00ced..4109ce46 100644 --- a/docs/source/build.rst +++ b/docs/source/build.rst @@ -1,6 +1,6 @@ -Building a Model -________________________________________________________________________ - -Models are constructed through the following sequence. - -1) +Building a Model +________________________________________________________________________ + +Models are constructed through the following sequence. + +1) diff --git a/docs/source/community/community_index.rst b/docs/source/community/community_index.rst deleted file mode 100644 index 74e0cafb..00000000 --- a/docs/source/community/community_index.rst +++ /dev/null @@ -1,33 +0,0 @@ -community -________________________________________________________________________ - -|PyPI version| |License| |Downloads| - -.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen - :target: https://pypi.org/project/modelseedpy/ - :alt: PyPI version - -.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg - :target: https://github.com/freiburgermsu/modelseedpy/actions - :alt: Actions Status - -.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg - :target: https://opensource.org/licenses/MIT - :alt: License - -.. |Downloads| image:: https://pepy.tech/badge/modelseedpy - :target: https://pepy.tech/project/modelseedpy - :alt: Downloads - -The ModelSEEDpy packages that compatibilize the transport reactions of individual models and simulate cross-feeding amongst community members are organized in the ``community`` directory of the ModelSEEDpy library. These packages are imported via:: - - from modelseedpy.community import * - -and include the following: - -.. toctree:: - - commkineticpkg_api - dfbapkg_api - mscommunity_api - mscompatibility_api diff --git a/docs/source/community/dfbapkg_api.rst b/docs/source/community/dfbapkg_api.rst index 7e39ef7e..7a68a5af 100644 --- a/docs/source/community/dfbapkg_api.rst +++ b/docs/source/community/dfbapkg_api.rst @@ -1,178 +1,178 @@ -dFBA Package --------------- - -++++++++++ -dFBAPkg() -++++++++++ - -This class defines and executes dynamic FBA simulations of COBRA models: - -.. code-block:: python - - from modelseedpy.fbapkg import dFBAPkg - dfba = dFBAPkg(model, modelseed_db_path, solver = 'glpk', warnings = True, verbose = False, printing = False, jupyter = False) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. -- *modelseed_db_path* ``str``: specifies the path to a local version of the ModelSEED Database. -- *solver* ``str``: specifies which linear programmating algorithm will be used to simulate the FBA model. The `glpk` solver is selected by default since it is free and universally accessible. -- *warnings*, *verbose*, & *printing* ``bool``: specifies whether simulation warnings, details and calculations, or results will be printed, respectively. These options are valuable for troubleshooting. -- *jupyter* ``bool``: specifies whether simulation is being conducted in a Jupyter notebook, in which case the printed DataFrames will be expressed with the ``display()`` function. - - ----------------------- -simulate() ----------------------- - -A cobrakbase model is simulated with the parameterized kinetics data over the defined time and conditions: - -.. code-block:: python - - dfba.simulate(kinetics_path = None, initial_concentrations_M: dict = {}, total_time = 200, timestep = 20, export_name = None, - export_directory = None, kinetics_data = {}, temperature = 25, p_h = 7, cellular_dry_mass_fg = 222, cellular_fL = 1, - figure_title = 'Metabolic perturbation', included_metabolites = [], labeled_plots = True, visualize = True, export = True) - -- *kinetics_path* & *kinetics_data* ``str`` & ``dict``: either the path to a `JSON` file that can be imported or a dictionary argument that provide the kinetics data that will constrain the model in the simulation. The `JSON` structure in both means of providing the data, and possesses the following nesting: ```` -> ```` -> ``substituted_rate_law`` + ``initial_concentrations_M`` + optional keys (such as ``metadata``). The ``substituted_rate_law`` key must contain the mathematically valid rate law expression as a string that can be evaluated through the `eval() built-in function `_ of Python, where each metabolite in the rate law is represented by a **single letter variable** that is defined with a `ModelSEED Compound ID `_ in the ``met_id`` key. The concentrations of the ``initial_concentrations_M`` key must be provided in units of Molar and defined for the rate law variable letters. - -.. code-block:: json - - { - "R_3OAS140": { - "source_1": { - "substituted_rate_law": "(68.0*A*B)/(50.0*0.34*C+360.0*B+0.34*A+A*B*C)", - "initial_concentrations_M": { - "A": 0.0200, - "C": 0.022, - "B": 0.0014 - }, - "met_id": { - "A": "cpd11468", - "B": "cpd00067", - "C": "cpd11492" - } - } - }, - "rxn2": { - "source_1": { - "substituted_rate_law": "(A*B)/(50.0*0.34*C+3*B+0.34*A+C)", - "initial_concentrations_M": { - "A": 0.0200, - "C": 0.022, - "B": 0.0012 - }, - "met_id": { - "A": "cpd11468", - "B": "cpd00011", - "C": "cpd11492" - } - } - } - } - -The additional keys can provide provenance of the datum source: - -.. code-block:: json - - { - "2-Oxogluterate dehydrogenase": { - "55199": { - "RateLaw": "Vmax*S/(Km+S)", - "initial_concentrations_M": { - "S": 1.6e-08 - }, - "metadata": { - "Buffer": "[50 mm Mops, 8 mm TCEP, 50 mm Mops, 8 mm TCEP]", - "Enzyme Variant": "wildtype", - "KineticMechanismType": "Michaelis-Menten", - "Organism": "Pisum sativum", - "Pathway": null, - "Product": "NADH;H+;Oxidized N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", - "Publication": "Neuburger M, Polidori AM, Pi\u00e8tre E, Faure M, Jourdain A, Bourguignon J, Pucci B, Douce R: Interaction between the lipoamide-containing H-protein and the lipoamide dehydrogenase (L-protein) of the glycine decarboxylase multienzyme system. 1. Biochemical studies., Eur J Biochem 2000 (267) , 2882-9", - "Temperature": "30.0", - "annotations": { - "ECNumber": "1.8.1.4", - "KeggReactionID": null, - "PubMedID": 10806385.0, - "SabioReactionID": 13969 - }, - "pH": "7.5", - "reaction_string": " <-> Nicotinamide adenine dinucleotide-reduced + H+" - }, - "substituted_parameters": { - "Km": { - "comment": "-", - "deviat.": "10", - "end val.": "-", - "species": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", - "start val.": "170.0", - "type": "Km", - "unit": "\u00b5M" - }, - "Vmax": { - "comment": "-", - "deviat.": "7", - "end val.": "-", - "species": "-", - "start val.": "90.0", - "type": "Vmax", - "unit": "nmol/min" - } - }, - "substituted_rate_law": "1.5000000000000002e-09*S/(0.00016999999999999999+S)", - "variables_molar": { - "Km": "0.00016999999999999999", - "Vmax": "1.5000000000000002e-09" - }, - "variables_name": { - "Km": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", - "S": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", - "Vmax": "-" - } - } - } - } - -- *initial_concentrations_M* ``dict``: specifies initial concentrations of the simulated metabolites that supplant values from the kinetics data. Every metabolite in this dictionary must be defined in the model, and the concentrations in units of molar must be assigned according to the metabolite's ModelSEED Compound ID: - -.. code-block:: json - - { - "cpd00002":0.0200, - "cpd00008":0.0014 - } - -- *total_time* & *timestep* ``float``: specify the total time and the timstep of the simulation in minutes. -- *export_name* & *export_directory* ``str``: specify the folder name and directory to which the simulation content will be exported, where `None` defaults to a unique folder name in the current working directory. -- *temperature* & *p_h* ``float``: optionally specify the temperature and pH at which the simulation will occur, respective, which allows the most closely matched datum to be parameterized, where multiple datum exist for the same reaction. -- *cellular_dry_mass_fg* & *cellular_fL* ``float``: The `dry mass `_ and `volume `_ of the simulated cell, in base units of femto- grams and liters, respectively. These values can be sourced from literature, and the standard values may approximate prokaryotic cells. -- *figure_title*, *included_metabolites*, & *labeled_plots* ``str``, ``list``, & ``bool``: specify the title of the simulation Figure, the metabolites that will be plotted in the simulation Figure, and where each plot will be labeled with text to clarify its identity. -- *visualize* & *export* ``bool``: specifies whether the simulation results will be visually depicted or exported to a specified folder, respectively. - - - ----------------------- -Accessible content ----------------------- - -A multitude of values are stored within the ``dFBA`` object, and can be subsequently used in a workflow. The complete list of content within the ``dFBA`` object can be printed through the built-in ``dir()`` function in the following example sequence: - -.. code-block:: python - - # conduct a dFBA simulation - from dfbapy import dFBA - dfba = dFBA(model) - dfba.simulate(reaction_kinetics, None, total_time, timestep) - - # evaluate the dFBA simulation contents - print(dir(dfba)) - -The following list highlights stored content in the ``dFBA`` object after a simulation: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that is simulated. -- *concentrations* & *fluxes* ``pandas.core.frame.DataFrame``: `Pandas DataFrames `_ that contain the ``mM`` concentrations (or changes thereof) for each metabolite and ``mmol/g_(dw)/hr`` fluxes for each reaction, respectively. -- *kinetics_data* ``dict``: A dictionary of the kinetics data constrains the model. -- *timestep_value* ``float``: The simulation timestep in minutes. -- *compound_ids* ``dict``: A dictionary of all ModelSEED IDs with their names as values, which is loaded from the ModelSEED Database via the parameterized path. -- *cell_dry_mass* & *cell_liters* ``float``: The mass and volume of the simulated cell. -- *changed* & *unchanged* ``set``: The exclusive sets of metabolites whose concentrations either changed or did not change over the simulation, respectively. -- *constrained* ``OrderedDict``: A dictionary with reaction names as the keys and their respective kinetic constraints as the values. -- *solutions* ``list``: A list of the Cobra solutions from each timestep that constitute the columns of the `fluxes` DataFrame. +dFBApkg +-------------- + +++++++++++ +dFBAPkg() +++++++++++ + +This class defines and executes dynamic FBA simulations of COBRA models: + +.. code-block:: python + + from modelseedpy.community import dFBAPkg + dfba = dFBAPkg(model, modelseed_db_path, solver = 'glpk', warnings = True, verbose = False, printing = False, jupyter = False) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. +- *modelseed_db_path* ``str``: specifies the path to a local version of the ModelSEED Database. +- *solver* ``str``: specifies which linear programmating algorithm will be used to simulate the FBA model. The `glpk` solver is selected by default since it is free and universally accessible. +- *warnings*, *verbose*, & *printing* ``bool``: specifies whether simulation warnings, details and calculations, or results will be printed, respectively. These options are valuable for troubleshooting. +- *jupyter* ``bool``: specifies whether simulation is being conducted in a Jupyter notebook, in which case the printed DataFrames will be expressed with the ``display()`` function. + + +---------------------- +simulate() +---------------------- + +A cobrakbase model is simulated with the parameterized kinetics data over the defined time and conditions: + +.. code-block:: python + + dfba.simulate(kinetics_path = None, initial_concentrations_M: dict = {}, total_time = 200, timestep = 20, export_name = None, + export_directory = None, kinetics_data = {}, temperature = 25, p_h = 7, cellular_dry_mass_fg = 222, cellular_fL = 1, + figure_title = 'Metabolic perturbation', included_metabolites = [], labeled_plots = True, visualize = True, export = True) + +- *kinetics_path* & *kinetics_data* ``str`` & ``dict``: either the path to a `JSON` file that can be imported or a dictionary argument that provide the kinetics data that will constrain the model in the simulation. The `JSON` structure in both means of providing the data, and possesses the following nesting: ```` -> ```` -> ``substituted_rate_law`` + ``initial_concentrations_M`` + optional keys (such as ``metadata``). The ``substituted_rate_law`` key must contain the mathematically valid rate law expression as a string that can be evaluated through the `eval() built-in function `_ of Python, where each metabolite in the rate law is represented by a **single letter variable** that is defined with a `ModelSEED Compound ID `_ in the ``met_id`` key. The concentrations of the ``initial_concentrations_M`` key must be provided in units of Molar and defined for the rate law variable letters. + +.. code-block:: json + + { + "R_3OAS140": { + "source_1": { + "substituted_rate_law": "(68.0*A*B)/(50.0*0.34*C+360.0*B+0.34*A+A*B*C)", + "initial_concentrations_M": { + "A": 0.0200, + "C": 0.022, + "B": 0.0014 + }, + "met_id": { + "A": "cpd11468", + "B": "cpd00067", + "C": "cpd11492" + } + } + }, + "rxn2": { + "source_1": { + "substituted_rate_law": "(A*B)/(50.0*0.34*C+3*B+0.34*A+C)", + "initial_concentrations_M": { + "A": 0.0200, + "C": 0.022, + "B": 0.0012 + }, + "met_id": { + "A": "cpd11468", + "B": "cpd00011", + "C": "cpd11492" + } + } + } + } + +The additional keys can provide provenance of the datum source: + +.. code-block:: json + + { + "2-Oxogluterate dehydrogenase": { + "55199": { + "RateLaw": "Vmax*S/(Km+S)", + "initial_concentrations_M": { + "S": 1.6e-08 + }, + "metadata": { + "Buffer": "[50 mm Mops, 8 mm TCEP, 50 mm Mops, 8 mm TCEP]", + "Enzyme Variant": "wildtype", + "KineticMechanismType": "Michaelis-Menten", + "Organism": "Pisum sativum", + "Pathway": null, + "Product": "NADH;H+;Oxidized N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", + "Publication": "Neuburger M, Polidori AM, Pi\u00e8tre E, Faure M, Jourdain A, Bourguignon J, Pucci B, Douce R: Interaction between the lipoamide-containing H-protein and the lipoamide dehydrogenase (L-protein) of the glycine decarboxylase multienzyme system. 1. Biochemical studies., Eur J Biochem 2000 (267) , 2882-9", + "Temperature": "30.0", + "annotations": { + "ECNumber": "1.8.1.4", + "KeggReactionID": null, + "PubMedID": 10806385.0, + "SabioReactionID": 13969 + }, + "pH": "7.5", + "reaction_string": " <-> Nicotinamide adenine dinucleotide-reduced + H+" + }, + "substituted_parameters": { + "Km": { + "comment": "-", + "deviat.": "10", + "end val.": "-", + "species": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", + "start val.": "170.0", + "type": "Km", + "unit": "\u00b5M" + }, + "Vmax": { + "comment": "-", + "deviat.": "7", + "end val.": "-", + "species": "-", + "start val.": "90.0", + "type": "Vmax", + "unit": "nmol/min" + } + }, + "substituted_rate_law": "1.5000000000000002e-09*S/(0.00016999999999999999+S)", + "variables_molar": { + "Km": "0.00016999999999999999", + "Vmax": "1.5000000000000002e-09" + }, + "variables_name": { + "Km": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", + "S": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine", + "Vmax": "-" + } + } + } + } + +- *initial_concentrations_M* ``dict``: specifies initial concentrations of the simulated metabolites that supplant values from the kinetics data. Every metabolite in this dictionary must be defined in the model, and the concentrations in units of molar must be assigned according to the metabolite's ModelSEED Compound ID: + +.. code-block:: json + + { + "cpd00002":0.0200, + "cpd00008":0.0014 + } + +- *total_time* & *timestep* ``float``: specify the total time and the timstep of the simulation in minutes. +- *export_name* & *export_directory* ``str``: specify the folder name and directory to which the simulation content will be exported, where `None` defaults to a unique folder name in the current working directory. +- *temperature* & *p_h* ``float``: optionally specify the temperature and pH at which the simulation will occur, respective, which allows the most closely matched datum to be parameterized, where multiple datum exist for the same reaction. +- *cellular_dry_mass_fg* & *cellular_fL* ``float``: The `dry mass `_ and `volume `_ of the simulated cell, in base units of femto- grams and liters, respectively. These values can be sourced from literature, and the standard values may approximate prokaryotic cells. +- *figure_title*, *included_metabolites*, & *labeled_plots* ``str``, ``list``, & ``bool``: specify the title of the simulation Figure, the metabolites that will be plotted in the simulation Figure, and where each plot will be labeled with text to clarify its identity. +- *visualize* & *export* ``bool``: specifies whether the simulation results will be visually depicted or exported to a specified folder, respectively. + + + +---------------------- +Accessible content +---------------------- + +A multitude of values are stored within the ``dFBA`` object, and can be subsequently used in a workflow. The complete list of content within the ``dFBA`` object can be printed through the built-in ``dir()`` function in the following example sequence: + +.. code-block:: python + + # conduct a dFBA simulation + from dfbapy import dFBA + dfba = dFBA(model) + dfba.simulate(reaction_kinetics, None, total_time, timestep) + + # evaluate the dFBA simulation contents + print(dir(dfba)) + +The following list highlights stored content in the ``dFBA`` object after a simulation: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that is simulated. +- *concentrations* & *fluxes* ``pandas.core.frame.DataFrame``: `Pandas DataFrames `_ that contain the ``mM`` concentrations (or changes thereof) for each metabolite and ``mmol/g_(dw)/hr`` fluxes for each reaction, respectively. +- *kinetics_data* ``dict``: A dictionary of the kinetics data constrains the model. +- *timestep_value* ``float``: The simulation timestep in minutes. +- *compound_ids* ``dict``: A dictionary of all ModelSEED IDs with their names as values, which is loaded from the ModelSEED Database via the parameterized path. +- *cell_dry_mass* & *cell_liters* ``float``: The mass and volume of the simulated cell. +- *changed* & *unchanged* ``set``: The exclusive sets of metabolites whose concentrations either changed or did not change over the simulation, respectively. +- *constrained* ``OrderedDict``: A dictionary with reaction names as the keys and their respective kinetic constraints as the values. +- *solutions* ``list``: A list of the Cobra solutions from each timestep that constitute the columns of the `fluxes` DataFrame. diff --git a/docs/source/community/mscommphitting_api.rst b/docs/source/community/mscommphitting_api.rst new file mode 100644 index 00000000..f611a0a7 --- /dev/null +++ b/docs/source/community/mscommphitting_api.rst @@ -0,0 +1,312 @@ +mscommphitting +-------------------------- + ++++++++++++++++++++++++++ +MSCommPhitting() ++++++++++++++++++++++++++ + +This class contains the functions that load and parameterize experimental data, define a linear problem for the defined system with the parameterized data, simulates the LP, and graphically the results: + +.. code-block:: python + + from modelseedpy.community import MSCommPhitting + mscommfit = MSCommPhitting(msdb_path, community_members: dict=None, fluxes_df=None, + growth_df=None, carbon_conc=None, media_conc=None, + experimental_metadata=None, base_media=None, solver: str = "glpk", + all_phenotypes=True, data_paths: dict = None, + species_abundances: str = None, carbon_conc_series: dict = None, + ignore_trials: Union[dict, list] = None, ignore_timesteps: list = None, + species_identities_rows=None, significant_deviation: float = 2, + extract_zip_path: str = None) + +The member models and experimental data can be parsed and parameterized or the processed files of experimental data can be passed in the class initialization. The former option is enacted by providing the ``community_members`` argument or when one of the ``fluxes_df`` and ``growth_df`` arguments are missing; the latter option is enacted otherwise. + + +- *msdb_path* ``str``: the path to the ModelSEED Database GitHub repository, which is loaded and referenced by the model. This is the only ubiquitously required argument. +- *community_members* ``dict``: a description of the member models and phenotypes in the simulated community. A community of *E. coli* (Acetate and Maltose phenotypes) and *Pseudomonas fluorescens* (Acetate and 4-Hydroxybenzoate phenotypes) would be expressed by the following block, where ``ecoli`` and ``pf`` denote the COBRA model objects and the list keys with "consumed" and "excreted" describe the set of metabolites that are consumed or excreted for the given growth phenotype, respectively. + +.. code-block:: json + + { + ecoli: { + "name": "ecoli", + "phenotypes": { + "Maltose": {"consumed":["cpd00179"], "excreted":["cpd00029"]}, + "Acetate": {"consumed":["cpd00029"]}, + } + }, + pf: { + "name": "pf", + "phenotypes": { + "Acetate": {"consumed":["cpd00029"]}, + "4-Hydroxybenzoate": {"consumed":["cpd00136"]} + } + } + } + +- *fluxes_df* ``Pandas DataFrame``: a DataFrame that consists of the metabolic flux profile for each phenotype that is described in ``community_members`` and will be simulated by CommPhiting. Each column is a separate phenotype, each row is an exchange reaction, and each element is the flux of the exchange reaction for the respective phenotype. This argument offers an opportunity to save compute time by loading a defined DataFrame from a previous simulation. +- *growth_df* ``Pandas DataFrame``: a DataFrame that contains parsed and organized experimental data to which the model will fit. The DataFrame is indexed by ``short_codes`` that concisely describe the experiment, while the ``trial_IDs`` fields offer more detail about the trial, including the relative abundances of each member and the initial *mM* concentrations of all pertinent compounds delimited by ``-`` hyphens. This argument offers an opportunity to save compute time by loading a defined DataFrame from a previous simulation. +- *carbon_conc* ``dict``: the concentrations (``values``) of carbon sources as ModelSEED IDs (``keys``) in the media, denoted by either ``columns`` or ``rows`` for the dimension in the experimental well-plate where the specified concentration varies. + +.. code-block:: json + + { + "rows": { + "cpd00136": {"B":0, "C": 0, "D": 1, "E": 1, "F": 4, "G": 4}, + "cpd00179": {"B":5, "C": 5, "D":5, "E": 5, "F": 5, "G": 5}, + }, + "columns": { + "cpd00029": {2:100, 3: 50, 4: 25, 5: 12.5, 6: 6.25, 7: 3} + } + } + +- *media_conc* ``dict``: the mM concentration of each media component indexed by its ModelSEED ID. +- *experimental_metadata* ``Pandas DataFrame``: a DataFrame that consists of metadata for the experiments, indexed by the ``short_codes``. The ``trial_IDs`` column emulates that of the ``growth_df`` DataFrame. The a ``additional_compounds`` column lists the chemicals, and their initial and final mM concentrations, that augment the media defined in the ``base_media`` column. The ``strains`` column lists the community members and their respective relative abundances (an abbreviated form of this information is provided in the ``trial_IDs`` column). The ``date`` column provides the date when the experiment occurred. +- *base_media* ``ModelSEEDpy Media``: a media object that is parsed to acquire the concentration for each component in the media, and can therefore supplement the omission of the ``media_conc`` argument. +- *solver* ``str``: the Linear Programming solver that will be used to solve the constructed problem. The open-source GLPK solveris used by default, to accommodate the greatest number of users. +- *all_phenotypes* ``bool``: specifies whether all phenotypes for the respective members will be defined and simulated. +- *data_paths* ``dict``: the local path to the data spreadsheet and the identification of pertinent content in the worksheets: + +.. code-block:: json + + { + "path":"data/Jeffs_data/PF-EC 4-29-22 ratios and 4HB changes.xlsx", + "Raw OD(590)":"OD", + "mNeonGreen":"pf", + "mRuby":"ecoli" + } + +- *species_abundance* ``dict``: the relative abundances of all members in the community for each column in the experimental well-plates: + +.. code-block:: json + + { + 1:{"ecoli":0, "pf":1}, + 2:{"ecoli":1, "pf":50}, + 3:{"ecoli":1, "pf":20}, + 4:{"ecoli":1, "pf":10}, + 5:{"ecoli":1, "pf":3}, + 6:{"ecoli":1, "pf":1}, + 7:{"ecoli":3, "pf":1}, + 8:{"ecoli":10, "pf":1}, + 9:{"ecoli":20, "pf":1}, + 10:{"ecoli":1, "pf":0}, + 11:{"ecoli":0, "pf":0} + } + +- *ignore_trials* ``list``: the trials (identified through the row & column well-plate coordinates) that will be ignored in the simulation. +- *ignore_timesteps* ``list``: the timesteps that will be ignored in the simulation. +- *species_identities_rows* ``dict``: the specification of strains for each member species, where it differs, per row in the well-plate experiments: + +.. code-block:: json + + { + 1:{"ecoli":"mRuby"}, + 2:{"ecoli":"ACS"}, + 3:{"ecoli":"mRuby"}, + 4:{"ecoli":"ACS"}, + 5:{"ecoli":"mRuby"}, + 6:{"ecoli":"ACS"} + } + +- *significant_deviation* ``float``: the smallest multiple of a trial mean relative to its initial value that permits its inclusion in the simulation. +- *extract_zip_path* ``str``: the path of a zipped file that contents some or all of the files that must be loaded in the simulation. + +----------------------------- +fit() +----------------------------- + +The parsed experimental data is used to define and constrain a Global Linear Problem of the community system: + +.. code-block:: python + + mscommfit.fit(parameters:dict=None, mets_to_track: list = None, + rel_final_conc:dict=None, zero_start:list=None, + abs_final_conc:dict=None, graphs: list = None, + data_timesteps: dict = None, export_zip_name: str = None, + export_parameters: bool = True, requisite_biomass: dict = None, + export_lp: str = "CommPhitting.lp", figures_zip_name:str=None, + publishing:bool=False, primals_export_path=None) + + +- *parameters* ``dict``: simulation parameters that will overwrite default and calculated options. The possible key values include + +.. csv-table:: + :header: "Parameter", "Default", "Description" + + "timestep_hr", "the average timestep that is parsed from the data", "the timestep size of the simulation in hours" + "cvct", "0.01", "the coefficient that penalizes phenotype conversion to the stationary phase" + "cvcf", "0.01", "the coefficient that penalizes phenotype conversion from the stationary phase" + "bcv", "0.1", "the highest fraction of species biomass that can convert phenotypes in a timestep" + "cvmin", "0", "the lowest fraction of biomass that converts phenotypes in a single timestep" + "kcat", "0.33", "the growth constant for linear 1st-order kinetics" + "carbon_sources", "["cpd00136", "cpd00179"]", "the ModelSEED IDs of the carbon sources in the media" + "diffpos", "1", "the objective coefficient that corresponds with the positive difference between experimental and predicted biomass values" + "diffneg", "1", "the objective coefficient that corresponds with the negative difference between experimental and predicted biomass values" + "stationary", "0.075", "the penalty coefficient for the stationary phenotype" + +- *mets_to_track* ``list``: the ModelSEED ID"s of all compounds that will be graphically plotted, unless metabolites are specifically listed in a graph of the ``graphs`` argument. +- *rel_final_conc* ``dict``: the final concentration of a phenotype compound in the media that is normalized by its initial concentration: e.g. + +.. code-block:: json + + { + "cpd00179":0.1 + } + +denotes that the final concentration of Maltose is 10% of its initial concentration. + +- *zero_start* ``list``: the compounds that possess a zero initial concentration, which is often assumed for cross-feeding compounds that are not provided in the media. +- *abs_final_conc* ``dict``: the final mM concentration of a phenotype compound in the media, which follows the same syntactic structure as the ``rel_final_conc`` parameter. +- *graphs* ``list``: the collection of graphs that will be plotted from the primal values after the simulation executes. Each dictionary in the list describes a figure, with descriptive keys that specify the type of figure, attributes of the figure, and the data that populates the figure. The ``trial`` key designates which experimental trial will be simulated. The ``experimental_data`` key accepts a boolean for whether the experimental growth data is overlaid as a scatter upon the predicted biomass plots, where the default is ``true``. The ``content`` key designates what content of the trial will be plotted, with acceptable string values of + +.. csv-table:: + :header: "content option", "Description" + + "biomass", "The g/L biomass of the defined phenotypes" + "total_biomass", "The g/L biomass of the defined phenotypes and the total OD biomass of the complete community" + "conc", "The mM concentration of the metabolites that are defined in either 1) an accompanying ``mets`` key that corresponds to a list of metabolites to plot, 2) the ``mets_to_track`` parameter of the function, or 3) all carbonaceous metabolites in the simulated phenotypes as a default." + +Graphing designations for non-concentration figures can be tailored with the ``species`` and ``phenotype`` keys, which correspond lists of the species and phenotypes for which primal values will be graphed, or a string ``"*"`` can be passed as the value to denote all available species and phenotypes will be plotted. Finally, the ``parsed`` key accepts a boolean for whether the biomass plots are segregated for each species, which can alleviate busyness for complex communities. All of these plots are all defined with time on the x-axis, and either mM concentration or g/L on the y-axis depending upon the plotted content. + +The following ``graphs`` argument samples the range of supported figures: + +.. code-block:: json + + [ + { + "trial":"G48", + "phenotype": "*", + "content": "biomass", + "experimental_data": false + }, + { + "trial":"G48", + "content": "conc" + }, + { + "trial":"G48", + "phenotype": "*", + "content": "biomass", + "parsed": true + }, + { + "trial":"G48", + "content": "total_biomass", + "experimental_data": true + } + ] + +- *data_timesteps* ``dict``: a list of timesteps for each ``short_code`` trial that will be simulated, which can be a more succinct tool for tailoring a simulation than specifying the timesteps to ignore from the full dataset. +- *export_zip_name* ``str``: the name of the zip file to which the simulation contents will be stored, where the omission of this parameter does not export content to a zip file. +- *export_parameters* ``bool``: specifies whether the simulation parameters will be exported as CSV to the current working directory. +- *requisite_biomass* ``dict``: the requisite amount of biomass that must grow for the prescribed final metabolite concentration to be achieved, according to the phenotype flux profiles. This is calculated in the ``MSCommPhitting`` initialization when ``community_members`` is defined, but this parameter option allows previous or custom objects to be provided for the simulation. +- *export_lp* ``str``: the name of the LP file, including the ".lp" extension, that will be exported to the current working directory. The default is "CommPhitting.lp". +- *figures_zip_name* ``str``: the name of the zip file to which all of the figures will be exported, where omitting this argument exports the figures to the current working directory. +- *publishing* ``bool``: specifies whether figure proportions and attributes are tailored to make the figures more desirable for publication or poster formats. +- *primals_export_path* ``str``: the path to which simulation primal values will be exported, which defaults to the ``export_lp`` name with "json" extension. + + +----------------------------- +fit_kcat() +----------------------------- + +This function simulates the defined community while implementing a range growth kinetic constants for each phenotype and refining the estimate of phenotype growth kinetics through a few iterative simulations. The parameters are identical to the ``fit()`` function: + +.. code-block:: python + + mscommfit.fit_kcat(parameters:dict=None, mets_to_track: list = None, + rel_final_conc:dict=None, zero_start:list=None, + abs_final_conc:dict=None, graphs: list = None, + data_timesteps: dict = None, export_zip_name: str = None, + export_parameters: bool = True, requisite_biomass: dict = None, + export_lp: str = "CommPhitting.lp", figures_zip_name:str=None, + publishing:bool=False, primals_export_path=None) + + + + + + + + +++++++++++++++++++++++++++++++++++++ +Un-updated documentation +++++++++++++++++++++++++++++++++++++ + + + + + + + +---------------------- +compute() +---------------------- + +The Linear Problem is simulated, and the primal values are parsed, optionally exported, and visualized as figures. + +.. code-block:: python + + mscommfit.compute(graphs=[], zip_name=None) + +- *zip_name* ``str``: the name of the export zip file to which content will be exported. + + +---------------------- +graph() +---------------------- + +Primal values are visualized as figures. + +.. code-block:: python + + mscommfit.compute(graphs=[], primal_values_filename=None, primal_values_zip_path=None, zip_name=None, data_timestep_hr=0.163) + +- *graph* ``list``: the graph specifications that specify which primal values will be graphed, which is elaborated above for the ``compute`` function. +- *primal_values_filename* ``str``: the name of the primal value JSON file ("primal_values.json") +- *primal_values_zip_path* ``str``: the path of the zip file that contains the primal values file +- *zip_name* ``str``: the name of the export zip file to which content will be exported. +- *data_timestep_hr* ``float``: the timestep value in hours of the data that is being graphed. This permits graphing primal values without previously simulating a model. The value is automatically overwritten by previously defined data timesteps in the ``MSCommFitting`` class object. + + +---------------------- +load_model() +---------------------- + +A JSON model file is imported. + +.. code-block:: python + + mscommfit.load_model(mscomfit_json_path, zip_name=None, class_object=False) + +- *mscomfit_json_path* ``str``: the path of the JSON model file that will be loaded and simulated. +- *zip_name* ``str``: the path of the zip file that contains the JSON model file. +- *class_object* ``bool``: specifies whether the loaded model will be defined in the class object. + +**returns** *model* ``Optland.Model``: The model that is loaded via the . + +---------------------- +change_parameters() +---------------------- + +Primal values are visualized figures. + +.. code-block:: python + + mscommfit.load_model(cvt=None, cvf=None, diff=None, vmax=None, mscomfit_json_path="mscommfitting.json", zip_name=None, class_object=False) + +- *cvt*, *cvf*, *diff*, & *vmax* ``float`` or ``dict``: the parameter values that will replace existing values in the LP file. The parameters may be defined as either floats, which will be applied globally to all applicable instances in the model, or as dictionaries that defined values at specific times and possibly at specific trials for a certain time. The latter follows a dictionary structure of ``param["time"]["trial"]``, where the "trial" level can be omitted to applied a parameter value at every trial of a time. A default value can also be specified in the dictionary ``param["default"]`` that applies to times+trials that are not captured by the defined conditions. +- *mscomfit_json_path* ``str``: the path of the JSON model file that will be loaded and simulated. +- *zip_name* ``str``: the zipfile to which the edited LP JSON will be exported . + + +---------------------- +Accessible content +---------------------- + +Several objects within the ``MSCommFitting`` class may be useful for subsequent post-processing or troubleshooting: + +- *problem* ``Optlang.Model``: the LP model of the experimental system that is simulated. +- *carbon_conc* ``dict``: the media concentrations per substrate as defined in ``carbon_conc_series``. +- *variables* & *constraints* ``dict``: the complete collection of all variables and constraints that comprise the LP model. diff --git a/docs/source/community/mscommunity_api.rst b/docs/source/community/mscommunity_api.rst index f67a47bf..b8630b40 100644 --- a/docs/source/community/mscommunity_api.rst +++ b/docs/source/community/mscommunity_api.rst @@ -1,255 +1,255 @@ -MScommunity --------------------------- - -+++++++++++++++++++++ -CommunityModelSpecies() -+++++++++++++++++++++ - -This class parses species in a community model based upon the composition of the model biomass reaction: - -.. code-block:: python - - from modelseedpy.core import CommunityModelSpecies - com_species = CommunityModelSpecies(community, biocpd, names) - -- *community* ``cobra.core.model.Model``: the CobraKBase community model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. -- *biocpd* ``cobrakbase.core.kbasefba.fbamodel_metabolite.ModelCompound``: the biomass metabolite that will be investigated in relation to the simulated community model. -- *names* ``list``: the list of species in the community model, which are indexed sequentially according to their community number. - ----------------------- -disable_species() ----------------------- - -A species can be practically muted from a community simulation by constraining all reaction fluxes of that species to be zero: - -.. code-block:: python - - com_species.disable_species() - -The code applies to the species and community that are loaded and parsed in the ``CommunityModel`` class. - ------------------------------ -compute_max_biomass() ------------------------------ - -The biomass production of the community model is determined when a reaction, in which the parameterized biomass metabolite is produced, is optimized. - -.. code-block:: python - - com_species.compute_max_biomass() - -The code applies to the species, community, and metabolite that are loaded and parsed in the ``CommunityModel`` class. - -**returns** the optimization result - ----------------------- -compute_max_atp() ----------------------- - -The biomass production of the community model is determined when the ATP hydrolysis reaction, which is added to the model when it is not present, is optimized. - -.. code-block:: python - - com_species.compute_max_atp() - -The code applies to the species and community that are loaded and parsed in the ``CommunityModel`` class. - -**returns** the optimization result - ----------------------- -Accessible content ----------------------- - -Several objects within the ``FullThermo`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: - -- *model* ``cobra.core.model.Model``: the cobrakbase model, with the corresponding constraints, that is simulated. -- *species_num* ``int``: the number that is assigned to the species under consideration in the community model. -- *id* ``str``: the identification of the species under consideration in the community model. -- *abundance* ``int``: the abundance of the species under consideration in the community model. -- *biomasses* ``list``: the collection of community reactions, excluding transport reactions, that produce the investigated metabolite. -- *biomass_drain* ``cobra.core.model.Reaction``: the transport reaction that drains the investigated metabolite into the extracellular environment. - -+++++++++++++++++++++ -MSCommunity() -+++++++++++++++++++++ - -This class manipulates and simulates community models: - -.. code-block:: python - - from modelseedpy.community import MSCommunity - mscom = MSCommunity(model, names=[], abundances=None, pfba = True, lp_filename = None) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. -- *names* ``list``: the list of species in the community model, which are indexed sequentially according to their community number. -- *abundances* ``dict``: the abundances (``values``) of the species in the community model (``keys``), in either absolute or relative terms. -- *pfba* ``bool``: signifies whether parsimonious FBA will be simulated. -- *lp_filename* ``str``: species the filename to which the LP file will be exported, where ``None`` does not export the LP file. - ----------------------- -set_abundance() ----------------------- - -The abundances of the community members are implemented in the model, and are normalized to relative abundances: - -.. code-block:: python - - mscom.set_abundance(abundances) - -- *abundances* ``dict``: the abundances (``values``) of the species in the community model (``keys``), in either absolute or relative terms. - ----------------------- -set_objective() ----------------------- - -The simulation objective for the community model is implemented: - -.. code-block:: python - - mscom.set_objective(target = None, minimize = False) - -- *target* ``str``: the ModelSEED id of the reaction for which the simulation will be optimized. -- *minimize* ``bool``: specifies whether the optimization will maximize or minimize the selected reaction, where ``False`` signifies maximization as the default. - ----------------------- -constrain() ----------------------- - -The simulation objective for the community model is implemented: - -.. code-block:: python - - mscom.constrain(element_uptake_limit = None, kinetic_coeff = None, modelseed_db_path = None) - -- *element_uptake_limit* ``dict``: the upper limits of consumption (``values``) for each element in the simulated system (where the element symbols are ``keys``), where ``None`` does not apply these constraints. -- *kinetic_coeff* ``float``: the kinetic coefficient of cross-feeding amongst members of the simulated community, where ``None`` does not apply this constraint. -- *modelseed_db_path* ``str``: the path to the ModelSEED Database, which is only required for the FullThermo, where ``None`` does not apply these constraints. - ----------------------- -print_lp() ----------------------- - -The Linear Programming file of the simulation is exported: - -.. code-block:: python - - mscom.print_lp(filename= None) - -- *filename* ``str``: the path to which the Linear Programming file of the simulation will be exported. - ------------------------------ -compute_interactions() ------------------------------ - -The cross-feeding interactions amongst all of the members of the community model are calculated: - -.. code-block:: python - - cross_feeding = mscom.compute_interactions(solution = None, threshold=1) - -- *solution* ``cobra.core.solution.Solution``: the simulation solution that will be parsed to calculate the cross-feeding interactions. The solution from the last simulation, which is stored within the class, is used when the argument is ``None``. -- *threshold* ``int``: the normalized flux threshold, above which the cross-feeding interactions will be considered. - -**returns** *cross_feeding* ``pandas.core.frame.DataFrame`` A `Pandas DataFrame `_ that provides the metabolite-level resolution of cross-feeding for each species in the community. - - ----------------------- -gapfill() ----------------------- - -The community model will be gap-filled with specified media, templates, models, and conditions: - -.. code-block:: python - - mscom.gapfill(media = None, target = None, minimize = False, default_gapfill_templates = [], - default_gapfill_models = [], test_conditions = [], reaction_scores = {}, blacklist = []) - -- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. -- *target* ``str``: the ModelSEED id of the reaction that will be optimized during the gap-filling. -- *default_gapfill_templates* & *default_gapfill_models* ``list``: collections of templates and models that will be used for gap-filling the community model. -- test_conditions ``list``: the collection of simulation conditions, including media and objective reactions and directions, that will be used to gap-fill the model. -- *reaction_scores* ``dict``: the highest score (``value``) of each gene (``key2``) for each reaction (``key1``), which rescales penalties via reaction scores and saving genes. -- *blacklist* ``list``: a collection of reaction ids that will not used for gap-filling. - -**return** the gap-filled model - - --------------------------------- -test_individual_species() --------------------------------- - -Examines the objective values of individual species in the simulated community: - -.. code-block:: python - - mscom.test_individual_species(media = None, allow_interaction = True, run_atp = True, run_biomass = True) - -- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. -- *allow_cross_feeding* ``bool``: specifies whether cross-feeding is permitted. -- *run_atp* & *run_biomass* ``bool``: specify whether the species will be optimized for ATP and Biomass, respectively, and optimized. - -**return** ``pandas.core.frame.DataFrame`` A `Pandas DataFrame `_ that entails objective value for ATP and Biomass optimizations for each species in the community. - --------------------------------- -atp_correction() --------------------------------- - -The ATP hydrolysis reaction is defined in the model and the ``MSATPCorrection`` module is instantiated as ``mscom.atpcorrect`` for post-processing: - -.. code-block:: python - - mscom.atp_correction(core_template, atp_medias, compartment="c0", max_gapfilling = None, gapfilling_delta = 0) - -- *core_template* ``list``: the collection of templates that will be used to gap-fill the community model. -- *atp_medias* ``list``: the collection of media that will be used for gap-filling. -- *compartment* ``str``: specifies the model compartment to which the ATP hydrolysis reaction will be added. -- *max_gapfilling* & *gapfilling_delta* ``float``: specify the maximum graphfilling score and the acceptable variability from the best gapfilling score, below which a media will be selected for growth of the respective model. - --------------------------------- -predict_abundances() --------------------------------- - -The relative abundances of species members within a community are approximated from the biomass fluxes in the solution of the community objective: - -.. code-block:: python - - mscom.predict_abundances(media = None, pfba = True, kinetic_coeff = None) - -- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. -- *pfba* ``bool``: signifies whether parsimonious FBA will be simulated. -- *kinetic_coeff* ``float``: the kinetic coefficient of cross-feeding amongst members of the simulated community. The combination of ``None`` for this argument and the absence of a defined ``kinetic_coeff`` in the ``MSCommunity`` class defaults to a value of 2000. - -**return** ``pandas.core.frame.DataFrame`` A `Pandas DataFrame `_ that provides the estimated abundance for each species in the community. - ----------- -run() ----------- - -The community model is simulated, with the : - -.. code-block:: python - - solution = mscom.run(media = None, pfba = True) - -- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. -- *pfba* ``bool``: signifies whether parsimonious FBA will be simulated. - -**return** *solution* ``cobra.core.solution.Solution`` The solution from simulation of the community model. - - ----------------------- -Accessible content ----------------------- - -Several objects within the ``FullThermo`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: - -- *model* ``cobra.core.model.Model``: the cobrakbase model, with the corresponding constraints, that is simulated. -- *cross_feeding_df* ``pandas.core.frame.DataFrame``: the output DataFrame from the ``compute_interactions`` function that organizes metabolite-resolution of cross-feeding for each species in the community. -- *lp_filename* ``str``: the filename to which the Linear Programming problem is exported. This can alternatively be defined in the ``print_lp()`` function as an argument. The absence of a defined ``lp_filename`` prevents the LP problem from being exported. -- *gapfillings* ``dict``: the collection of ``MSGapfil`` objects (``values``) for each combination of media and target objective that is parameterized in the function (``key``). -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. -- *solution* ``int``: the FBA solution from the most recent simulation of the model. -- *primary_biomass* & *biomass_drain* ``cobra.core.model.Reaction``: the COBRA model reactions that produce or excrete the biomass compound, respectively. -- *kinetic_coeff* ``float``: the kinetic coefficient that constrained cross-feeding amongst members of the simulated community. -- *element_uptake_limit* ``dict``: the upper limits of consumption (``values``) for each element in the simulated system (``keys``). -- *modelseed_db_path* ``str``: the path to the ModelSEED Database, if the FullThermo constraints were applied. +mscommunity +-------------------------- + ++++++++++++++++++++++++++ +CommunityModelSpecies() ++++++++++++++++++++++++++ + +This class parses species in a community model based upon the composition of the model biomass reaction: + +.. code-block:: python + + from modelseedpy.community import CommunityModelSpecies + com_species = CommunityModelSpecies(community, biocpd, names) + +- *community* ``cobra.core.model.Model``: the CobraKBase community model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. +- *biocpd* ``cobrakbase.core.kbasefba.fbamodel_metabolite.ModelCompound``: the biomass metabolite that will be investigated in relation to the simulated community model. +- *names* ``list``: the list of species in the community model, which are indexed sequentially according to their community number. + +---------------------- +disable_species() +---------------------- + +A species can be practically muted from a community simulation by constraining all reaction fluxes of that species to be zero: + +.. code-block:: python + + com_species.disable_species() + +The code applies to the species and community that are loaded and parsed in the ``CommunityModel`` class. + +----------------------------- +compute_max_biomass() +----------------------------- + +The biomass production of the community model is determined when a reaction, in which the parameterized biomass metabolite is produced, is optimized. + +.. code-block:: python + + com_species.compute_max_biomass() + +The code applies to the species, community, and metabolite that are loaded and parsed in the ``CommunityModel`` class. + +**returns** the optimization result + +---------------------- +compute_max_atp() +---------------------- + +The biomass production of the community model is determined when the ATP hydrolysis reaction, which is added to the model when it is not present, is optimized. + +.. code-block:: python + + com_species.compute_max_atp() + +The code applies to the species and community that are loaded and parsed in the ``CommunityModel`` class. + +**returns** the optimization result + +---------------------- +Accessible content +---------------------- + +Several objects within the ``FullThermo`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: + +- *model* ``cobra.core.model.Model``: the cobrakbase model, with the corresponding constraints, that is simulated. +- *species_num* ``int``: the number that is assigned to the species under consideration in the community model. +- *id* ``str``: the identification of the species under consideration in the community model. +- *abundance* ``int``: the abundance of the species under consideration in the community model. +- *biomasses* ``list``: the collection of community reactions, excluding transport reactions, that produce the investigated metabolite. +- *biomass_drain* ``cobra.core.model.Reaction``: the transport reaction that drains the investigated metabolite into the extracellular environment. + ++++++++++++++++++++++ +MSCommunity() ++++++++++++++++++++++ + +This class manipulates and simulates community models: + +.. code-block:: python + + from modelseedpy.community import MSCommunity + mscom = MSCommunity(model, names=[], abundances=None, pfba = True, lp_filename = None) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. +- *names* ``list``: the list of species in the community model, which are indexed sequentially according to their community number. +- *abundances* ``dict``: the abundances (``values``) of the species in the community model (``keys``), in either absolute or relative terms. +- *pfba* ``bool``: signifies whether parsimonious FBA will be simulated. +- *lp_filename* ``str``: species the filename to which the LP file will be exported, where ``None`` does not export the LP file. + +---------------------- +set_abundance() +---------------------- + +The abundances of the community members are implemented in the model, and are normalized to relative abundances: + +.. code-block:: python + + mscom.set_abundance(abundances) + +- *abundances* ``dict``: the abundances (``values``) of the species in the community model (``keys``), in either absolute or relative terms. + +---------------------- +set_objective() +---------------------- + +The simulation objective for the community model is implemented: + +.. code-block:: python + + mscom.set_objective(target = None, minimize = False) + +- *target* ``str``: the ModelSEED id of the reaction for which the simulation will be optimized. +- *minimize* ``bool``: specifies whether the optimization will maximize or minimize the selected reaction, where ``False`` signifies maximization as the default. + +---------------------- +constrain() +---------------------- + +The simulation objective for the community model is implemented: + +.. code-block:: python + + mscom.constrain(element_uptake_limit = None, kinetic_coeff = None, modelseed_db_path = None) + +- *element_uptake_limit* ``dict``: the upper limits of consumption (``values``) for each element in the simulated system (where the element symbols are ``keys``), where ``None`` does not apply these constraints. +- *kinetic_coeff* ``float``: the kinetic coefficient of cross-feeding amongst members of the simulated community, where ``None`` does not apply this constraint. +- *modelseed_db_path* ``str``: the path to the ModelSEED Database, which is only required for the FullThermo, where ``None`` does not apply these constraints. + +---------------------- +print_lp() +---------------------- + +The Linear Programming file of the simulation is exported: + +.. code-block:: python + + mscom.print_lp(filename= None) + +- *filename* ``str``: the path to which the Linear Programming file of the simulation will be exported. + +----------------------------- +compute_interactions() +----------------------------- + +The cross-feeding interactions amongst all of the members of the community model are calculated: + +.. code-block:: python + + cross_feeding = mscom.compute_interactions(solution = None, threshold=1) + +- *solution* ``cobra.core.solution.Solution``: the simulation solution that will be parsed to calculate the cross-feeding interactions. The solution from the last simulation, which is stored within the class, is used when the argument is ``None``. +- *threshold* ``int``: the normalized flux threshold, above which the cross-feeding interactions will be considered. + +**returns** *cross_feeding* ``pandas.core.frame.DataFrame`` A `Pandas DataFrame `_ that provides the metabolite-level resolution of cross-feeding for each species in the community. + + +---------------------- +gapfill() +---------------------- + +The community model will be gap-filled with specified media, templates, models, and conditions: + +.. code-block:: python + + mscom.gapfill(media = None, target = None, minimize = False, default_gapfill_templates = [], + default_gapfill_models = [], test_conditions = [], reaction_scores = {}, blacklist = []) + +- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. +- *target* ``str``: the ModelSEED id of the reaction that will be optimized during the gap-filling. +- *default_gapfill_templates* & *default_gapfill_models* ``list``: collections of templates and models that will be used for gap-filling the community model. +- test_conditions ``list``: the collection of simulation conditions, including media and objective reactions and directions, that will be used to gap-fill the model. +- *reaction_scores* ``dict``: the highest score (``value``) of each gene (``key2``) for each reaction (``key1``), which rescales penalties via reaction scores and saving genes. +- *blacklist* ``list``: a collection of reaction ids that will not used for gap-filling. + +**return** the gap-filled model + + +-------------------------------- +test_individual_species() +-------------------------------- + +Examines the objective values of individual species in the simulated community: + +.. code-block:: python + + mscom.test_individual_species(media = None, allow_interaction = True, run_atp = True, run_biomass = True) + +- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. +- *allow_cross_feeding* ``bool``: specifies whether cross-feeding is permitted. +- *run_atp* & *run_biomass* ``bool``: specify whether the species will be optimized for ATP and Biomass, respectively, and optimized. + +**return** ``pandas.core.frame.DataFrame`` A `Pandas DataFrame `_ that entails objective value for ATP and Biomass optimizations for each species in the community. + +-------------------------------- +atp_correction() +-------------------------------- + +The ATP hydrolysis reaction is defined in the model and the ``MSATPCorrection`` module is instantiated as ``mscom.atpcorrect`` for post-processing: + +.. code-block:: python + + mscom.atp_correction(core_template, atp_medias, compartment="c0", max_gapfilling = None, gapfilling_delta = 0) + +- *core_template* ``list``: the collection of templates that will be used to gap-fill the community model. +- *atp_medias* ``list``: the collection of media that will be used for gap-filling. +- *compartment* ``str``: specifies the model compartment to which the ATP hydrolysis reaction will be added. +- *max_gapfilling* & *gapfilling_delta* ``float``: specify the maximum graphfilling score and the acceptable variability from the best gapfilling score, below which a media will be selected for growth of the respective model. + +-------------------------------- +predict_abundances() +-------------------------------- + +The relative abundances of species members within a community are approximated from the biomass fluxes in the solution of the community objective: + +.. code-block:: python + + mscom.predict_abundances(media = None, pfba = True, kinetic_coeff = None) + +- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. +- *pfba* ``bool``: signifies whether parsimonious FBA will be simulated. +- *kinetic_coeff* ``float``: the kinetic coefficient of cross-feeding amongst members of the simulated community. The combination of ``None`` for this argument and the absence of a defined ``kinetic_coeff`` in the ``MSCommunity`` class defaults to a value of 2000. + +**return** ``pandas.core.frame.DataFrame`` A `Pandas DataFrame `_ that provides the estimated abundance for each species in the community. + +---------- +run() +---------- + +The community model is simulated, with the : + +.. code-block:: python + + solution = mscom.run(media = None, pfba = True) + +- *media* ``str``: the media of the model that will be used for gap-filling, where ``None`` defaults to a complete media. +- *pfba* ``bool``: signifies whether parsimonious FBA will be simulated. + +**return** *solution* ``cobra.core.solution.Solution`` The solution from simulation of the community model. + + +---------------------- +Accessible content +---------------------- + +Several objects within the ``FullThermo`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: + +- *model* ``cobra.core.model.Model``: the cobrakbase model, with the corresponding constraints, that is simulated. +- *cross_feeding_df* ``pandas.core.frame.DataFrame``: the output DataFrame from the ``compute_interactions`` function that organizes metabolite-resolution of cross-feeding for each species in the community. +- *lp_filename* ``str``: the filename to which the Linear Programming problem is exported. This can alternatively be defined in the ``print_lp()`` function as an argument. The absence of a defined ``lp_filename`` prevents the LP problem from being exported. +- *gapfillings* ``dict``: the collection of ``MSGapfil`` objects (``values``) for each combination of media and target objective that is parameterized in the function (``key``). +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. +- *solution* ``int``: the FBA solution from the most recent simulation of the model. +- *primary_biomass* & *biomass_drain* ``cobra.core.model.Reaction``: the COBRA model reactions that produce or excrete the biomass compound, respectively. +- *kinetic_coeff* ``float``: the kinetic coefficient that constrained cross-feeding amongst members of the simulated community. +- *element_uptake_limit* ``dict``: the upper limits of consumption (``values``) for each element in the simulated system (``keys``). +- *modelseed_db_path* ``str``: the path to the ModelSEED Database, if the FullThermo constraints were applied. diff --git a/docs/source/community/mscompatibility_api.rst b/docs/source/community/mscompatibility_api.rst index 0301a09f..a9547d31 100644 --- a/docs/source/community/mscompatibility_api.rst +++ b/docs/source/community/mscompatibility_api.rst @@ -1,77 +1,63 @@ -MScompatibility --------------------------- - -+++++++++++++++++++++ -MSCompatibility() -+++++++++++++++++++++ - -This class determines the compatibility of individual models for the construction of a community model, as well as the standardization of models to the metabolite and reaction IDs and names of the ModelSEED Database: - -.. code-block:: python - - from modelseedpy.core import MSCompatibility - ms_compat = MSCompatibility(modelseed_db_path, printing = True) - -- *modelseed_db_path* ``str``: the path to the ModelSEED Database, which is only required for the FullThermo, where ``None`` does not apply these constraints. -- *printing* ``bool``: specifies whether results will be printed. - ----------------------- -standardize_MSD() ----------------------- - -The IDs and names of the metabolites and reactions of a model are standardized to those of the ModelSEED Database: - -.. code-block:: python - - ms_compat.standardize_MSD(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be standardized. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - -**returns** the standardized COBRA model - ------------------------------ -compare_models() ------------------------------ - -Determines the consistency of reaction or metabolite IDs and names between two models: - -.. code-block:: python - - ms_compat.compare_models(model_1, model_2, metabolites = True, standardize = False) - -- *model_1* & *model_2* ``cobra.core.model.Model``: CobraKBase models that will be compared. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. -- *metabolites* ``bool``: specifies whether metabolites (``True``) or reactions (``False``) will be compared between the models. -- *standardize* ``bool``: specifies whether the models will be standardized through the ``standardize_MSD`` function. - -**returns** misaligned, model_1, model_2 - -- *misaligned* ``list``: the collection of the discrepancies between the two models, where the differing entries for each model are both provided. -- *model_1* & *model_2* ``cobra.core.model.Model``: the models that were compared, which is relevant only if the models were also standardized via ``standardize = True``. - ----------------------- -exchanges() ----------------------- - -Model variabilities in the exchange fluxes -- such as non-standard metabolite IDs (e.g NH4) and different metabolite IDs for each isomer (e.g. L-alanine is cpd00035 while beta-alanine is cpd00085) -- are systematically corrected to facilitate a compatible community of these models. - -.. code-block:: python - - ms_compat.exchanges(model) - -- *model_1* & *model_2* ``cobra.core.model.Model``: CobraKBase models that will be compared. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - -**returns** model, unknown_met_ids - -- *model* ``cobra.core.model.Model``: the corrected model that is now compatible with other models to assemble a community. -- *unknown_met_ids* ``list``: the collection of non-standard metabolite IDs that were not able to be mapped with a standard ModelSEED Database ID. - - ----------------------- -Accessible content ----------------------- - -Several objects within the ``MSCompatibility`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: - -- *compounds* & *reactions* ``dict``: the complete content of compounds and reactions, respectively, in the ModelSEED Database. -- *compound_names* & *compounds_id_indexed* ``OrderedDict``: ordered dictionaries of ModelSEED compound names and IDs (``values``) according to the corresponding compound IDs and names (``keys``), respectively. -- *reaction_ids* ``OrderedDict``: ordered dictionary of ModelSEED reaction IDs (``values``) according to the corresponding reaction names (``keys``). +mscompatibility +-------------------------- + ++++++++++++++++++++++ +MSCompatibility() ++++++++++++++++++++++ + +This class compatibilizes a collection of individual metabolic models to facilitate syntrophy and accurate analysis of herefrom community models. This standardization leverages the ModelSEED Database as the arbitrator of metabolite and reaction IDs in the metabolic models: + +.. code-block:: python + + from modelseedpy.community import MSCompatibility + ms_compat = MSCompatibility(modelseed_db_path, printing = True) + +- *modelseed_db_path* ``str``: the path to the ModelSEED Database, which is only required for the FullThermo, where ``None`` does not apply these constraints. +- *printing* ``bool``: specifies whether results will be printed. + +---------------------- +standardize() +---------------------- + +**Staticmethod** + +The IDs and names of the metabolites and reactions models are standardized to those of the ModelSEED Database: + +.. code-block:: python + + new_models (, optionally unknown_met_ids) = MSCompatibility.standardize(models, metabolites=True, exchanges=True, conflicts_file_name=None, model_names=None, + export_directory=None, view_unknown_mets=True, printing=True, unknown_met_ids=None, changed_metabolites=None, changed_reactions=None) + +- *models* ``Iterable o cobra.core.model.Model``: the collection of CobraKBase models that will be standardized. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. +- *metabolites* ``bool``: specifies whether metabolites (``True``) or reactions (``False``) will be compared between the models. +- *exchanges* ``bool``: specifies whether only the exchanges of the models will be standardized. +- *conflicts_file_name* ``str``: the filename to where metabolite conflicts will be exported, where ``None`` does not export. +- *model_names* ``list``: the collection of model names that correspond with the indices of the ``models`` parameter, which is used to distinguish the exported files of each model. +- *export_directory* ``str``: specifies the directory to which all of the content will be exported. +- *view_unknown_mets* & *printing* ``bool``: specifies whether the unknown metabolite IDs and other results of the alignment functionality, respectively, are printed to the console for the user to review. +- *unknown_met_ids*, *changed_metabolites*, & *changed_reactions* ``Iterable``: collections of unknown metabolite IDs and corrected metabolites and reactions. These are internal entities that are passed as argumented to ``standardize()`` by ``align_exchanges()`` when the latter is provided ``True`` through the ``standardize`` parameter. + +**returns** the collection of standardized COBRA models, and possibly the collection of unknown metabolite IDs + +----------------------------- +align_exchanges() +----------------------------- + +**Staticmethod** + +The exchange reactions and metabolites of metabolic models are aligned to facilitate community assemblage and cross-feeding interactions: + +.. code-block:: python + + new_models (, optionally extras) = MSCompatibility.align_exchanges(models, standardize=False, conflicts_file_name=None, + model_names=None, export_directory=None, printing=True, extras=False) + +- *models* ``Iterable o cobra.core.model.Model``: the collection of CobraKBase models that will be standardized. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. +- *standardize* ``bool``: specifies whether the models will be standardized through the ``standardize`` function. +- *conflicts_file_name* ``str``: the filename to where metabolite conflicts will be exported, where ``None`` does not export. +- *model_names* ``Iterable``: the collection of model names that correspond with the indices of the ``models`` parameter, which is used to distinguish the exported files of each model. +- *export_directory* ``str``: specifies the directory to which all of the content will be exported. +- *printing* ``bool``: specifies whether results of the alignment functionality, respectively, are printed to the console for the user to review. +- *extras* ``bool``: specifies whether the ``unique_mets``, ``unknown_met_ids``, ``changed_metabolites``, and ``changed_reactions`` collections of internal data are provided in a tuple, respectively, as the second returned object from the function. This information is not provided, and the function returns one object, when this parameter is ``False``. + +**returns** the collection of aligned COBRA models, and possibly the collection of the aforementioned ``extras`` diff --git a/docs/source/community/mssmetana_api.rst b/docs/source/community/mssmetana_api.rst new file mode 100644 index 00000000..eefd2cf5 --- /dev/null +++ b/docs/source/community/mssmetana_api.rst @@ -0,0 +1,331 @@ +mssmetana +-------------------------- + ++++++++++++++++++++++ +MSSmetana() ++++++++++++++++++++++ + +TThis class provides metrics of various dimensions in microbial communities to quantify interactions among community members. Many of the scores -- principally MRO and MIP -- are curated versions from the SMETANA suite of scores (Zelezniak et al., 2015, https://doi.org/10.1073/pnas.1421834112), while the other scores are original metrics that capture additional biological dimensions for comparison. Both class methods, which support multiple scores to be efficiently calculated for a single community of members, and ``staticmethods``, which support in-line calculation of single scores ad hoc, are available for each score: + +.. code-block:: python + + from modelseedpy.community import MSSmetana + mssmet = MSSmetana(self, member_models: Iterable, min_growth=0.1, n_solutions=100, + environment=None, abstol=1e-3, media_dict=None, + printing=True, raw_content=False, antismash_json_path:str=None, + antismash_zip_path:str=None, minimal_media_method="minFlux") + +- *member_models* ``list|set ``: the collection of member models for which the metric scores will be calculated. +- *min_growth* ``float``: the smallest growth rate that is specified during minimal media calculations. +- *n_solutions* ``int``: the number of exploratory loops that the MILP algorithms of the ``MU`` and ``SC`` SMETANA scores will execute. +- *environment* ``dict|kbase_media_object``: the media in which the community will be simulated, which can be a dictionary of exchanges and their fluxes or a KBase Media object. +- *abstol* ``float``: the flux threshold above which cross-feeding will be considered significant and therefore tracked for the ``MP``, ``MU``, and ``SC`` scores of SMETANA. +- *media_dict* ``dict``: the minimal media of the community members, which can be provided to expedite computational time by not recalculating it repeatedly during development sessions. The media must be defined with the following structure: + +.. code-block:: json + + { + "members": { + "Bacillus_sp._bc15.RAST.fbamodel": { + "media": { + "EX_cpd00051_e0": 0.024950298185467054, "EX_cpd00644_e0": 0.0005612318319214348, + "EX_cpd00654_e0": 0.0011184174481049735, "EX_cpd00393_e0": 0.0008418477478827718, + "EX_cpd00149_e0": 0.00028061591596092344, "EX_cpd00030_e0": 0.0002806159159609234, + "EX_cpd00182_e0": 0.012823174793819692, "EX_cpd00367_e0": 0.019860385045891646, + "EX_cpd00063_e0": 0.0002806159159609234, "EX_cpd00066_e0": 0.015451949003231678, + "EX_cpd00099_e0": 0.00028061591596092344, "EX_cpd15603_e0": 0.040392130687977465, + "EX_cpd00254_e0": 0.00028061591596092344, "EX_cpd00264_e0": 0.00028061591596092344, + "EX_cpd00209_e0": 0.29280989138763885, "EX_cpd00007_e0": 0.0007015397899023084, + "EX_cpd00104_e0": 0.00028061591596092344, "EX_cpd00158_e0": 0.8572001890264485, + "EX_cpd00065_e0": 0.004720191914454185, "EX_cpd10515_e0": 0.0008418477478827702, + "EX_cpd00069_e0": 0.012067660460609869, "EX_cpd00048_e0": 0.00028061591596092344, + "EX_cpd00793_e0": 0.0002806159159609235, "EX_cpd00058_e0": 0.00028061591596092344, + "EX_cpd00107_e0": 0.037538884754252475, "EX_cpd00119_e0": 0.00792636000742222, + "EX_cpd00156_e0": 0.035223318909387485, "EX_cpd00034_e0": 0.00028061591596092344, + "EX_cpd00179_e0": 4.162129853322901e-13, "EX_cpd00017_e0": 0.0019643114116915986, + "EX_cpd00205_e0": 0.00028061591596092344, "EX_cpd00277_e0": 0.014659099568563774, + "EX_cpd00355_e0": 0.08097665993895736, "EX_cpd00220_e0": 0.0008418477478827705, + "EX_cpd00322_e0": 0.024179851033877948, "EX_cpd00028_e0": 0.00028061591596092344 + } + }, + "Sphingobium_AP49_pacbio_v2.RAST.fbamodel": { + "media": { + "EX_cpd00039_e0": 0.028543802049017904, "EX_cpd00118_e0": 0.000280615915959131, + "EX_cpd01017_e0": 0.008456496968388943, "EX_cpd00051_e0": 0.024669682270134097, + "EX_cpd00136_e0": 0.00028061591595913087, "EX_cpd00161_e0": 0.03565680232766155, + "EX_cpd00009_e0": 0.08097472586643507, "EX_cpd00644_e0": 0.0005612318318649744, + "EX_cpd00654_e0": 0.0011501166238305303, "EX_cpd00393_e0": 0.0008418477478774078, + "EX_cpd00149_e0": 0.000280615915959131, "EX_cpd00030_e0": 0.000280615915959131, + "EX_cpd00132_e0": 0.0200830806928348, "EX_cpd00060_e0": 0.011096446763321909, + "EX_cpd00063_e0": 0.000280615915959131, "EX_cpd00066_e0": 0.015451949003134501, + "EX_cpd00099_e0": 0.00028061591595913103, "EX_cpd00794_e0": 0.2508330788175711, + "EX_cpd03847_e0": 0.00250105977108944, "EX_cpd00254_e0": 0.00028061591595913103, + "EX_cpd00264_e0": 0.000280615915959131, "EX_cpd00007_e0": 1.181243853603619, + "EX_cpd00104_e0": 0.000280615915959131, "EX_cpd00065_e0": 0.004720191914502181, + "EX_cpd10515_e0": 0.0008418477478773928, "EX_cpd00069_e0": 0.0120676604606612, + "EX_cpd00053_e0": 0.20365017006808284, "EX_cpd00048_e0": 0.000280615915959131, + "EX_cpd00793_e0": 0.000280615915959131, "EX_cpd00058_e0": 0.00028061591595913103, + "EX_cpd00107_e0": 0.0375388847540127, "EX_cpd00119_e0": 0.00792636000737159, + "EX_cpd00156_e0": 0.035223318909181824, "EX_cpd00034_e0": 0.000280615915959131, + "EX_cpd00215_e0": 0.000280615915959131, "EX_cpd00166_e0": 5.3065904751139414e-20, + "EX_cpd00017_e0": 0.001964311411713922, "EX_cpd00205_e0": 0.0002806159159591311, + "EX_cpd00277_e0": 0.00205355085202053, "EX_cpd00220_e0": 0.0008418477478773926, + "EX_cpd00322_e0": 0.024179851033723505, "EX_cpd00028_e0": 0.00028061591595913103 + } + } + }, + "community_media": { + "EX_cpd00039_e0": 0.028543802049017904, "EX_cpd00118_e0": 0.000280615915959131, + "EX_cpd01017_e0": 0.008456496968388943, "EX_cpd00051_e0": 0.024669682270134097, + "EX_cpd00136_e0": 0.00028061591595913087, "EX_cpd00161_e0": 0.03565680232766155, + "EX_cpd00009_e0": 0.08097472586643507, "EX_cpd00644_e0": 0.0005612318318649744, + "EX_cpd00654_e0": 0.0011501166238305303, "EX_cpd00393_e0": 0.0008418477478774078, + "EX_cpd00149_e0": 0.000280615915959131, "EX_cpd00030_e0": 0.000280615915959131, + "EX_cpd00132_e0": 0.0200830806928348, "EX_cpd00060_e0": 0.011096446763321909, + "EX_cpd00063_e0": 0.000280615915959131, "EX_cpd00066_e0": 0.015451949003134501, + "EX_cpd00099_e0": 0.00028061591595913103, "EX_cpd00794_e0": 0.2508330788175711, + "EX_cpd03847_e0": 0.00250105977108944, "EX_cpd00254_e0": 0.00028061591595913103, + "EX_cpd00264_e0": 0.000280615915959131, "EX_cpd00007_e0": 1.181243853603619, + "EX_cpd00104_e0": 0.000280615915959131, "EX_cpd00065_e0": 0.004720191914502181, + "EX_cpd10515_e0": 0.0008418477478773928, "EX_cpd00069_e0": 0.0120676604606612, + "EX_cpd00053_e0": 0.20365017006808284, "EX_cpd00048_e0": 0.000280615915959131, + "EX_cpd00793_e0": 0.000280615915959131, "EX_cpd00058_e0": 0.00028061591595913103, + "EX_cpd00107_e0": 0.0375388847540127, "EX_cpd00119_e0": 0.00792636000737159, + "EX_cpd00156_e0": 0.035223318909181824, "EX_cpd00034_e0": 0.000280615915959131, + "EX_cpd00215_e0": 0.000280615915959131, "EX_cpd00166_e0": 5.3065904751139414e-20, + "EX_cpd00017_e0": 0.001964311411713922, "EX_cpd00205_e0": 0.0002806159159591311, + "EX_cpd00277_e0": 0.00205355085202053, "EX_cpd00220_e0": 0.0008418477478773926, + "EX_cpd00322_e0": 0.024179851033723505, "EX_cpd00028_e0": 0.00028061591595913103 + } + } + +The ``"community_media"`` key contains the minimal media of the community model, while the ``"members"`` key contains information for each community member. The key:value pairings of exchange reactions and their respective fluxes, with (+) denoting influx, is loaded by the package. + +- *printing* ``bool``: specifies whether progress, warnings, and results are printed to the User"s interface. +- *raw_content* ``bool``: specifies whether the returned content is processed or raw intermediate values that contain additional dimensions of information. +- *antismash_json_path* ``str``: the path to antiSMASH data of the simulated community, which is only used for the ``antiSMASH_scores`` function. +- *antismash_zip_path* ``str``: the path to a raw antiSMASH zip file, which is unzipped by the ``antiSMASH_scores`` function to access the data that constitutes our score. +- *minimal_media_method* ``str``: specifies which minimal media method is employed when calculating the minimal media for the members and community. The "minFlux" selection minimizes total consumption flux while "minComponents" minimizes the number of compounds that are consumed. These options significantly alter the metrics of our scores. + + +----------------------------- +all_scores() +----------------------------- + +All of the defined scores can be simulated on the initalized community system through the ``all_scores`` function. Omission of the *kbase_obj*, *RAST_genomes*, and both of the *cobrakbase_path* and *kbase_token_path* omits the ``RFC`` score from output: + +.. code-block:: python + + scores = mssmet.all_scores(mp_score=True, kbase_obj=None, cobrakbase_path:str=None, + kbase_token_path:str=None, RAST_genomes:dict=None) + + +- *mp_score* ``bool``: specifies whether the MP score will be calculated. +- *kbase_obj* ``kbase_api_object``: the KBase API object from which member genomes can be loaded to calculate the RAST Functional Complementary (RFC) score. +- *cobrakbase_path* & *kbase_token_path* ``str``: the local paths to the COBRA-Kbase repository, which is necessary to load genomes for specified models, and the KBase User's token, which is necessary to access the KBase API. +- *RAST_genomes* ``dict``: the collection of RAST genomes, indexed by the IDs of their respective community members, that are used for calculating the ``RFC`` score. + + +**Returns** *scores* ``dict``: the dictionary of outputs for each score: + +.. code-block:: json + + { + "mro": mro_output, + "mip": mip_output, + "mp" mp_output, + "mu": mu_output, + "sc": sc_score, + "smetana": smetana_score, + "grd": grd_score, + "rfc": rfc_score + } + + +-------------------------- +report_generation() +-------------------------- + +The scores can be calculated over a large range of models, either for specified pairs or for all combinations of all models. This process can be expedited with optional parallelization. This function is a **Staticmethod**, and therefore cannot access any content that is loaded in the class object of the aforementioned functions. + +.. code-block:: python + + scores_df, mets = mssmet.report_generation(all_models:iter=None, pairs:dict=None, mem_media:dict=None, + pair_limit:int=None, exclude_pairs:list=None, kbase_obj=None, + RAST_genomes:dict=None, see_media:bool=True, + environment:Union[dict]=None, # can be KBase media object + lazy_load:bool=False, pool_size:int=None) + +- *all_models* ``list|set``: the collection of all member models. +- *pairs* ``dict``: the specification of individual member pairings that are sought. The keys are either model objects per se, the permanent KBase model ID, or a tuple of the KBase object name and Narrative ID. The latter two options require that the *kbase_obj* argument is also provided to load the models, but is advantageously coupled with lazy loading via the *lazy_load* argument to minimize RAM consumption for large-scale analyses with numerous models. The values are an iterable of the models that will be coupled with the key model: + +.. code-block:: json + + { + model1: [model2, model3, model4, model5], + model2: [model4, model6], + model4: [model5, model7] + } + +- *mem_media* ``dict``: the minimal media of members, which obviates duplicated computation with subsequent iteractions. The form is the sub-dictionary within the "members" key of the previously defined minimal media dictionary, where the top-level keys are the model IDs, the second-level keys is "media", and the values are the media dictionaries of exchange IDs and their respective fluxes. +- *pair_limit* ``int``: the maximal number of member pairs that are examined, which is applicable when *pairs* are not specified and an all v. all comparison is conducted. +- *excluded_pairs* ``iterable``: the member pairs that will be omitted, which is valuable for the excluding pairs from the all versus all comparison perspective. +- *RAST_genomes* ``iterable``: the genomes of the members that will be examined, where the omission of this argument does not calculate the ``RFC`` score. +- *see_media* ``bool``: specifies whether the *mem_media* dictionary is printed if it is printed from scratch and not loaded as an argument, which can allow the user to copy it and pass it as the *mem_media* argument in future computations. +- *environment* ``dict|KBase_media_object``: the media in which the community will be simulated, which can be a dictionary of exchanges and their fluxes or a KBase Media object. +- *lazy_load* ``bool``: specifies whether models will only be loaded as they are used in a comparison, which limits RAM consumption by only ever containing two models in memory at a time. +- *pool_size* ``int``: the number of parallel processes across which pairwise scores will be calculated, where omitting this score does not parallelize the process. Our observation is that the processes are not very CPU intensive, even when specifying the maximal number of cores, so this option should be utilized for >50 models, especially for all versus all comparisons. + + +**Returns** *scores_df* & *mets* ``Pandas.DataFrame`` & ``list``: a dataframe of all scores for all computed pairs and a list of the metabolites the comprise the ``MRO`` and ``MIP`` scores, for additional information of differences between the members, respectively. These returned objects can be directly passed as inputs into the ``commscores_report`` function of ModelSEEDpy to create an HTML output of the results, which processes the DataFrame into a quantitative heatmap and will eventually include the extra metabolites as hoverover metadata for access to users. + + + +---------------------------------------------------------------------------------------- +mro_score(), mip_score(), mu_score(), mp_score(), sc_score(), smetana_score() +---------------------------------------------------------------------------------------- + +The individual SMETANA scores can be succinctly calculated in any order from the aforementioned class object, without the need for further parameters: + +.. code-block:: python + + mro = smtna.mro_score() + mip = smtna.mip_score() + mu = smtna.mu_score() + mp = smtna.mp_score() + sc = smtna.sc_score() + smetana = smtna.smetana_score() + + **returns** the respective score of the defined community system: + +- *mro* & *mip* ``float``: The numerous scores from the MRO and MIP scores, respectively. +- *mu*, *mp*, *sc*, & *smetana* ``dict``: The collections of scores, organized by model IDs, for the MU, MP, SC, and SMETANA scores, respectively. + +----------------------------- +Attributes +----------------------------- + +The ``MSSmetana`` class object stores numerous attributes for subsequent post-processing or troubleshooting: + +- *community* ``MSModelUtil``: the MSModelUtil model object of the community model. +- *models* ``list``: the collection of compatibilized member models that are examined. +- *mro* & *mip* ``float``: The numerous scores from the MRO and MIP scores, respectively. +- *mu*, *mp*, *sc*, *smetana*, *grd_val*, *rfc_val*, & *antismash* ``dict``: The collections of scores, organized by model IDs, for the *MU*, *MP*, *SC*, and *smetana* SMETANA scores, respectively, as well as the original *grd_val*, *rfc_val*, & *antismash* scores. +- *media* ``dict``: The media object of the community. +- *printing* ``bool``: The setting for whether results of the alignment functionality, respectively, are printed to the console. + + +--------- +mro() +--------- + +**Staticmethod** + +The MRO SMETANA score can be specifically calculated without constructing a class object: + +.. code-block:: python + + MSSmetana.mro(cobra_models, min_growth=0.1, media_dict=None, compatibilize=True) + +- *cobra_models* ``list o cobra.core.model.Model``: the collection of member models that comprise the examined community. +- *min_growth* ``float``: the minimal permissible community biomass objective value from simulation. +- *media_dict* ``dict``: A dictionary of predetermined minimal media, per the above definition. +- *compatibilize* ``bool``: specifies whether the member models will be standardized to the ModelSEED Database conventions. + + +-------- +mip() +-------- + +**Staticmethod** + +The MIP SMETANA score can be specifically calculated without constructing a class object: + +.. code-block:: python + + MSSmetana.mip(com_model, cobra_models, min_growth=0.1, interacting_media_dict=None, + noninteracting_media_dict=None, compatibilize=True) + +- *com_model* ``cobra.core.model.Model``: the community model that combines the individual member models. +- *cobra_models* ``list o cobra.core.model.Model``: the collection of member models that comprise the examined community. +- *min_growth* ``float``: the minimal permissible community biomass objective value from simulation. +- *interacting_media_dict* & *noninteracting_media_dict* ``dict``: Dictionaries of the predetermined minimal media that include and exclude cross-feeding (syntrophy), respectively. The MIP formulation essentially compares these two media, hence the calculation can be tremenedously expedited if both of these media objects are parameterized and need not be calculated in the logic. +- *compatibilize* ``bool``: specifies whether the member models will be standardized to the ModelSEED Database conventions. + + +--------- +mu() +--------- + +**Staticmethod** + +The MU SMETANA score can be specifically calculated without constructing a class object: + +.. code-block:: python + + MSSmetana.mu(cobra_models, n_solutions=100, abstol=1e-3, compatibilize=True) + +- *cobra_models* ``list o cobra.core.model.Model``: the collection of member models that comprise the examined community. +- *n_solutions* ``int``: the number of loops over which the MILP algorithms of the SMETANA scores search. +- *abstol* ``float``: the minimum flux above which the flux is considered to be non-zero. +- *compatibilize* ``bool``: specifies whether the member models will be standardized to the ModelSEED Database conventions. + +--------- +mp() +--------- + +**Staticmethod** + +The MP SMETANA score can be specifically calculated without constructing a class object: + +.. code-block:: python + + MSSmetana.mp(cobra_models=None, com_model=None, abstol=1e-3, compatibilize=True) + +- *cobra_models* ``list o cobra.core.model.Model``: the collection of member models that comprise the examined community. +- *com_model* ``cobra.core.model.Model``: the community model that combines the individual member models. +- *abstol* ``float``: the minimum flux above which the flux is considered to be non-zero. +- *compatibilize* ``bool``: specifies whether the member models will be standardized to the ModelSEED Database conventions. + +--------- +sc() +--------- + +**Staticmethod** + +The SC SMETANA score can be specifically calculated without constructing a class object: + +.. code-block:: python + + MSSmetana.sc(cobra_models=None, com_model=None, min_growth=0.1, + n_solutions=100, abstol=1e-3, compatibilize=True) + +- *cobra_models* ``list o cobra.core.model.Model``: the collection of member models that comprise the examined community. +- *com_model* ``cobra.core.model.Model``: the community model that combines the individual member models. +- *min_growth* ``float``: the minimal permissible community biomass objective value from simulation. +- *n_solutions* ``int``: the number of loops over which the MILP algorithms of the SMETANA scores search. +- *abstol* ``float``: the minimum flux above which the flux is considered to be non-zero. +- *compatibilize* ``bool``: specifies whether the member models will be standardized to the ModelSEED Database conventions. + + +----------- +smetana() +----------- + +**Staticmethod** + +The smetana SMETANA superscore can be specifically calculated without constructing a class object: + +.. code-block:: python + + MSSmetana.smetana(cobra_models, com_model=None, min_growth=0.1, n_solutions=100, abstol=1e-6, + prior_values=None, compatibilize=False, sc_coupling=False) + +- *cobra_models* ``list o cobra.core.model.Model``: the collection of member models that comprise the examined community. +- *com_model* ``cobra.core.model.Model``: the community model that combines the individual member models. +- *min_growth* ``float``: the minimal permissible community biomass objective value from simulation. +- *n_solutions* ``int``: the number of loops over which the MILP algorithms of the SMETANA scores search. +- *abstol* ``float``: the minimum flux above which the flux is considered to be non-zero. +- *prior_values* ``Iterable``: The collection of ``SC``, ``MU``, and ``MP`` score results that were previously calculated for the studied system, and thus do not need to be recalculated. +- *compatibilize* ``bool``: specifies whether the member models will be standardized to the ModelSEED Database conventions. +- *sc_coupling* ``bool``: specifies whether the SC score contributes to the calculation of the smetana score. diff --git a/docs/source/core/biology_api.rst b/docs/source/core/biology_api.rst index 6e36a279..771a28c0 100644 --- a/docs/source/core/biology_api.rst +++ b/docs/source/core/biology_api.rst @@ -1,108 +1,108 @@ -Biology Packages -------------------- - -+++++++++++++++++++++ -BiologPlate() -+++++++++++++++++++++ - -This class assembles media from lists of compounds and HTML representations of the well media: - -.. code-block:: python - - from modelseedpy.core import BiologPlate - bioplate = BiologPlate(plate_id, rows, cols) - -- *plate_id* ``str``: The ID of the plate that will be parsed to develop a simulation media. -- *rows* & *cols* ``list``: The rows and columns of the experimental system, respectively. - ----------------------- -add_base() ----------------------- - -A list of compounds are ascribed a value to construct a media: - -.. code-block:: python - - bioplate.add_base(compounds, value) - -- *compounds* ``list``: The compounds that will constitute a media. -- *value* ``float``: The value that will be assigned to each compound. - ----------------------- -get_media() ----------------------- - -The generate a media from a defined well ID in the set of all wells: - -.. code-block:: python - - bioplate.get_media(well_id) - -- *well_id* ``dict``: The collection of compounds and values that supplant default entries from the ``add_base`` function, where compounds and values are provided as the ``values`` of the "compounds" and value" ``keys``, respectively. - -**returns** *media* ``dict``: The media that is created from the parameterized list of compounds and the respective value. - ----------------------- -_repr_html_() ----------------------- - -An HTML table is constructed for the plate ID, for all of the experimental wells: - -.. code-block:: python - - bioplate._repr_html_() - ----------------------- -Accessible content ----------------------- - -The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *id* ``str``: The plate ID that will be assessed. -- *rows* & *cols* ``list``: The rows and columns of the experimental system, respectively. -- *wells* & *base* ``dict``: Dictionaries of the experimental wells and added solution that will be constructed into media, respectively. - - -+++++++++++++++++++++ -Biolog() -+++++++++++++++++++++ - -This class applies plates to the model medium: - -.. code-block:: python - - from modelseedpy.fbapkg import Biolog - biol = Biolog() - ----------------------- -add_plate() ----------------------- - -The parameterized plate is added to the collection of plates: - -.. code-block:: python - - biol.add_plate(plate) - -- *plate* ``Plate object``: A plate object of the experimental content. - ----------------------- -run_plates() ----------------------- - -Each well of each plate is defined as the model media, and the simulation results from that media are stored will the respective plate and well: - -.. code-block:: python - - biol.run_plates(model, biomass=None, cmp='e') - -- *model* ``cobra.core.model.Model``: The model whose medium will be updated with the composed media. -- *cmp* ``str``: The compartment of the exchange metabolite. - ----------------------- -Accessible content ----------------------- - -The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *plates* ``dict``: The collection of plates (``values``) for all plate IDs (``keys``), will is updated with simulation results from each well media. +biology +------------------- + ++++++++++++++++++++++ +BiologPlate() ++++++++++++++++++++++ + +This class assembles media from lists of compounds and HTML representations of the well media: + +.. code-block:: python + + from modelseedpy.core import BiologPlate + bioplate = BiologPlate(plate_id, rows, cols) + +- *plate_id* ``str``: The ID of the plate that will be parsed to develop a simulation media. +- *rows* & *cols* ``list``: The rows and columns of the experimental system, respectively. + +---------------------- +add_base() +---------------------- + +A list of compounds are ascribed a value to construct a media: + +.. code-block:: python + + bioplate.add_base(compounds, value) + +- *compounds* ``list``: The compounds that will constitute a media. +- *value* ``float``: The value that will be assigned to each compound. + +---------------------- +get_media() +---------------------- + +The generate a media from a defined well ID in the set of all wells: + +.. code-block:: python + + bioplate.get_media(well_id) + +- *well_id* ``dict``: The collection of compounds and values that supplant default entries from the ``add_base`` function, where compounds and values are provided as the ``values`` of the "compounds" and value" ``keys``, respectively. + +**returns** *media* ``dict``: The media that is created from the parameterized list of compounds and the respective value. + +---------------------- +_repr_html_() +---------------------- + +An HTML table is constructed for the plate ID, for all of the experimental wells: + +.. code-block:: python + + bioplate._repr_html_() + +---------------------- +Accessible content +---------------------- + +The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *id* ``str``: The plate ID that will be assessed. +- *rows* & *cols* ``list``: The rows and columns of the experimental system, respectively. +- *wells* & *base* ``dict``: Dictionaries of the experimental wells and added solution that will be constructed into media, respectively. + + ++++++++++++++++++++++ +Biolog() ++++++++++++++++++++++ + +This class applies plates to the model medium: + +.. code-block:: python + + from modelseedpy.fbapkg import Biolog + biol = Biolog() + +---------------------- +add_plate() +---------------------- + +The parameterized plate is added to the collection of plates: + +.. code-block:: python + + biol.add_plate(plate) + +- *plate* ``Plate object``: A plate object of the experimental content. + +---------------------- +run_plates() +---------------------- + +Each well of each plate is defined as the model media, and the simulation results from that media are stored will the respective plate and well: + +.. code-block:: python + + biol.run_plates(model, biomass=None, cmp='e') + +- *model* ``cobra.core.model.Model``: The model whose medium will be updated with the composed media. +- *cmp* ``str``: The compartment of the exchange metabolite. + +---------------------- +Accessible content +---------------------- + +The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *plates* ``dict``: The collection of plates (``values``) for all plate IDs (``keys``), will is updated with simulation results from each well media. diff --git a/docs/source/core/core_index.rst b/docs/source/core/core_index.rst deleted file mode 100644 index 9234561f..00000000 --- a/docs/source/core/core_index.rst +++ /dev/null @@ -1,45 +0,0 @@ -core -________________________________________________________________________ - -|PyPI version| |License| |Downloads| - -.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen - :target: https://pypi.org/project/modelseedpy/ - :alt: PyPI version - -.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg - :target: https://github.com/freiburgermsu/modelseedpy/actions - :alt: Actions Status - -.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg - :target: https://opensource.org/licenses/MIT - :alt: License - -.. |Downloads| image:: https://pepy.tech/badge/modelseedpy - :target: https://pepy.tech/project/modelseedpy - :alt: Downloads - -The ModelSEEDpy packages that parse and manipulate, e.g. gapfill, metabolic models are assembled into the ``core`` directory of ModelSEEDpy. These packages are imported via:: - - from modelseedpy.core import * - -and include the following - -.. toctree:: - - biology_api - fbahelper_api - gapfillinghelper_api - msatpcorrection_api - msbuilder_api - mseditorapi_api - msgenome_api - msgapfill_api - msgenomeclassifier_api - msgrowthphenotypes_api - msmedia_api - msmodel_api - msmodelutils_api - mstemplate_api - rpcclient_api - template_api diff --git a/docs/source/core/fbahelper_api.rst b/docs/source/core/fbahelper_api.rst index 45a04d5d..dbd999ab 100644 --- a/docs/source/core/fbahelper_api.rst +++ b/docs/source/core/fbahelper_api.rst @@ -1,296 +1,296 @@ -FBAHelper Packages -------------------- - -+++++++++++++++++++++ -FBAHelper() -+++++++++++++++++++++ - -This class offers a suite of static method functions that assist users in editing and expanding COBRA models: - -.. code-block:: python - - from modelseedpy.core import FBAHelper - ---------------------------------------------------- -add_autodrain_reactions_to_community_model() ---------------------------------------------------- - -Drain reactions are added to a model: - -.. code-block:: python - - fbahelper.add_autodrain_reactions_to_community_model(model,auto_sink = ["cpd02701", "cpd15302"]) - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. -- *auto_sink* ``list``: The collection of metabolites for which drain reactions will be created and added to the model. - --------------------------------- -add_drain_from_metabolite_id() --------------------------------- - -A drain reaction is constructed for a specified metabolite: - -.. code-block:: python - - drain_reaction = fbahelper.add_drain_from_metabolite_id(model, cpd_id, uptake, excretion, prefix='EX_', prefix_name='Exchange for ') - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. -- *cpd_id* ``str``: The ID of the compound for which a drain reaction will be constructed. -- *uptake* & *excretion* ``float``: The magnitudes of metabolite uptake and excretion that define the lower and upper bounds of the drain reaction. -- *prefix* & *prefix_name* ``str``: The prefixes for the drain reaction ID and name, respectively. - -**returns** *drain_reaction* ``cobra.core.model.Reaction``: The drain reaction of the respective metabolite. - --------------------------------- -test_condition_list() --------------------------------- - -A collection of simulation conditions are examined for the specified model: - -.. code-block:: python - - test_result = fbahelper.test_condition_list(model, condition_list, pkgmgr) - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. -- *condition_list* ``list``: A list of simulation conditions that will be each examined during the simulation. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. - -**returns** *test_result* ``bool``: specifies whether all of the conditions yielded feasible solutions and objective values that surpassed the provided threshold with each condition. - --------------------------------- -reaction_expansion_test() --------------------------------- - -The reactions that cause simulations to not pass all conditions is collected and returned: - -.. code-block:: python - - filtered_list = fbahelper.reaction_expansion_test(model, reaction_list, condition_list, pkgmgr) - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. -- *reaction_list* ``list``: The collections of COBRA reactions that will be knocked-out and then are iteratively restored while assessing whether all of the conditions pass the reaction. -- *condition_list* ``list``: and simulation conditions that will be simulated. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. - -**returns** *filtered_list* ``list``: The collection of reactions from the ``reaction_list`` for which at least one of the simulation conditions failed. - -------------------------------------- -set_reaction_bounds_from_direction() -------------------------------------- - -The reaction bounds are set based upon the reaction direction: - -.. code-block:: python - - fbahelper.set_reaction_bounds_from_direction(reaction, direction, add=False) - -- *reaction* ``cobra.core.model.Reaction``: A COBRA reaction whose flux bounds will be adjusted based upon the direction of the reaction. -- *direction* ``str``: The ``<`` or ``>`` designation of the reaction direction. -- *add* ``bool``: specifies whether the upper bound for ``<`` directions or the lower bound for ``>`` directions will be assigned to zero. - -------------------------------------- -set_objective_from_target_reaction() -------------------------------------- - -The FBA reaction objective is defined: - -.. code-block:: python - - target_reaction = fbahelper.set_objective_from_target_reaction(model,target_reaction,minimize = False) - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. -- *target_reaction* ``str``: The ID of the COBRA reaction in the parameterized model that will be set as the model objective. -- *minimize* ``bool``: specifies whether the simulation will minimize the objective. - -**returns** *target_reaction* ``cobra.core.model.Reaction``: The reaction that is specified to be the simulation objective. - -------------------------------------- -compute_flux_values_from_variables() -------------------------------------- - -Defines the reaction fluxes for all model reactions: - -.. code-block:: python - - flux_values = fbahelper.compute_flux_values_from_variables(model) - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which will be interpreted for the fluxes. - -**returns** *flux_values* ``cobra.core.model.Reaction``: The reaction that is specified to be the simulation objective. - -------------------------------------- -modelseed_id_from_cobra_metabolite() -------------------------------------- - -A ModelSEED compound ID is determined from a COBRA metabolite ID: - -.. code-block:: python - - msid = fbahelper.modelseed_id_from_cobra_metabolite(metabolite) - -- *model* ``cobra.core.model.Metabolite``: The COBRA metabolite whose ModelSEED ID will be returned from a COBRA ID. - -**returns** *msid* ``str``: The ModelSEED metabolite ID that is parsed from the COBRA ID. - -------------------------------------- -modelseed_id_from_cobra_reaction() -------------------------------------- - -A ModelSEED reaction ID is determined from a COBRA reaction ID: - -.. code-block:: python - - msid = fbahelper.modelseed_id_from_cobra_reaction(reaction) - -- *model* ``cobra.core.model.Reaction``: The COBRA reaction whose ModelSEED ID will be returned from a COBRA ID. - -**returns** *msid* ``str``: The ModelSEED reaction ID that is parsed from the COBRA reaction ID. - -------------------------------------- -metabolite_mw() -------------------------------------- - -The molecular weight of a metabolite is calculated from its elemental composition, or its chemical formula when the elements are unavailable: - -.. code-block:: python - - mw = fbahelper.metabolite_mw(metabolite) - -- *model* ``cobra.core.model.Metabolite``: The COBRA metabolite whose molecular weight will be calculated. - -**returns** *mw* ``float``: The molecular weight of the parameterized metabolite. - -------------------------------------- -elemental_mass() -------------------------------------- - -**returns** *elementmasses* ``dict``: A dictionary of all elemental masses (``values``) for all chemical symbols (``keys``). - -------------------------------------- -get_modelseed_db_api() -------------------------------------- - -**returns** *modelseed_api* ``ModelSEED``: The ModelSEED Database that can be used for ModelSEEDpy operations. - -------------------------------------- -is_ex() & is_biomass() -------------------------------------- - -Functions that determine whether parameterized reactions are exchange or biomass reactions, respectively: - -.. code-block:: python - - result = fbahelper.is_ex(reaction) - result = fbahelper.is_biomass(reaction) - -- *reaction* ``cobra.core.model.Reaction``: The COBRA reaction that will be examined as being either an exchange or biomass reaction, respectively. - -**returns** *result* ``bool``: specifies whether the parameterized reaction is one of the two reaction types. - -------------------------------------- -find_reaction() -------------------------------------- - -Identifies a reaction in a model based upon reaction stoichiometry: - -.. code-block:: python - - reaction = fbahelper.find_reaction(model, stoichiometry) - -- *model* ``cobra.core.model.Model``: The COBRA model in which the reaction will be searched. -- *stoichiometry* ``dict``: The stoichiometry of the reaction that will be searched in the model. - -**returns** *reaction* ``cobra.core.model.Model``: The located COBRA reaction, if its reaction string is identified in the model, or ``None`` otherwise. - -------------------------------------- -msid_hash() -------------------------------------- - -Assembles all of the COBRA metabolites that correspond to the same ModelSEED metabolite ID: - -.. code-block:: python - - reaction = fbahelper.msid_hash(model) - -- *model* ``cobra.core.model.Model``: The COBRA model where all of the metabolites will be searched. - -**returns** *metabolites* ``dict``: Lists of all COBRA metabolites (``values``) that are represented by a ModelSEED compound ID. - -------------------------------------- -rxn_hash() -------------------------------------- - -Pairs all reaction strings, in both directions, with their corresponding COBRA reaction object: - -.. code-block:: python - - reaction = fbahelper.rxn_hash(model) - -- *model* ``cobra.core.model.Model``: The COBRA model where all of the metabolites will be searched. - -**returns** *reactions* ``dict``: Lists of all COBRA reaction objects with a designation of their directionality (``values``) according to their reaction strings (``keys``). - -------------------------------------- -rxn_compartment() -------------------------------------- - -Determines the non-extracellular compartment of the parameterized reaction: - -.. code-block:: python - - compartment = fbahelper.rxn_compartment(reaction) - -- *model* ``cobra.core.model.Reaction``: The COBRA reaction whose non-extracellular compartment will be provided. - -**returns** *compartment* ``str``: The non-extracellular reaction compartment. - -------------------------------------- -add_atp_hydrolysis() -------------------------------------- - -Adds an ATP Hydrolysis reaction to the parameterized model in the specified compartment: - -.. code-block:: python - - reaction_dict = fbahelper.add_atp_hydrolysis(model,compartment) - -- *model* ``cobra.core.model.Model``: The COBRA model into which an ATP hydrolysis reaction will be added. -- *compartment* ``str``: The compartment of the ATP hydrolysis reaction, which is sensitive to community models where each species is represented with a unique compartment. - -**returns** *reaction_dict* ``dict``: The reaction string, direction, and newness of the reaction (``values``) are specified for the constructed ATP hydrolysis reaction (``keys``). - -------------------------------------- -parse_id() -------------------------------------- - -Determines the non-extracellular compartment of the parameterized reaction: - -.. code-block:: python - - ID_components = fbahelper.parse_id(cobra_obj) - -- *cobra_obj* ``str``: The COBRA object ID that will be parsed. - -**returns** *ID_components* ``tuple``: The basename, compartment, and index of the COBRA object in a single tuple, respectively. - -------------------------------------- -medianame() -------------------------------------- - -**returns** *media_id* ``str``: The ID of a media, where "Complete" is provided by default. - -------------------------------------- -validate_dictionary() -------------------------------------- - -Validates a dictionary based upon the requirements and optional default values are added to the dictionary: - -.. code-block:: python - - validated_dictionary = fbahelper.validate_dictionary(dictionary, required_keys, defaults) - -- *dictionary* ``dict``: The dictionary that will be validated. -- *required_keys* ``list``: The collection of keys that must be provided in the dictionary. -- *defaults* ``dict``: The default entries that will be added to the dictionary. - -**returns** *validated_dictionary* ``dict``: The dictionary that has been validated through the function. +fbahelper +------------------- + ++++++++++++++++++++++ +FBAHelper() ++++++++++++++++++++++ + +This class offers a suite of static method functions that assist users in editing and expanding COBRA models: + +.. code-block:: python + + from modelseedpy.core import FBAHelper + +--------------------------------------------------- +add_autodrain_reactions_to_community_model() +--------------------------------------------------- + +Drain reactions are added to a model: + +.. code-block:: python + + fbahelper.add_autodrain_reactions_to_community_model(model,auto_sink = ["cpd02701", "cpd15302"]) + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. +- *auto_sink* ``list``: The collection of metabolites for which drain reactions will be created and added to the model. + +-------------------------------- +add_drain_from_metabolite_id() +-------------------------------- + +A drain reaction is constructed for a specified metabolite: + +.. code-block:: python + + drain_reaction = fbahelper.add_drain_from_metabolite_id(model, cpd_id, uptake, excretion, prefix='EX_', prefix_name='Exchange for ') + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. +- *cpd_id* ``str``: The ID of the compound for which a drain reaction will be constructed. +- *uptake* & *excretion* ``float``: The magnitudes of metabolite uptake and excretion that define the lower and upper bounds of the drain reaction. +- *prefix* & *prefix_name* ``str``: The prefixes for the drain reaction ID and name, respectively. + +**returns** *drain_reaction* ``cobra.core.model.Reaction``: The drain reaction of the respective metabolite. + +-------------------------------- +test_condition_list() +-------------------------------- + +A collection of simulation conditions are examined for the specified model: + +.. code-block:: python + + test_result = fbahelper.test_condition_list(model, condition_list, pkgmgr) + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. +- *condition_list* ``list``: A list of simulation conditions that will be each examined during the simulation. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. + +**returns** *test_result* ``bool``: specifies whether all of the conditions yielded feasible solutions and objective values that surpassed the provided threshold with each condition. + +-------------------------------- +reaction_expansion_test() +-------------------------------- + +The reactions that cause simulations to not pass all conditions is collected and returned: + +.. code-block:: python + + filtered_list = fbahelper.reaction_expansion_test(model, reaction_list, condition_list, pkgmgr) + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. +- *reaction_list* ``list``: The collections of COBRA reactions that will be knocked-out and then are iteratively restored while assessing whether all of the conditions pass the reaction. +- *condition_list* ``list``: and simulation conditions that will be simulated. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. + +**returns** *filtered_list* ``list``: The collection of reactions from the ``reaction_list`` for which at least one of the simulation conditions failed. + +------------------------------------- +set_reaction_bounds_from_direction() +------------------------------------- + +The reaction bounds are set based upon the reaction direction: + +.. code-block:: python + + fbahelper.set_reaction_bounds_from_direction(reaction, direction, add=False) + +- *reaction* ``cobra.core.model.Reaction``: A COBRA reaction whose flux bounds will be adjusted based upon the direction of the reaction. +- *direction* ``str``: The ``<`` or ``>`` designation of the reaction direction. +- *add* ``bool``: specifies whether the upper bound for ``<`` directions or the lower bound for ``>`` directions will be assigned to zero. + +------------------------------------- +set_objective_from_target_reaction() +------------------------------------- + +The FBA reaction objective is defined: + +.. code-block:: python + + target_reaction = fbahelper.set_objective_from_target_reaction(model,target_reaction,minimize = False) + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. +- *target_reaction* ``str``: The ID of the COBRA reaction in the parameterized model that will be set as the model objective. +- *minimize* ``bool``: specifies whether the simulation will minimize the objective. + +**returns** *target_reaction* ``cobra.core.model.Reaction``: The reaction that is specified to be the simulation objective. + +------------------------------------- +compute_flux_values_from_variables() +------------------------------------- + +Defines the reaction fluxes for all model reactions: + +.. code-block:: python + + flux_values = fbahelper.compute_flux_values_from_variables(model) + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which will be interpreted for the fluxes. + +**returns** *flux_values* ``cobra.core.model.Reaction``: The reaction that is specified to be the simulation objective. + +------------------------------------- +modelseed_id_from_cobra_metabolite() +------------------------------------- + +A ModelSEED compound ID is determined from a COBRA metabolite ID: + +.. code-block:: python + + msid = fbahelper.modelseed_id_from_cobra_metabolite(metabolite) + +- *model* ``cobra.core.model.Metabolite``: The COBRA metabolite whose ModelSEED ID will be returned from a COBRA ID. + +**returns** *msid* ``str``: The ModelSEED metabolite ID that is parsed from the COBRA ID. + +------------------------------------- +modelseed_id_from_cobra_reaction() +------------------------------------- + +A ModelSEED reaction ID is determined from a COBRA reaction ID: + +.. code-block:: python + + msid = fbahelper.modelseed_id_from_cobra_reaction(reaction) + +- *model* ``cobra.core.model.Reaction``: The COBRA reaction whose ModelSEED ID will be returned from a COBRA ID. + +**returns** *msid* ``str``: The ModelSEED reaction ID that is parsed from the COBRA reaction ID. + +------------------------------------- +metabolite_mw() +------------------------------------- + +The molecular weight of a metabolite is calculated from its elemental composition, or its chemical formula when the elements are unavailable: + +.. code-block:: python + + mw = fbahelper.metabolite_mw(metabolite) + +- *model* ``cobra.core.model.Metabolite``: The COBRA metabolite whose molecular weight will be calculated. + +**returns** *mw* ``float``: The molecular weight of the parameterized metabolite. + +------------------------------------- +elemental_mass() +------------------------------------- + +**returns** *elementmasses* ``dict``: A dictionary of all elemental masses (``values``) for all chemical symbols (``keys``). + +------------------------------------- +get_modelseed_db_api() +------------------------------------- + +**returns** *modelseed_api* ``ModelSEED``: The ModelSEED Database that can be used for ModelSEEDpy operations. + +------------------------------------- +is_ex() & is_biomass() +------------------------------------- + +Functions that determine whether parameterized reactions are exchange or biomass reactions, respectively: + +.. code-block:: python + + result = fbahelper.is_ex(reaction) + result = fbahelper.is_biomass(reaction) + +- *reaction* ``cobra.core.model.Reaction``: The COBRA reaction that will be examined as being either an exchange or biomass reaction, respectively. + +**returns** *result* ``bool``: specifies whether the parameterized reaction is one of the two reaction types. + +------------------------------------- +find_reaction() +------------------------------------- + +Identifies a reaction in a model based upon reaction stoichiometry: + +.. code-block:: python + + reaction = fbahelper.find_reaction(model, stoichiometry) + +- *model* ``cobra.core.model.Model``: The COBRA model in which the reaction will be searched. +- *stoichiometry* ``dict``: The stoichiometry of the reaction that will be searched in the model. + +**returns** *reaction* ``cobra.core.model.Model``: The located COBRA reaction, if its reaction string is identified in the model, or ``None`` otherwise. + +------------------------------------- +msid_hash() +------------------------------------- + +Assembles all of the COBRA metabolites that correspond to the same ModelSEED metabolite ID: + +.. code-block:: python + + reaction = fbahelper.msid_hash(model) + +- *model* ``cobra.core.model.Model``: The COBRA model where all of the metabolites will be searched. + +**returns** *metabolites* ``dict``: Lists of all COBRA metabolites (``values``) that are represented by a ModelSEED compound ID. + +------------------------------------- +rxn_hash() +------------------------------------- + +Pairs all reaction strings, in both directions, with their corresponding COBRA reaction object: + +.. code-block:: python + + reaction = fbahelper.rxn_hash(model) + +- *model* ``cobra.core.model.Model``: The COBRA model where all of the metabolites will be searched. + +**returns** *reactions* ``dict``: Lists of all COBRA reaction objects with a designation of their directionality (``values``) according to their reaction strings (``keys``). + +------------------------------------- +rxn_compartment() +------------------------------------- + +Determines the non-extracellular compartment of the parameterized reaction: + +.. code-block:: python + + compartment = fbahelper.rxn_compartment(reaction) + +- *model* ``cobra.core.model.Reaction``: The COBRA reaction whose non-extracellular compartment will be provided. + +**returns** *compartment* ``str``: The non-extracellular reaction compartment. + +------------------------------------- +add_atp_hydrolysis() +------------------------------------- + +Adds an ATP Hydrolysis reaction to the parameterized model in the specified compartment: + +.. code-block:: python + + reaction_dict = fbahelper.add_atp_hydrolysis(model,compartment) + +- *model* ``cobra.core.model.Model``: The COBRA model into which an ATP hydrolysis reaction will be added. +- *compartment* ``str``: The compartment of the ATP hydrolysis reaction, which is sensitive to community models where each species is represented with a unique compartment. + +**returns** *reaction_dict* ``dict``: The reaction string, direction, and newness of the reaction (``values``) are specified for the constructed ATP hydrolysis reaction (``keys``). + +------------------------------------- +parse_id() +------------------------------------- + +Determines the non-extracellular compartment of the parameterized reaction: + +.. code-block:: python + + ID_components = fbahelper.parse_id(cobra_obj) + +- *cobra_obj* ``str``: The COBRA object ID that will be parsed. + +**returns** *ID_components* ``tuple``: The basename, compartment, and index of the COBRA object in a single tuple, respectively. + +------------------------------------- +mediaName() +------------------------------------- + +**returns** *media_id* ``str``: The ID of a media, where "Complete" is provided by default. + +------------------------------------- +validate_dictionary() +------------------------------------- + +Validates a dictionary based upon the requirements and optional default values are added to the dictionary: + +.. code-block:: python + + validated_dictionary = fbahelper.validate_dictionary(dictionary, required_keys, defaults) + +- *dictionary* ``dict``: The dictionary that will be validated. +- *required_keys* ``list``: The collection of keys that must be provided in the dictionary. +- *defaults* ``dict``: The default entries that will be added to the dictionary. + +**returns** *validated_dictionary* ``dict``: The dictionary that has been validated through the function. diff --git a/docs/source/core/gapfillinghelper_api.rst b/docs/source/core/gapfillinghelper_api.rst index 0939a0fd..6f60ee8a 100644 --- a/docs/source/core/gapfillinghelper_api.rst +++ b/docs/source/core/gapfillinghelper_api.rst @@ -1,210 +1,210 @@ -gapfillinghelper ------------------- - -+++++++++++++++++++++ -GapfillingHelper -+++++++++++++++++++++ - -A class of functions that assist modifying models: - -.. code-block:: python - - gfhelper = GapfillingHelper(blacklist = [], auto_sink = ["cpd02701_c", "cpd11416_c0", "cpd15302_c"]) - -- *blacklist* ``list``: The collection of IDs for reactions that will not be examined during gapfilling. -- *auto_sink* ``list``: The collection of IDs for reactions that represent biomass growth. - ------------------------------------------- -test_reaction_additions_againt_limits() ------------------------------------------- - -Returns the collection of genes for all roles of all complexes from the template reaction: - -.. code-block:: python - - filtered = gfhelper.test_reaction_additions_againt_limits(model,reactions,tests) - -- *model* ``cobra.core.model.Model``: The COBRA model whose reactions will be tested. -- *reactions* ``list``: The collection of COBRA reactions in the ``model`` that will be tested. -- *tests* ``list``: The collection of dictionaries for the tests, with keys of ``"media"``, ``"default_uptake"``, ``"default_excretion"``, ``"target"``, & ``"maximize"``. - -**Returns** *filtered* ``cobra.core.dictlist.DictList``: The collection of tests that contained an objective maximum of 1 and greater than the test limit. - --------------------------------------------- -build_model_extended_for_gapfilling() --------------------------------------------- - -Extends a model with reactions and metabolites from collections of source models and possibly templates: - -.. code-block:: python - - gapfilling_penalties = gfhelper.build_model_extended_for_gapfilling(extend_with_template = True, source_models = [], input_templates = [], model_penalty = 1, reaction_scores = {}) - -- *extend_with_template* ``bool``: specifies whether the gapfilling penalties will be extended with a template. -- *source_models* & *input_templates* ``list``: The collections of models and templates whose reactions and metabolites be extend the object model before its gapfilling. -- *model_penalty* ``int``: The gapfilling penalty for reaction flux, with an equal weighting in both directions. -- *reaction_scores* ``dict``: The gapfilling reaction scores (``values``) for each gene of each reaction (``keys``). - -**Returns** *gapfilling_penalties* ``dict``: The gapfilling penalties of the extended model. - ---------------------------------------------------------- -convert_modelreaction() & convert_modelcompound() ---------------------------------------------------------- - -Formats COBRA reactions and metabolites for ModelSEED operations, respectively: - -.. code-block:: python - - cobra_rxn = gfhelper.convert_modelreaction(reaction, bigg=False) - cobra_met = gfhelper.convert_modelreaction(metabolite, bigg=False) - -- *reaction* ``cobra.core.reaction.Reaction``: The COBRA reaction that will be reformatted. -- *metabolite* ``cobra.core.metabolite.Metabolite``: The COBRA metabolite that will be reformatted. -- *bigg* ``bool``: specifies whether the COBRA object originates from a BiGG model, which requires an additional reformulation. - -**Returns** *cobra_rxn* ``cobra.core.reaction.Reaction``: The reaction that is generated from the ModelSEED reaction. -**Returns** *cobra_met* ``cobra.core.metabolite.Metabolite``: The metabolite that is generated from the ModelSEED metabolite. - --------------------------------------- -binary_check_gapfilling_solution() --------------------------------------- - -Constructs binary variables for the direction of all model reactions, the sum of which are minimized and the resulting fluxes are returned: - -.. code-block:: python - - flux_values = gfhelper.binary_check_gapfilling_solution(gapfilling_penalties,add_solution_exclusion_constraint) - -- *gapfilling_penalties* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``). -- *add_solution_exclusion_constraint* ``bool``: specifies whether a binary exclusion constraint will be added based upon the primal flux values, which renders a gapfilled solution infeasible and thus permits the determination of a new solution. - -**Returns** *flux_values* ``dict``: The collection of all primal flux values (``values``) for each direction of all reaction IDs (``keys``). - --------------------------------------- -create_minimal_reaction_objective() --------------------------------------- - -Constructs an objective function that minimizes the flux of gapfilled reactions: - -.. code-block:: python - - gene = gfhelper.create_minimal_reaction_objective(penalty_hash, default_penalty = 0) - -- *penalty_hash* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``), which will be minimized through this function. -- *default_penalty* ``str``: The default gapfill penalty and is the default flux coefficient in the objective function for all reactions. - ------------------------------------------ -convert_cobra_compound_to_kbcompound() ------------------------------------------ - -Constructs a metadata dictionary of a COBRA Metabolite object that is returned and can be added to a KBase model: - -.. code-block:: python - - cpd_data = gfhelper.convert_cobra_compound_to_kbcompound(cpd, kbmodel=None) - -- *cpd* ``cobra.core.metabolite.Metabolite``: The COBRA Metabolite that will be converted into a KBase Metabolite. -- *kbmodel* ``cobrakbase model``: The KBase model that will be expanded with ``cpd`` metadata, where ``None`` specifies that the compound will not be added. - -**Returns** *cpd_data* ``dict``: The collection of ``cpd`` attributes in key-value pairs. - ------------------------------------------ -convert_cobra_reaction_to_kbreaction() ------------------------------------------ - -Constructs a metadata dictionary of a COBRA Reaction object that is returned and can be added to a KBase model: - -.. code-block:: python - - rxn_data = gfhelper.convert_cobra_reaction_to_kbreaction(rxn, kbmodel, direction="=", add_to_model=True) - -- *rxn* ``cobra.core.metabolite.Metabolite``: The COBRA Metabolite that will be converted into a KBase Reaction. -- *kbmodel* ``cobrakbase model``: The KBase model that contains ``rxn``. -- *direction* ``str``: The "<", "=", or ">" direction of ``rxn``. -- *add_to_model* ``bool``: specifies whether the reaction metadata will be added to the KBase model. - -**Returns** *rxn_data* ``dict``: The collection of ``rxn`` attributes in key-value pairs. - ------------------------------------------ -convert_objective_to_constraint() ------------------------------------------ - -Coverts an old objective function into a variable and constructs a new constraint that the new objective must equate the old object. The variable and constraint are added to the ``cobramodel`` in the extant object: - -.. code-block:: python - - gfhelper.convert_objective_to_constraint(lower_bound, upper_bound) - -- *lower_bound* & *upper_bound* ``float``: The bounds that will contrain the objective function variable. - ------------------------------------------ -compute_gapfilled_solution() ------------------------------------------ - -Returns the direction for all gapfilled reactions in a model: - -.. code-block:: python - - directions = gfhelper.compute_gapfilled_solution(penalty_hash, flux_values = None) - -- *penalty_hash* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``), which will be minimized through this function. -- *flux_values* ``dict``: The collection of all primal flux values (``values``) for each direction of all reaction IDs (``keys``), where ``None`` constructs *flux_values* from the from ``cobramodel`` in class object. - -**Returns** *directions* ``dict``: The collection of directions (``values``) for all reactions in a ``cobramodel`` that are stored in ``penalty_hash``. - ------------------------------------------ -add_gapfilling_solution_to_kbase_model() ------------------------------------------ - -The gapfilled reactions of a solution are added to a model: - -.. code-block:: python - - gfhelper.add_gapfilling_solution_to_kbase_model(newmodel, penalty_hash, media_ref) - -- *newmodel* ``cobrakbase Model``: The model to which the gapfilled content will be added. -- *penalty_hash* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``), which will be minimized through this function. -- *media_ref* ``str``: The reference of the media that was used to gapfill the model. - ------------------------------------------ -compute_reaction_scores() ------------------------------------------ - -Returns the gapfilling reaction scores for all events, with possible weighting: - -.. code-block:: python - - reaction_genes = gfhelper.compute_reaction_scores(weights=None) - -- *weights* ``dict``: The collection of gapfill-weightings (``values``) for each event, via ``"description"``, ``"event_id"``, or ``"id"`` attributes of the event (``keys``). An argument of ``None`` specifies that all events will be equally weighted. - -**Returns** *reaction_genes* ``dict``: The collection of reaction scores (``values``) for each gene of all reactions over all ontological events in ``fbamodel``. - ------------------------------------------ -replicate_model() ------------------------------------------ - -Returns a new model that contains a parameterized number of duplicate content of the ``cobramodel`` in the class object: - -.. code-block:: python - - newmodel = gfhelper.replicate_model(count) - -- *count* ``int``: The number of copies of the ``cobramodel`` that are added to the new model. - -**Returns** *newmodel* ``cobra.core.model.Model``: The duplicated COBRA model. - ------------------------------------------ -test_reaction_additions_againt_limits() ------------------------------------------ - -Returns a new model that contains a parameterized number of duplicate content of the ``cobramodel`` in the class object: - -.. code-block:: python - - newmodel = gfhelper.replicate_model(reactions, directions, tests) - -- *reactions* ``dict``: The "<" or ">" reaction directions (``values``) for all COBRA reactions that will be tested (``keys``). -- *tests* ``list``: The collection of tests that will be examined for the reactions in the ``cobrakbase`` model. - -**Returns** *filtered_tests* ``dict``: The collection of reaction directions and reaction objects in key-value pairs. +gapfillinghelper +------------------ + ++++++++++++++++++++++ +GapfillingHelper ++++++++++++++++++++++ + +A class of functions that assist modifying models: + +.. code-block:: python + + gfhelper = GapfillingHelper(blacklist = [], auto_sink = ["cpd02701_c", "cpd11416_c0", "cpd15302_c"]) + +- *blacklist* ``list``: The collection of IDs for reactions that will not be examined during gapfilling. +- *auto_sink* ``list``: The collection of IDs for reactions that represent biomass growth. + +------------------------------------------ +test_reaction_additions_againt_limits() +------------------------------------------ + +Returns the collection of genes for all roles of all complexes from the template reaction: + +.. code-block:: python + + filtered = gfhelper.test_reaction_additions_againt_limits(model,reactions,tests) + +- *model* ``cobra.core.model.Model``: The COBRA model whose reactions will be tested. +- *reactions* ``list``: The collection of COBRA reactions in the ``model`` that will be tested. +- *tests* ``list``: The collection of dictionaries for the tests, with keys of ``"media"``, ``"default_uptake"``, ``"default_excretion"``, ``"target"``, & ``"maximize"``. + +**Returns** *filtered* ``cobra.core.dictlist.DictList``: The collection of tests that contained an objective maximum of 1 and greater than the test limit. + +-------------------------------------------- +build_model_extended_for_gapfilling() +-------------------------------------------- + +Extends a model with reactions and metabolites from collections of source models and possibly templates: + +.. code-block:: python + + gapfilling_penalties = gfhelper.build_model_extended_for_gapfilling(extend_with_template = True, source_models = [], input_templates = [], model_penalty = 1, reaction_scores = {}) + +- *extend_with_template* ``bool``: specifies whether the gapfilling penalties will be extended with a template. +- *source_models* & *input_templates* ``list``: The collections of models and templates whose reactions and metabolites be extend the object model before its gapfilling. +- *model_penalty* ``int``: The gapfilling penalty for reaction flux, with an equal weighting in both directions. +- *reaction_scores* ``dict``: The gapfilling reaction scores (``values``) for each gene of each reaction (``keys``). + +**Returns** *gapfilling_penalties* ``dict``: The gapfilling penalties of the extended model. + +--------------------------------------------------------- +convert_modelreaction() & convert_modelcompound() +--------------------------------------------------------- + +Formats COBRA reactions and metabolites for ModelSEED operations, respectively: + +.. code-block:: python + + cobra_rxn = gfhelper.convert_modelreaction(reaction, bigg=False) + cobra_met = gfhelper.convert_modelreaction(metabolite, bigg=False) + +- *reaction* ``cobra.core.reaction.Reaction``: The COBRA reaction that will be reformatted. +- *metabolite* ``cobra.core.metabolite.Metabolite``: The COBRA metabolite that will be reformatted. +- *bigg* ``bool``: specifies whether the COBRA object originates from a BiGG model, which requires an additional reformulation. + +**Returns** *cobra_rxn* ``cobra.core.reaction.Reaction``: The reaction that is generated from the ModelSEED reaction. +**Returns** *cobra_met* ``cobra.core.metabolite.Metabolite``: The metabolite that is generated from the ModelSEED metabolite. + +-------------------------------------- +binary_check_gapfilling_solution() +-------------------------------------- + +Constructs binary variables for the direction of all model reactions, the sum of which are minimized and the resulting fluxes are returned: + +.. code-block:: python + + flux_values = gfhelper.binary_check_gapfilling_solution(gapfilling_penalties,add_solution_exclusion_constraint) + +- *gapfilling_penalties* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``). +- *add_solution_exclusion_constraint* ``bool``: specifies whether a binary exclusion constraint will be added based upon the primal flux values, which renders a gapfilled solution infeasible and thus permits the determination of a new solution. + +**Returns** *flux_values* ``dict``: The collection of all primal flux values (``values``) for each direction of all reaction IDs (``keys``). + +-------------------------------------- +create_minimal_reaction_objective() +-------------------------------------- + +Constructs an objective function that minimizes the flux of gapfilled reactions: + +.. code-block:: python + + gene = gfhelper.create_minimal_reaction_objective(penalty_hash, default_penalty = 0) + +- *penalty_hash* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``), which will be minimized through this function. +- *default_penalty* ``str``: The default gapfill penalty and is the default flux coefficient in the objective function for all reactions. + +----------------------------------------- +convert_cobra_compound_to_kbcompound() +----------------------------------------- + +Constructs a metadata dictionary of a COBRA Metabolite object that is returned and can be added to a KBase model: + +.. code-block:: python + + cpd_data = gfhelper.convert_cobra_compound_to_kbcompound(cpd, kbmodel=None) + +- *cpd* ``cobra.core.metabolite.Metabolite``: The COBRA Metabolite that will be converted into a KBase Metabolite. +- *kbmodel* ``cobrakbase model``: The KBase model that will be expanded with ``cpd`` metadata, where ``None`` specifies that the compound will not be added. + +**Returns** *cpd_data* ``dict``: The collection of ``cpd`` attributes in key-value pairs. + +----------------------------------------- +convert_cobra_reaction_to_kbreaction() +----------------------------------------- + +Constructs a metadata dictionary of a COBRA Reaction object that is returned and can be added to a KBase model: + +.. code-block:: python + + rxn_data = gfhelper.convert_cobra_reaction_to_kbreaction(rxn, kbmodel, direction="=", add_to_model=True) + +- *rxn* ``cobra.core.metabolite.Metabolite``: The COBRA Metabolite that will be converted into a KBase Reaction. +- *kbmodel* ``cobrakbase model``: The KBase model that contains ``rxn``. +- *direction* ``str``: The "<", "=", or ">" direction of ``rxn``. +- *add_to_model* ``bool``: specifies whether the reaction metadata will be added to the KBase model. + +**Returns** *rxn_data* ``dict``: The collection of ``rxn`` attributes in key-value pairs. + +----------------------------------------- +convert_objective_to_constraint() +----------------------------------------- + +Coverts an old objective function into a variable and constructs a new constraint that the new objective must equate the old object. The variable and constraint are added to the ``cobramodel`` in the extant object: + +.. code-block:: python + + gfhelper.convert_objective_to_constraint(lower_bound, upper_bound) + +- *lower_bound* & *upper_bound* ``float``: The bounds that will contrain the objective function variable. + +----------------------------------------- +compute_gapfilled_solution() +----------------------------------------- + +Returns the direction for all gapfilled reactions in a model: + +.. code-block:: python + + directions = gfhelper.compute_gapfilled_solution(penalty_hash, flux_values = None) + +- *penalty_hash* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``), which will be minimized through this function. +- *flux_values* ``dict``: The collection of all primal flux values (``values``) for each direction of all reaction IDs (``keys``), where ``None`` constructs *flux_values* from the from ``cobramodel`` in class object. + +**Returns** *directions* ``dict``: The collection of directions (``values``) for all reactions in a ``cobramodel`` that are stored in ``penalty_hash``. + +----------------------------------------- +add_gapfilling_solution_to_kbase_model() +----------------------------------------- + +The gapfilled reactions of a solution are added to a model: + +.. code-block:: python + + gfhelper.add_gapfilling_solution_to_kbase_model(newmodel, penalty_hash, media_ref) + +- *newmodel* ``cobrakbase Model``: The model to which the gapfilled content will be added. +- *penalty_hash* ``dict``: The collection of gapfilling penalties (``values``) for each direction of all reaction IDs (``keys``), which will be minimized through this function. +- *media_ref* ``str``: The reference of the media that was used to gapfill the model. + +----------------------------------------- +compute_reaction_scores() +----------------------------------------- + +Returns the gapfilling reaction scores for all events, with possible weighting: + +.. code-block:: python + + reaction_genes = gfhelper.compute_reaction_scores(weights=None) + +- *weights* ``dict``: The collection of gapfill-weightings (``values``) for each event, via ``"description"``, ``"event_id"``, or ``"id"`` attributes of the event (``keys``). An argument of ``None`` specifies that all events will be equally weighted. + +**Returns** *reaction_genes* ``dict``: The collection of reaction scores (``values``) for each gene of all reactions over all ontological events in ``fbamodel``. + +----------------------------------------- +replicate_model() +----------------------------------------- + +Returns a new model that contains a parameterized number of duplicate content of the ``cobramodel`` in the class object: + +.. code-block:: python + + newmodel = gfhelper.replicate_model(count) + +- *count* ``int``: The number of copies of the ``cobramodel`` that are added to the new model. + +**Returns** *newmodel* ``cobra.core.model.Model``: The duplicated COBRA model. + +----------------------------------------- +test_reaction_additions_againt_limits() +----------------------------------------- + +Returns a new model that contains a parameterized number of duplicate content of the ``cobramodel`` in the class object: + +.. code-block:: python + + newmodel = gfhelper.replicate_model(reactions, directions, tests) + +- *reactions* ``dict``: The "<" or ">" reaction directions (``values``) for all COBRA reactions that will be tested (``keys``). +- *tests* ``list``: The collection of tests that will be examined for the reactions in the ``cobrakbase`` model. + +**Returns** *filtered_tests* ``dict``: The collection of reaction directions and reaction objects in key-value pairs. diff --git a/docs/source/core/msatpcorrection_api.rst b/docs/source/core/msatpcorrection_api.rst index a231bfe3..ad0af8b2 100644 --- a/docs/source/core/msatpcorrection_api.rst +++ b/docs/source/core/msatpcorrection_api.rst @@ -1,38 +1,38 @@ -msatpcorrection ---------------------- - -+++++++++++++++++++++ -MSATPCorrection -+++++++++++++++++++++ - -A class that corrects the ATP Hydrolysis reaction of a given model: - -.. code-block:: python - - msatp = MSATPCorrection(model, core_template, atp_medias, compartment="c0", max_gapfilling=None, gapfilling_delta=0, atp_hydrolysis_id=None) - -- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. -- *core_template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template that is used to correct the model. -- *atp_medias* ``modelseedpy.core.msmedia.MSMedia``: The media that is associated with the growth phenotype. -- *compartment* ``str``: The compartment in which ATP will be added. -- *max_gapfilling* ``float``: The greatest extent of gapfilling for respective model. -- *gapfilling_delta* ``int``: The allowable margin above the best gapfilling score that permits selection of a growth media. -- *atp_hydrolysis_id* ``str``: The ID of the ATP Hydrolysis reaction, where ``None`` specifies a SEED reaction search. - ------------------------------- -atp_correction() ------------------------------- - -``staticMethod`` Restores the bounds on all noncore reactions: - -.. code-block:: python - - msatpobj = msatp.run_atp_correction(model, coretemplate, atp_medias = None, max_gapfilling = None, gapfilling_delta = 0) - -- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. -- *coretemplate* ``modelseedpy.core.mstemplate.MSTemplate``: The template that consists of the reactions that be used to assess which reactions in the model are categorized as core. -- *atp_medias* ``list``: The collection of media whose gapfilling requirements to produce ATP will be examined. -- *max_gapfilling* ``float``: The maximal gapfilling score, where ``None`` defaults to the best score from gapfilling the provided media. -- *gapfilling_delta* ``int``: The allowable margin above the best gapfilling score that permits selection of a growth media. - -**Returns** *msatpobj* ``modelseedpy.core.msatpcorrection.MSATPCorrection``: The ``MSATPCorrection`` object that possesses the corrected model and all attributes of the correction process. +msatpcorrection +--------------------- + ++++++++++++++++++++++ +MSATPCorrection ++++++++++++++++++++++ + +A class that corrects the ATP Hydrolysis reaction of a given model: + +.. code-block:: python + + msatp = MSATPCorrection(model, core_template, atp_medias, compartment="c0", max_gapfilling=None, gapfilling_delta=0, atp_hydrolysis_id=None) + +- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. +- *core_template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template that is used to correct the model. +- *atp_medias* ``modelseedpy.core.msmedia.MSMedia``: The media that is associated with the growth phenotype. +- *compartment* ``str``: The compartment in which ATP will be added. +- *max_gapfilling* ``float``: The greatest extent of gapfilling for respective model. +- *gapfilling_delta* ``int``: The allowable margin above the best gapfilling score that permits selection of a growth media. +- *atp_hydrolysis_id* ``str``: The ID of the ATP Hydrolysis reaction, where ``None`` specifies a SEED reaction search. + +------------------------------ +atp_correction() +------------------------------ + +``staticMethod`` Restores the bounds on all noncore reactions: + +.. code-block:: python + + msatpobj = msatp.run_atp_correction(model, coretemplate, atp_medias = None, max_gapfilling = None, gapfilling_delta = 0) + +- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. +- *coretemplate* ``modelseedpy.core.mstemplate.MSTemplate``: The template that consists of the reactions that be used to assess which reactions in the model are categorized as core. +- *atp_medias* ``list``: The collection of media whose gapfilling requirements to produce ATP will be examined. +- *max_gapfilling* ``float``: The maximal gapfilling score, where ``None`` defaults to the best score from gapfilling the provided media. +- *gapfilling_delta* ``int``: The allowable margin above the best gapfilling score that permits selection of a growth media. + +**Returns** *msatpobj* ``modelseedpy.core.msatpcorrection.MSATPCorrection``: The ``MSATPCorrection`` object that possesses the corrected model and all attributes of the correction process. diff --git a/docs/source/core/msbuilder_api.rst b/docs/source/core/msbuilder_api.rst index 715fa198..8f4fae09 100644 --- a/docs/source/core/msbuilder_api.rst +++ b/docs/source/core/msbuilder_api.rst @@ -1,174 +1,174 @@ -msbuilder ------------- - -+++++++++++++++++++++ -MSBuilder -+++++++++++++++++++++ - -A class that constructs COBRA metabolic models from genomes and model templates: - -.. code-block:: python - - new_model = MSBuilder(genome, template=None) - -- *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome that will form the COBRA model. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will construct the COBRA model. - ------------------------------------- -get_gpr_from_template_reaction() ------------------------------------- - -Returns the collection of genes for all roles of all complexes from the template reaction: - -.. code-block:: python - - gpr_dict = new_model.get_gpr_from_template_reaction(template_reaction, allow_incomplete_complexes=True) - -- *template_reaction* ``modelseedy.core.mstemplate.MSTemplateReaction``: The reaction whose GPR relationships will be discerned. -- *allow_incomplete_complexes* ``bool``: specifies whether the complexes will be built regardless of total complex determination. - -**Returns** *gpr_dict* ``dict``: The collection of genes (``values``) for all roles of all complexes (``keys``) of the parameterized reaction. - ------------------------------------- -build_exchanges() ------------------------------------- - -Constructs exchange reactions from model reactions whose metabolites exist in the extracellular compartment: - -.. code-block:: python - - reactions_exchanges = new_model.build_exchanges(model, extra_cell='e0') - -- *model* ``cobra.core.model.Model``: The COBRA model that will be expanded with exchange reactions. -- *extra_cell* ``str``: The compartment of the excellular solution. - -**Returns** *reactions_exchanges* ``list``: The collection of COBRA exchange reactions that were added to the model. - ----------------------- -build_biomasses() ----------------------- - -Constructs biomass reaction(s) for a model with a specified template: - -.. code-block:: python - - biomass_reactions = new_model.build_biomasses(model, template, index) - -- *model* ``cobra.core.model.Model``: The COBRA model that will be expanded with exchange reactions. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template within which the biomass reactions of the model will be constructed. -- *index* ``str``: The compartment index of the respective model. - -**Returns** *biomass_reactions* ``list``: The collection of biomass reactions that are created and added to the model. - ------------------------------------- -auto_select_template() ------------------------------------- - -Returns the predicted class of a genome per the ``knn_ACNP_RAST_filter`` filter ID: - -.. code-block:: python - - genome_class = new_model.auto_select_template() - -**Returns** *genome_class* ``Pickle prediction``: The genome class that is predicted for the model based upon its genome and a ``knn_ACNP_RAST_filter`` filter ID. - ------------------------------------- -build_metabolic_reactions() ------------------------------------- - -Returns the collection of reactions that are constructed from the gpr set for each reaction in the template: - -.. code-block:: python - - reactions = new_model.build_metabolic_reactions(index='0', allow_incomplete_complexes=True) - -- *index* ``str``: The compartment index of the respective model. -- *allow_incomplete_complexes* ``bool``: specifies whether the complexes will be built regardless of total complex determination. - -**Returns** *reactions* ``list``: The collection of formated template reactions that have associated gpr information. - ------------------------------------- -build_non_metabolite_reactions() ------------------------------------- - -Returns the collection of reactions that lack gpr information: - -.. code-block:: python - - reactions_no_gpr = new_model.build_non_metabolite_reactions(cobra_model, index='0', allow_all_non_grp_reactions=False) - -- *model* ``cobra.core.model.Model``: The COBRA model that will be expanded with exchange reactions. -- *index* ``str``: The compartment index of the respective model. - -**Returns** *reactions_no_gpr* ``list``: The collection of formated template reactions that lack associated gpr information. - ------------- -build() ------------- - -Constructs a COBRA model based upon the genome in the MSBuilder class and the provided model ID: - -.. code-block:: python - - model = new_model.build(model_id, index='0', annotate_with_rast=True) - -- *model_id* ``str``: The ID of the model that will be constructed. -- *index* ``str``: The compartment index of the respective model. -- *allow_all_non_grp_reactions* ``bool``: specifies whether non-metabolite reactions will be added to the model. -- *annotate_with_rast* ``bool``: specifies whether the genome will be ontologically annotated via RAST. - -**Returns** *cobra_model* ``cobra.core.model.Model``: The COBRA model that is generated from the provided genome and model ID. - ------------------------------------- -build_full_template_model() ------------------------------------- - -Constructs a COBRA model from a template: - -.. code-block:: python - - model = new_model.build_full_template_model(template, model_id=None, index='0') - -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will guide the model construction. -- *model_id* ``str``: The ID of the model that will be constructed. -- *index* ``str``: The compartment index of the respective model. - -**Returns** *cobra_model* ``cobra.core.model.Model``: The COBRA model that is generated from the provided template and model ID. - ------------------------------------- -build_metabolic_model() ------------------------------------- - -A concise function that develops a COBRA metabolic model from a genome and various specifications: - -.. code-block:: python - - model = new_model.build_full_template_model(model_id, genome, gapfill_media=None, template=None, index='0', - allow_all_non_grp_reactions=False, annotate_with_rast=True) - -- *model_id* ``str``: The ID of the model that will be constructed. -- *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome that will form the COBRA model. -- *gapfill_media* ``modelseedpy.core.msgapfill.MSGapfill``: The media that will be used to gapfill the model, where ``None`` specifies that the model will not be gapfilled. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will guide the model construction. -- *index* ``str``: The compartment index of the respective model. -- *allow_all_non_grp_reactions* ``bool``: specifies whether non-metabolite reactions will be added to the model. -- *annotate_with_rast* ``bool``: specifies whether the genome will be ontologically annotated via RAST. - -**Returns** *cobra_model* ``cobra.core.model.Model``: The COBRA model that is generated from the provided template and model ID. - --------------------- -gapfill_model() --------------------- - -A model is gapfilled for a target reaction, extracellular media, and model template: - -.. code-block:: python - - model = new_model.gapfill_model(original_mdl, target_reaction, template, media) - -- *original_mdl* ``cobra.core.model.Model``: The model that will be gapfilled. -- *target_reaction* ``str``: The ID of the reaction that will be defined as the objective during gapfilling. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will guide the model gapfilling. -- *media* ``modelseedpy.core.msgapfill.MSGapfill``: The media that will be used to gapfill the model. - -**Returns** *cobra_model* ``cobra.core.model.Model``: The gapfilled COBRA model. +msbuilder +------------ + ++++++++++++++++++++++ +MSBuilder ++++++++++++++++++++++ + +A class that constructs COBRA metabolic models from genomes and model templates: + +.. code-block:: python + + new_model = MSBuilder(genome, template=None) + +- *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome that will form the COBRA model. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will construct the COBRA model. + +------------------------------------ +get_gpr_from_template_reaction() +------------------------------------ + +Returns the collection of genes for all roles of all complexes from the template reaction: + +.. code-block:: python + + gpr_dict = new_model.get_gpr_from_template_reaction(template_reaction, allow_incomplete_complexes=True) + +- *template_reaction* ``modelseedy.core.mstemplate.MSTemplateReaction``: The reaction whose GPR relationships will be discerned. +- *allow_incomplete_complexes* ``bool``: specifies whether the complexes will be built regardless of total complex determination. + +**Returns** *gpr_dict* ``dict``: The collection of genes (``values``) for all roles of all complexes (``keys``) of the parameterized reaction. + +------------------------------------ +build_exchanges() +------------------------------------ + +Constructs exchange reactions from model reactions whose metabolites exist in the extracellular compartment: + +.. code-block:: python + + reactions_exchanges = new_model.build_exchanges(model, extra_cell='e0') + +- *model* ``cobra.core.model.Model``: The COBRA model that will be expanded with exchange reactions. +- *extra_cell* ``str``: The compartment of the excellular solution. + +**Returns** *reactions_exchanges* ``list``: The collection of COBRA exchange reactions that were added to the model. + +---------------------- +build_biomasses() +---------------------- + +Constructs biomass reaction(s) for a model with a specified template: + +.. code-block:: python + + biomass_reactions = new_model.build_biomasses(model, template, index) + +- *model* ``cobra.core.model.Model``: The COBRA model that will be expanded with exchange reactions. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template within which the biomass reactions of the model will be constructed. +- *index* ``str``: The compartment index of the respective model. + +**Returns** *biomass_reactions* ``list``: The collection of biomass reactions that are created and added to the model. + +------------------------------------ +auto_select_template() +------------------------------------ + +Returns the predicted class of a genome per the ``knn_ACNP_RAST_filter`` filter ID: + +.. code-block:: python + + genome_class = new_model.auto_select_template() + +**Returns** *genome_class* ``Pickle prediction``: The genome class that is predicted for the model based upon its genome and a ``knn_ACNP_RAST_filter`` filter ID. + +------------------------------------ +build_metabolic_reactions() +------------------------------------ + +Returns the collection of reactions that are constructed from the gpr set for each reaction in the template: + +.. code-block:: python + + reactions = new_model.build_metabolic_reactions(index='0', allow_incomplete_complexes=True) + +- *index* ``str``: The compartment index of the respective model. +- *allow_incomplete_complexes* ``bool``: specifies whether the complexes will be built regardless of total complex determination. + +**Returns** *reactions* ``list``: The collection of formated template reactions that have associated gpr information. + +------------------------------------ +build_non_metabolite_reactions() +------------------------------------ + +Returns the collection of reactions that lack gpr information: + +.. code-block:: python + + reactions_no_gpr = new_model.build_non_metabolite_reactions(cobra_model, index='0', allow_all_non_grp_reactions=False) + +- *model* ``cobra.core.model.Model``: The COBRA model that will be expanded with exchange reactions. +- *index* ``str``: The compartment index of the respective model. + +**Returns** *reactions_no_gpr* ``list``: The collection of formated template reactions that lack associated gpr information. + +------------ +build() +------------ + +Constructs a COBRA model based upon the genome in the MSBuilder class and the provided model ID: + +.. code-block:: python + + model = new_model.build(model_id, index='0', annotate_with_rast=True) + +- *model_id* ``str``: The ID of the model that will be constructed. +- *index* ``str``: The compartment index of the respective model. +- *allow_all_non_grp_reactions* ``bool``: specifies whether non-metabolite reactions will be added to the model. +- *annotate_with_rast* ``bool``: specifies whether the genome will be ontologically annotated via RAST. + +**Returns** *cobra_model* ``cobra.core.model.Model``: The COBRA model that is generated from the provided genome and model ID. + +------------------------------------ +build_full_template_model() +------------------------------------ + +Constructs a COBRA model from a template: + +.. code-block:: python + + model = new_model.build_full_template_model(template, model_id=None, index='0') + +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will guide the model construction. +- *model_id* ``str``: The ID of the model that will be constructed. +- *index* ``str``: The compartment index of the respective model. + +**Returns** *cobra_model* ``cobra.core.model.Model``: The COBRA model that is generated from the provided template and model ID. + +------------------------------------ +build_metabolic_model() +------------------------------------ + +A concise function that develops a COBRA metabolic model from a genome and various specifications: + +.. code-block:: python + + model = new_model.build_full_template_model(model_id, genome, gapfill_media=None, template=None, index='0', + allow_all_non_grp_reactions=False, annotate_with_rast=True) + +- *model_id* ``str``: The ID of the model that will be constructed. +- *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome that will form the COBRA model. +- *gapfill_media* ``modelseedpy.core.msgapfill.MSGapfill``: The media that will be used to gapfill the model, where ``None`` specifies that the model will not be gapfilled. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will guide the model construction. +- *index* ``str``: The compartment index of the respective model. +- *allow_all_non_grp_reactions* ``bool``: specifies whether non-metabolite reactions will be added to the model. +- *annotate_with_rast* ``bool``: specifies whether the genome will be ontologically annotated via RAST. + +**Returns** *cobra_model* ``cobra.core.model.Model``: The COBRA model that is generated from the provided template and model ID. + +-------------------- +gapfill_model() +-------------------- + +A model is gapfilled for a target reaction, extracellular media, and model template: + +.. code-block:: python + + model = new_model.gapfill_model(original_mdl, target_reaction, template, media) + +- *original_mdl* ``cobra.core.model.Model``: The model that will be gapfilled. +- *target_reaction* ``str``: The ID of the reaction that will be defined as the objective during gapfilling. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template that will guide the model gapfilling. +- *media* ``modelseedpy.core.msgapfill.MSGapfill``: The media that will be used to gapfill the model. + +**Returns** *cobra_model* ``cobra.core.model.Model``: The gapfilled COBRA model. diff --git a/docs/source/core/mseditorapi_api.rst b/docs/source/core/mseditorapi_api.rst index 72a7d173..7ebf0942 100644 --- a/docs/source/core/mseditorapi_api.rst +++ b/docs/source/core/mseditorapi_api.rst @@ -1,151 +1,151 @@ -mseditor ------------- - -+++++++++++++++++++++ -MSEditorAPI -+++++++++++++++++++++ - -A class of static methods that offer various editing features - ------------------------------------- -remove_reactions() ------------------------------------- - -``staticMethod`` Removes a list of reactions from a model: - -.. code-block:: python - - MSEditorAPI.remove_reactions(model, rxn_id_list = []) - -- *model* ``core.core.model.Model``: The model that will be edited by removing a reaction. -- *rxn_id_list* ``list``: The IDs of all reaction that will be removed from the model. - ----------------------- -edit_reaction() ----------------------- - -``staticMethod`` Defines genome features from a FASTA file: - -.. code-block:: python - - MSEditorAPI.edit_reaction(model, rxn_id, direction=None, gpr=None) - -- *model* ``core.core.model.Model``: The model that will be edited by removing a reaction. -- *rxn_id* ``str``: The ID of the reaction that will be edited. -- *direction* ``str``: The "=>", "<=", or "<=>" reaction direction that represents thermodynamic favorability. -- *gpr* ``str``: The reaction GPR that will be set in the COBRA model. - ------------------------------------- -edit_biomass_compound() ------------------------------------- - -``staticMethod`` Adds a compound to the biomass reaction, or creates a biomass reaction with the compound where a biomass reaction is not defined: - -.. code-block:: python - - MSEditorAPI.edit_biomass_compound(model,biomass_id,cpd_id,new_coef) - -- *model* ``core.core.model.Model``: The model whose biomass reaction will be edited. -- *biomass_id* & *cpd_id* ``str``: The IDs of the biomass reaction and the compound that will be added to the biomass reaction. -- *new_coef* ``float``: The stoichiometric coefficient of the added compound to the biomass reaction. - ---------------------------- -compute_molecular_weight() ---------------------------- - -``staticMethod`` Returns the molecular weight of a model metabolite: - -.. code-block:: python - - met_mw = MSEditorAPI.compute_molecular_weight(model, metabolite_id) - -- *model* ``core.core.model.Model``: The model that contains the metabolite and thus the molecular formula. -- *metabolite_id* ``str``: The ID of the metabolite whose MW will be calculated. - -**Returns** *met_mw* ``float``: The MW of the metabolite. - ------------------------- -add_custom_reaction() ------------------------- - -``staticMethod`` Adds a reaction to the model with the parameterized characteristics: - -.. code-block:: python - - MSEditorAPI.add_custom_reaction(model,rxn_id,MSEquation,gpr = None) - -- *model* ``core.core.model.Model``: The model that will be expanded with the reaction. -- *rxn_id* ``str``: The ID of the reaction that will be added to the model. -- *MSEquation* ``modelseedpy.core.mseditorapi.msequation``: The ModelSEED reaction object that contains both the stoichiometry and direction. -- *gpr* ``str``: The reaction GPR that will be set in the COBRA model. - ------------------------- -add_ms_reaction() ------------------------- - -``staticMethod`` Adds a reaction with ModelSEED parameters to a model: - -.. code-block:: python - - MSEditorAPI.add_ms_reaction(model, rxn_id, modelseed, compartment_equivalents = {'0':'c0', '1':'e0'}, direction = '>') - -- *model* ``core.core.model.Model``: The model that will be expanded with the reaction. -- *rxn_id* ``str``: The ID of the reaction that will be added to the model. -- *modelseed* ``ModelSEED Database``: The ModelSEED Database object that will be used to acquire reaction information. -- *compartment_equivalents* ``dict``: The compartments and their indicies that are used in the reaction. -- *direction* ``str``: The "<", "=", or ">" direction of the reaction. - ------------------------- -copy_model_reactions() ------------------------- - -``staticMethod`` Adds specified reactions from a source model to a second model: - -.. code-block:: python - - MSEditorAPI.copy_model_reactions(model,source_model,rxn_id_list = []) - -- *model* ``core.core.model.Model``: The model that will be expanded with additional reactions. -- *source_model* ``core.core.model.Model``: The model whose reactions will be added to the ``model``. -- *rxn_id_list* ``list``: The list of reactions that may be potentially added, provided that they are in the ``source_model``. - ------------------------------ -copy_all_model_reactions() ------------------------------ - -``staticMethod`` Adds all new reactions from a source model to a second model: - -.. code-block:: python - - MSEditorAPI.copy_model_reactions(model,source_model) - -- *model* ``core.core.model.Model``: The model that will be expanded with all new reactions. -- *source_model* ``core.core.model.Model``: The model whose reactions will be added to the ``model``. - -+++++++++++++++++++++ -MSEquation -+++++++++++++++++++++ - -A class that constructs and organizes reaction information: - -.. code-block:: python - - mse = MSEquation(stoichiometry, direction) - -- *stoichiometry* ``dict``: The collection of stoichiometry (``values``) for all metabolites in the reaction (``keys``). -- *direction* ``str``: The "<", "=", or ">" reaction directionality. - ------------------------------------- -build_from_palsson_string() ------------------------------------- - -``staticMethod`` Parses a BiGG-formatted reaction string into an amenable form for ModelSEEDpy: - -.. code-block:: python - - reaction_object = MSEquation.build_from_palsson_string(equation_string, default_group='c') - -- *equation_string* ``str``: The BiGG reaction string. -- *default_group* ``str``: The reactant identifier. - -**Returns** *reaction_object* ``modelseedpy.core.mseditorapi.MSEquation``: The ``MSEquation`` object version of a BiGG reaction. +mseditor +------------ + ++++++++++++++++++++++ +MSEditorAPI ++++++++++++++++++++++ + +A class of static methods that offer various editing features + +------------------------------------ +remove_reactions() +------------------------------------ + +``staticMethod`` Removes a list of reactions from a model: + +.. code-block:: python + + MSEditorAPI.remove_reactions(model, rxn_id_list = []) + +- *model* ``core.core.model.Model``: The model that will be edited by removing a reaction. +- *rxn_id_list* ``list``: The IDs of all reaction that will be removed from the model. + +---------------------- +edit_reaction() +---------------------- + +``staticMethod`` Defines genome features from a FASTA file: + +.. code-block:: python + + MSEditorAPI.edit_reaction(model, rxn_id, direction=None, gpr=None) + +- *model* ``core.core.model.Model``: The model that will be edited by removing a reaction. +- *rxn_id* ``str``: The ID of the reaction that will be edited. +- *direction* ``str``: The "=>", "<=", or "<=>" reaction direction that represents thermodynamic favorability. +- *gpr* ``str``: The reaction GPR that will be set in the COBRA model. + +------------------------------------ +edit_biomass_compound() +------------------------------------ + +``staticMethod`` Adds a compound to the biomass reaction, or creates a biomass reaction with the compound where a biomass reaction is not defined: + +.. code-block:: python + + MSEditorAPI.edit_biomass_compound(model,biomass_id,cpd_id,new_coef) + +- *model* ``core.core.model.Model``: The model whose biomass reaction will be edited. +- *biomass_id* & *cpd_id* ``str``: The IDs of the biomass reaction and the compound that will be added to the biomass reaction. +- *new_coef* ``float``: The stoichiometric coefficient of the added compound to the biomass reaction. + +--------------------------- +compute_molecular_weight() +--------------------------- + +``staticMethod`` Returns the molecular weight of a model metabolite: + +.. code-block:: python + + met_mw = MSEditorAPI.compute_molecular_weight(model, metabolite_id) + +- *model* ``core.core.model.Model``: The model that contains the metabolite and thus the molecular formula. +- *metabolite_id* ``str``: The ID of the metabolite whose MW will be calculated. + +**Returns** *met_mw* ``float``: The MW of the metabolite. + +------------------------ +add_custom_reaction() +------------------------ + +``staticMethod`` Adds a reaction to the model with the parameterized characteristics: + +.. code-block:: python + + MSEditorAPI.add_custom_reaction(model,rxn_id,MSEquation,gpr = None) + +- *model* ``core.core.model.Model``: The model that will be expanded with the reaction. +- *rxn_id* ``str``: The ID of the reaction that will be added to the model. +- *MSEquation* ``modelseedpy.core.mseditorapi.msequation``: The ModelSEED reaction object that contains both the stoichiometry and direction. +- *gpr* ``str``: The reaction GPR that will be set in the COBRA model. + +------------------------ +add_ms_reaction() +------------------------ + +``staticMethod`` Adds a reaction with ModelSEED parameters to a model: + +.. code-block:: python + + MSEditorAPI.add_ms_reaction(model, rxn_id, modelseed, compartment_equivalents = {'0':'c0', '1':'e0'}, direction = '>') + +- *model* ``core.core.model.Model``: The model that will be expanded with the reaction. +- *rxn_id* ``str``: The ID of the reaction that will be added to the model. +- *modelseed* ``ModelSEED Database``: The ModelSEED Database object that will be used to acquire reaction information. +- *compartment_equivalents* ``dict``: The compartments and their indicies that are used in the reaction. +- *direction* ``str``: The "<", "=", or ">" direction of the reaction. + +------------------------ +copy_model_reactions() +------------------------ + +``staticMethod`` Adds specified reactions from a source model to a second model: + +.. code-block:: python + + MSEditorAPI.copy_model_reactions(model,source_model,rxn_id_list = []) + +- *model* ``core.core.model.Model``: The model that will be expanded with additional reactions. +- *source_model* ``core.core.model.Model``: The model whose reactions will be added to the ``model``. +- *rxn_id_list* ``list``: The list of reactions that may be potentially added, provided that they are in the ``source_model``. + +----------------------------- +copy_all_model_reactions() +----------------------------- + +``staticMethod`` Adds all new reactions from a source model to a second model: + +.. code-block:: python + + MSEditorAPI.copy_model_reactions(model,source_model) + +- *model* ``core.core.model.Model``: The model that will be expanded with all new reactions. +- *source_model* ``core.core.model.Model``: The model whose reactions will be added to the ``model``. + ++++++++++++++++++++++ +MSEquation ++++++++++++++++++++++ + +A class that constructs and organizes reaction information: + +.. code-block:: python + + mse = MSEquation(stoichiometry, direction) + +- *stoichiometry* ``dict``: The collection of stoichiometry (``values``) for all metabolites in the reaction (``keys``). +- *direction* ``str``: The "<", "=", or ">" reaction directionality. + +------------------------------------ +build_from_palsson_string() +------------------------------------ + +``staticMethod`` Parses a BiGG-formatted reaction string into an amenable form for ModelSEEDpy: + +.. code-block:: python + + reaction_object = MSEquation.build_from_palsson_string(equation_string, default_group='c') + +- *equation_string* ``str``: The BiGG reaction string. +- *default_group* ``str``: The reactant identifier. + +**Returns** *reaction_object* ``modelseedpy.core.mseditorapi.MSEquation``: The ``MSEquation`` object version of a BiGG reaction. diff --git a/docs/source/core/msgapfill_api.rst b/docs/source/core/msgapfill_api.rst index e9e58ff3..afdd6de3 100644 --- a/docs/source/core/msgapfill_api.rst +++ b/docs/source/core/msgapfill_api.rst @@ -1,74 +1,74 @@ -msgapfill ---------------------- - -+++++++++++++++++++++ -MSGapfill -+++++++++++++++++++++ - -A class that gapfills a given model: - -.. code-block:: python - - msgap = MSGapfill(model, default_gapfill_templates=[], default_gapfill_models=[], test_conditions=[], reaction_scores={}, blacklist=[]) - -- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. -- *default_gapfill_templates* & *default_gapfill_models* ``list``: The collection of ``modelseedpy.core.mstemplate.MSTemplate`` templates and ``cobra.core.model.Model`` models, respectively, whose gapfilling penalties will be determined and updated during gapfilling. -- *test_conditions* ``list``: The collection of conditions in which the model is examined for feasibility. -- *reaction_scores* ``dict``: The collection of reaction scores (``values``) for all genes of each core reaction ID (``keys``). -- *blacklist* ``list``: The collection of reaction IDs that will not be included while gapfilling. - ------------------------------- -run_gapfilling() ------------------------------- - -Executes gapfilling for the specified model: - -.. code-block:: python - - check_solution = msgap.run_gapfilling(media=None, target=None, minimum_obj=0.01, binary_check=True, solver = 'optland-cplex') - solution = msgap.run_gapfilling(media=None, target=None, minimum_obj=0.01, binary_check=False, solver = 'optland-cplex') - -- *media* ``modelseedpy.core.msmedia.MSMedia``: The media in which gapfilling will occur. -- *target* ``str``: The ID of the reaction that will be set as the gapfilling objective. -- *minimum_obj* ``float``: The minimum tolerable objective value, which is constrained as the lower bound of the objective function. -- *binary_check* ``bool``: specifies whether the reaction directions for all gapfilled reactions will be returned. -- *solver* ``str``: The ID specification of the linear programming solver that is used during optimization. - -**Returns** *check_solution* ``dict``: The collection of "<" or ">" directions for all reversed reactions in the model that are described with gapfilling penalties. - -**Returns** *solution* ``cobra.core.solution.Solution``: The COBRA optimization solution. - ------------------------------- -integrate_gapfill_solution() ------------------------------- - -Embeds a gapfilling solution into a model: - -.. code-block:: python - - new_model = msgap.run_gapfilling(solution) - -- *solution* ``cobra.core.solution.Solution``: The optimization solution that will be embedded in the model within the ``MSGapfill`` object. - -**Returns** *new_model* ``cobra.core.model.Model``: The COBRA model that is updated with the gapfilling optimization solution. - - ------------------------------- -gapfill() ------------------------------- - -``staticMethod`` Executes gapfilling of the specified : - -.. code-block:: python - - new_model = MSGapfill.gapfill(model, media=None, target_reaction="bio1", default_gapfill_templates=[], default_gapfill_models=[], test_conditions=[], reaction_scores={}, blacklist=[]) - -- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. -- *media* ``modelseedpy.core.msmedia.MSMedia``: The media in which gapfilling will occur. -- *target_reaction* ``str``: The ID of the reaction that will be set as the gapfilling objective. -- *default_gapfill_templates* & *default_gapfill_models* ``list``: The collection of ``modelseedpy.core.mstemplate.MSTemplate`` templates and ``cobra.core.model.Model`` models, respectively, whose gapfilling penalties will be determined and updated during gapfilling. -- *test_conditions* ``list``: The collection of conditions in which the model is examined for feasibility. -- *reaction_scores* ``dict``: The collection of reaction scores (``values``) for all genes of each core reaction ID (``keys``). -- *blacklist* ``list``: The collection of reaction IDs that will not be included while gapfilling. - -**Returns** *new_model* ``cobra.core.model.Model``: The COBRA model that is updated with the gapfilling optimization solution. +msgapfill +--------------------- + ++++++++++++++++++++++ +MSGapfill ++++++++++++++++++++++ + +A class that gapfills a given model: + +.. code-block:: python + + msgap = MSGapfill(model, default_gapfill_templates=[], default_gapfill_models=[], test_conditions=[], reaction_scores={}, blacklist=[]) + +- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. +- *default_gapfill_templates* & *default_gapfill_models* ``list``: The collection of ``modelseedpy.core.mstemplate.MSTemplate`` templates and ``cobra.core.model.Model`` models, respectively, whose gapfilling penalties will be determined and updated during gapfilling. +- *test_conditions* ``list``: The collection of conditions in which the model is examined for feasibility. +- *reaction_scores* ``dict``: The collection of reaction scores (``values``) for all genes of each core reaction ID (``keys``). +- *blacklist* ``list``: The collection of reaction IDs that will not be included while gapfilling. + +------------------------------ +run_gapfilling() +------------------------------ + +Executes gapfilling for the specified model: + +.. code-block:: python + + check_solution = msgap.run_gapfilling(media=None, target=None, minimum_obj=0.01, binary_check=True, solver = 'optland-cplex') + solution = msgap.run_gapfilling(media=None, target=None, minimum_obj=0.01, binary_check=False, solver = 'optland-cplex') + +- *media* ``modelseedpy.core.msmedia.MSMedia``: The media in which gapfilling will occur. +- *target* ``str``: The ID of the reaction that will be set as the gapfilling objective. +- *minimum_obj* ``float``: The minimum tolerable objective value, which is constrained as the lower bound of the objective function. +- *binary_check* ``bool``: specifies whether the reaction directions for all gapfilled reactions will be returned. +- *solver* ``str``: The ID specification of the linear programming solver that is used during optimization. + +**Returns** *check_solution* ``dict``: The collection of "<" or ">" directions for all reversed reactions in the model that are described with gapfilling penalties. + +**Returns** *solution* ``cobra.core.solution.Solution``: The COBRA optimization solution. + +------------------------------ +integrate_gapfill_solution() +------------------------------ + +Embeds a gapfilling solution into a model: + +.. code-block:: python + + new_model = msgap.run_gapfilling(solution) + +- *solution* ``cobra.core.solution.Solution``: The optimization solution that will be embedded in the model within the ``MSGapfill`` object. + +**Returns** *new_model* ``cobra.core.model.Model``: The COBRA model that is updated with the gapfilling optimization solution. + + +------------------------------ +gapfill() +------------------------------ + +``staticMethod`` Executes gapfilling of the specified : + +.. code-block:: python + + new_model = MSGapfill.gapfill(model, media=None, target_reaction="bio1", default_gapfill_templates=[], default_gapfill_models=[], test_conditions=[], reaction_scores={}, blacklist=[]) + +- *model* ``cobra.core.model.Model``: The model whose ATP Hydrolysis reaction will be corrected. +- *media* ``modelseedpy.core.msmedia.MSMedia``: The media in which gapfilling will occur. +- *target_reaction* ``str``: The ID of the reaction that will be set as the gapfilling objective. +- *default_gapfill_templates* & *default_gapfill_models* ``list``: The collection of ``modelseedpy.core.mstemplate.MSTemplate`` templates and ``cobra.core.model.Model`` models, respectively, whose gapfilling penalties will be determined and updated during gapfilling. +- *test_conditions* ``list``: The collection of conditions in which the model is examined for feasibility. +- *reaction_scores* ``dict``: The collection of reaction scores (``values``) for all genes of each core reaction ID (``keys``). +- *blacklist* ``list``: The collection of reaction IDs that will not be included while gapfilling. + +**Returns** *new_model* ``cobra.core.model.Model``: The COBRA model that is updated with the gapfilling optimization solution. diff --git a/docs/source/core/msgenome_api.rst b/docs/source/core/msgenome_api.rst index 4f2be8cf..832d491e 100644 --- a/docs/source/core/msgenome_api.rst +++ b/docs/source/core/msgenome_api.rst @@ -1,93 +1,93 @@ -msgenome ------------- - -+++++++++++++++++++++ -MSFeature -+++++++++++++++++++++ - -A class that defines attributes of a genome feature: - -.. code-block:: python - - msfeat = MSFeature(feature_id, sequence, description=None) - -- *feature_id*, *sequence*, & *description* ``str``: The ID, sequence, and description of the genome feature. - ------------------------------------- -add_ontology_term() ------------------------------------- - -Returns the collection of genes for all roles of all complexes from the template reaction: - -.. code-block:: python - - msfeat.add_ontology_term(ontology_term, value) - -- *ontology_term* ``str``: The ontological term that will be added to the dictionary of ontological terms. -- *value* ``str``: The sequence that corresponds to the ontological term. - -+++++++++++++++++++++ -MSGenome -+++++++++++++++++++++ - -A class that edits and parses a genome: - -.. code-block:: python - - msgen = MSGenome() - ----------------------- -from_fasta() ----------------------- - -``staticMethod`` Defines genome features from a FASTA file: - -.. code-block:: python - - genome = msgen.from_fasta(filename, split='|', h_func=None) - -- *filename* ``str``: The name of the FASTA file that will be parsed and populated in the genome features. -- *split* ``str``: The delimiter that separates the sequence ID from the sequence description. -- *h_func* ``function``: A custom function that parses the file line of a FASTA file into its sequence ID and descriptoin. - -**Returns** *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome whose features have been parsed from a fasta file. - ------------------------------------- -from_protein_sequences_hash() ------------------------------------- - -``staticMethod`` Defines genome features from a dictionary of protein sequences: - -.. code-block:: python - - genome_class = msgen.from_protein_sequences_hash(sequences) - -- *sequences* ``dict``: Protein sequences (``values``) for various sequence IDs (``keys``) that will be added to the genome features. - -**Returns** *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome whose features have been parsed from a fasta file. - -------------------- -alias_hash() -------------------- - -Returns the gene for each alias in each gene of the features: - -.. code-block:: python - - alias_hash = msgen.alias_hash() - -**Returns** *alias_hash* ``dict``: The collection of all alias-gene (``key``:``value``) pairs for each gene in the genome features. - -------------------- -search_for_gene() -------------------- - -Returns the sought gene based upon a query term of features or aliases: - -.. code-block:: python - - gene = msgen.search_for_gene(query) - -- *query* ``str``: The search term of a feature ID or gene alias. - -**Returns** *gene* ``modelseedpy.core.msgenome.MSGenome``: The gene that matches the search term, where ``None`` signifies that no match was discerned. +msgenome +------------ + ++++++++++++++++++++++ +MSFeature ++++++++++++++++++++++ + +A class that defines attributes of a genome feature: + +.. code-block:: python + + msfeat = MSFeature(feature_id, sequence, description=None) + +- *feature_id*, *sequence*, & *description* ``str``: The ID, sequence, and description of the genome feature. + +------------------------------------ +add_ontology_term() +------------------------------------ + +Returns the collection of genes for all roles of all complexes from the template reaction: + +.. code-block:: python + + msfeat.add_ontology_term(ontology_term, value) + +- *ontology_term* ``str``: The ontological term that will be added to the dictionary of ontological terms. +- *value* ``str``: The sequence that corresponds to the ontological term. + ++++++++++++++++++++++ +MSGenome ++++++++++++++++++++++ + +A class that edits and parses a genome: + +.. code-block:: python + + msgen = MSGenome() + +---------------------- +from_fasta() +---------------------- + +``staticMethod`` Defines genome features from a FASTA file: + +.. code-block:: python + + genome = msgen.from_fasta(filename, split='|', h_func=None) + +- *filename* ``str``: The name of the FASTA file that will be parsed and populated in the genome features. +- *split* ``str``: The delimiter that separates the sequence ID from the sequence description. +- *h_func* ``function``: A custom function that parses the file line of a FASTA file into its sequence ID and descriptoin. + +**Returns** *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome whose features have been parsed from a fasta file. + +------------------------------------ +from_protein_sequences_hash() +------------------------------------ + +``staticMethod`` Defines genome features from a dictionary of protein sequences: + +.. code-block:: python + + genome_class = msgen.from_protein_sequences_hash(sequences) + +- *sequences* ``dict``: Protein sequences (``values``) for various sequence IDs (``keys``) that will be added to the genome features. + +**Returns** *genome* ``modelseedpy.core.msgenome.MSGenome``: The genome whose features have been parsed from a fasta file. + +------------------- +alias_hash() +------------------- + +Returns the gene for each alias in each gene of the features: + +.. code-block:: python + + alias_hash = msgen.alias_hash() + +**Returns** *alias_hash* ``dict``: The collection of all alias-gene (``key``:``value``) pairs for each gene in the genome features. + +------------------- +search_for_gene() +------------------- + +Returns the sought gene based upon a query term of features or aliases: + +.. code-block:: python + + gene = msgen.search_for_gene(query) + +- *query* ``str``: The search term of a feature ID or gene alias. + +**Returns** *gene* ``modelseedpy.core.msgenome.MSGenome``: The gene that matches the search term, where ``None`` signifies that no match was discerned. diff --git a/docs/source/core/msgenomeclassifier_api.rst b/docs/source/core/msgenomeclassifier_api.rst index 59b44642..ca4f8073 100644 --- a/docs/source/core/msgenomeclassifier_api.rst +++ b/docs/source/core/msgenomeclassifier_api.rst @@ -1,61 +1,61 @@ -msgenomeclassifier --------------------------------------- - -------------------------------------------- -load_classifier_from_folder() -------------------------------------------- - -A function that loads the model and model features from a local folder: - -.. code-block:: python - - media = load_classifier_from_folder(directory, filename) - -- *directory* ``str``: The directory in which the model and features files are provided. -- *filename* ``str``: The basename of the file, where the model file is named ````.pickle and the features file is named ````\_features.json. - -**returns** *msgenclass* ``modelseedpy.core.msgenomeclassifier.MSGenomeClassifier``: The MSGenomeClassifier object of the respective model and model features. - -+++++++++++++++++++++ -MSGenomeClassifier() -+++++++++++++++++++++ - -This class classifies a model and its features: - -.. code-block:: python - - from modelseedpy.core import MSGenomeClassifier - genclass = MSGenomeClassifier(model, model_features) - -- *model* ``cobra.core.model.Model``: The CobraKBase model whose genome will be classified. -- *model_features* ``dict``: A descriptive dictionary of the investigated model. - -------------------------------------------- -extract_features_from_genome() -------------------------------------------- - -A function that assembles a unique list of features for the specified genome: - -.. code-block:: python - - genome_features = genclass.extract_features_from_genome(genome, ontology_term) - -- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. -- *ontology_term* ``str``: The ontological criteria that will assess the genome. - -**returns** *genome_features* ``dict``: A list of genome features ``value`` with the key of ``"genome"``. - ------------------- -classify() ------------------- - -A function that predicts FBA solutions based upon a set of genome features and indicators: - -.. code-block:: python - - media = genclass.classify(genome, ontology_term='RAST') - -- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. -- *ontology_term* ``str``: The ontological criteria that will assess the genome. - -**returns** *prediction* ``str``: The numerical prediction of the model based upon the set of genome features and indicators. +msgenomeclassifier +-------------------------------------- + +------------------------------------------- +load_classifier_from_folder() +------------------------------------------- + +A function that loads the model and model features from a local folder: + +.. code-block:: python + + media = load_classifier_from_folder(directory, filename) + +- *directory* ``str``: The directory in which the model and features files are provided. +- *filename* ``str``: The basename of the file, where the model file is named ````.pickle and the features file is named ````\_features.json. + +**returns** *msgenclass* ``modelseedpy.core.msgenomeclassifier.MSGenomeClassifier``: The MSGenomeClassifier object of the respective model and model features. + ++++++++++++++++++++++ +MSGenomeClassifier() ++++++++++++++++++++++ + +This class classifies a model and its features: + +.. code-block:: python + + from modelseedpy.core import MSGenomeClassifier + genclass = MSGenomeClassifier(model, model_features) + +- *model* ``cobra.core.model.Model``: The CobraKBase model whose genome will be classified. +- *model_features* ``dict``: A descriptive dictionary of the investigated model. + +------------------------------------------- +extract_features_from_genome() +------------------------------------------- + +A function that assembles a unique list of features for the specified genome: + +.. code-block:: python + + genome_features = genclass.extract_features_from_genome(genome, ontology_term) + +- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. +- *ontology_term* ``str``: The ontological criteria that will assess the genome. + +**returns** *genome_features* ``dict``: A list of genome features ``value`` with the key of ``"genome"``. + +------------------ +classify() +------------------ + +A function that predicts FBA solutions based upon a set of genome features and indicators: + +.. code-block:: python + + media = genclass.classify(genome, ontology_term='RAST') + +- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. +- *ontology_term* ``str``: The ontological criteria that will assess the genome. + +**returns** *prediction* ``str``: The numerical prediction of the model based upon the set of genome features and indicators. diff --git a/docs/source/core/msgrowthphenotypes_api.rst b/docs/source/core/msgrowthphenotypes_api.rst index 04698c49..03ed555a 100644 --- a/docs/source/core/msgrowthphenotypes_api.rst +++ b/docs/source/core/msgrowthphenotypes_api.rst @@ -1,172 +1,172 @@ -msgrowthphenotypes ---------------------- - -+++++++++++++++++++++ -MSGrowthPhenotype -+++++++++++++++++++++ - -A class that defines a growth phenotype and constructs media for the phenotype: - -.. code-block:: python - - mspheno = MSGrowthPhenotype(obj_id, media=None, growth=None, gene_ko=[], additional_compounds=[], parent=None, name=None) - -- *obj_id* & *name* ``str``: The ID and name of the growth phenotype. -- *media* ``modelseedpy.core.msmedia.MSMedia``: The media in which the phenotype will be simulated. -- *growth* ``float``: The objective value of the growth phenotype. -- *gene_ko* ``list``: The collection of genes that are knocked-out in association with this phenotype. -- *additional_compounds* ``list``: A collection of compounds that will construct a media through the ``build_media`` function. -- *parent* ``list``: The source of base media information, through the ``base_media``, ``base_uptake``, and ``base_excretion`` attributes. - ------------------------ -build_media() ------------------------ - -Returns a media that is constructed as the amalgamation of extant ``media`` and ``parent`` media and the ``additional_compounds``: - -.. code-block:: python - - media = mspheno.build_media() - -**Returns** *media* ``cobra.core.msmedia.MSMedia``: The media that is constituted from the ``additional_compounds`` and existing media in the ``media`` and ``parent`` attributes of the ``MSGrowthPhenotype`` object. - ---------------- -simulate() ---------------- - -Simulates the growht phenotype of a model that is defined within ``MSModelUtils`` object: - -.. code-block:: python - - results = mspheno.simulate(modelutl, growth_threshold=0.001, add_missing_exchanges=False, save_fluxes=False, pfba=False) - -- *modelutl* ``modelseedpy.core.msmodelutl.MSModelUtil``: A ``MSModelUtils`` object which possesses the model that will be manipulated and simulated. -- *growth_threshold* ``float``: The objective value threshold for the growth phenotype that is examined by this class. -- *add_missing_exchanges* ``bool``: specifies whether the missing exchange reactions will be added to the model. -- *save_fluxes* ``bool``: specifies whether the solution fluxes will be stored in the results dictionary. - -**Returns** *results* ``dict``: The organization of simulation results and intermediate values in key-value pairs, including whether the growth predictions were correct or false. - ---------------------------------- -gapfill_model_for_phenotype() ---------------------------------- - -Formats COBRA reactions and metabolites for ModelSEED operations, respectively: - -.. code-block:: python - - gpf_model = gfhelper.convert_modelreaction(modelutl, default_gapfill_templates, test_conditions, default_gapfill_models=[], blacklist=[], growth_threshold=0.001, add_missing_exchanges=False) - -- *modelutl* ``modelseedpy.core.msmodelutl.MSModelUtil``: A ``MSModelUtils`` object which possesses the model that will be gapfilled. -- *default_gapfill_templates* & *test_conditions* ``list``: A collection of gapfilling templates and test conditions that will be used to gapfill the model. -- *default_gapfill_models* ``list``: The collection of models that will extend ``modelutl.model`` for gapfilling. -- *blacklist* ``list``: The collection of reactions that will not be included during gapfilling. -- *growth_threshold* ``float``: The objective value threshold for the growth phenotype that is examined by this class. -- *add_missing_exchanges* ``bool``: specifies whether the missing exchange reactions will be added to the model. - -**Returns** *gpf_model* ``cobra.core.model.Model``: The gapfilled model. - -+++++++++++++++++++++ -MSGrowthPhenotypes -+++++++++++++++++++++ - -A class that defines a growth phenotype and combines phenotypes that are defined through ``MSGrowthPhenotype``: - -.. code-block:: python - - mspheno = MSGrowthPhenotype(base_media=None, base_uptake=0, base_excretion=1000) - -- *base_media* ``modelseedpy.core.msmedia.MSMedia``: The media that is associated with the growth phenotype. -- *base_uptake* & *base_excretion* ``int``: The uptake and excretion fluxes for the examined phenotype. - ------------------------ -from_compound_hash() ------------------------ - -``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from a dictionary that describes the compounds of the phenotype: - -.. code-block:: python - - growthpheno = MSGrowthPhenotypes.from_compound_hash(compounds, base_media, base_uptake=0, base_excretion=1000) - -- *compounds* ``list``: The collection of compounds that will comprise the growth phenotype. -- *base_media* ``str``: The media that is associated with the growth phenotype. -- *base_uptake* & *base_excretion* ``int``: The uptake and excretion fluxes for the examined phenotype. - -**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: A growth phenotype that is constructed from a dictionary that describes a compound. - --------------------------------------- -from_kbase_object() --------------------------------------- - -``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from KBase through the kbase API object: - -.. code-block:: python - - growthpheno = MSGrowthPhenotypes.from_compound_hash(data, kbase_api) - -- *data* ``dict``: The collection of phenotypes that will be defined and examined (``values``), under the ``phenotypes`` key. -- *kbase_api* ``KBase API``: The KBase API object that can acquire media information from a KBase reference from each phenotype. - -**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: The collective of growth phenotypes that are defined from the ``data`` dictionary. - --------------------------------------- -from_kbase_file() --------------------------------------- - -``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from a KBase TSV file: - -.. code-block:: python - - growthpheno = MSGrowthPhenotypes.from_kbase_file(filename, base_media, kbase_api) - -- *filename* ``str``: The name of the TSV file -- with a header of "media mediaws growth geneko addtlCpd" -- that will be parsed into a ``MSGrowthPhenotypes`` object. -- *base_media* ``str``: The media that is associated with the growth phenotype. -- *kbase_api* ``KBase API``: The KBase API object that can acquire media information from a KBase reference from each phenotype. - -**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: The collective of growth phenotypes that are defined from the ``data`` dictionary. - ----------------------- -from_ms_file() ----------------------- - -``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from a ModelSEED CSV file: - -.. code-block:: python - - growthpheno = MSGrowthPhenotypes.from_ms_file(filename, base_media, base_uptake=0, base_excretion=100) - -- *filename* ``str``: The name of the CSV file -- with a header of "media mediaws growth geneko addtlCpd" -- that will be parsed into a ``MSGrowthPhenotypes`` object. -- *base_media* ``str``: The media that is associated with the growth phenotype. -- *base_uptake* & *base_excretion* ``int``: The uptake and excretion fluxes for the examined phenotype. - -**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: The collective of growth phenotypes that are defined from the ``data`` dictionary. - --------------------- -add_phenotypes() --------------------- - -Constructs a metadata dictionary of a COBRA Reaction object that is returned and can be added to a KBase model: - -.. code-block:: python - - MSGrowthPhenotypes.add_phenotypes(new_phenotypes) - -- *new_phenotypes* ``list``: The collection of phenotypes that will be added to the ``MSGrowthPhenotypes`` object list of phenotypes. - ----------------------------- -simulate_phenotypes() ----------------------------- - -Coverts an old objective function into a variable and constructs a new constraint that the new objective must equate the old object. The variable and constraint are added to the ``cobramodel`` in the extant object: - -.. code-block:: python - - gfhelper.convert_objective_to_constraint(model, biomass, add_missing_exchanges=False, correct_false_negatives=False, template=None, growth_threshold=0.001) - -- *model* ``cobra.core.model.Model``: The model wqhose phenotypes will be simulated. -- *biomass* ``cobra.core.reaction.Reaction``: The biomass reaction which is set as the model objective. -- *add_missing_exchanges* ``bool``: specifies whether the missing exchange reactions will be added to the model. -- *correct_false_negatives* ``bool``: specifies whether false negatives from each phenotype simulation will be corrected. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template that is used to gapfill the model. -- *growth_threshold* ``float``: The objective value threshold for the growth phenotypes. +msgrowthphenotypes +--------------------- + ++++++++++++++++++++++ +MSGrowthPhenotype ++++++++++++++++++++++ + +A class that defines a growth phenotype and constructs media for the phenotype: + +.. code-block:: python + + mspheno = MSGrowthPhenotype(obj_id, media=None, growth=None, gene_ko=[], additional_compounds=[], parent=None, name=None) + +- *obj_id* & *name* ``str``: The ID and name of the growth phenotype. +- *media* ``modelseedpy.core.msmedia.MSMedia``: The media in which the phenotype will be simulated. +- *growth* ``float``: The objective value of the growth phenotype. +- *gene_ko* ``list``: The collection of genes that are knocked-out in association with this phenotype. +- *additional_compounds* ``list``: A collection of compounds that will construct a media through the ``build_media`` function. +- *parent* ``list``: The source of base media information, through the ``base_media``, ``base_uptake``, and ``base_excretion`` attributes. + +----------------------- +build_media() +----------------------- + +Returns a media that is constructed as the amalgamation of extant ``media`` and ``parent`` media and the ``additional_compounds``: + +.. code-block:: python + + media = mspheno.build_media() + +**Returns** *media* ``cobra.core.msmedia.MSMedia``: The media that is constituted from the ``additional_compounds`` and existing media in the ``media`` and ``parent`` attributes of the ``MSGrowthPhenotype`` object. + +--------------- +simulate() +--------------- + +Simulates the growht phenotype of a model that is defined within ``MSModelUtils`` object: + +.. code-block:: python + + results = mspheno.simulate(modelutl, growth_threshold=0.001, add_missing_exchanges=False, save_fluxes=False, pfba=False) + +- *modelutl* ``modelseedpy.core.msmodelutl.MSModelUtil``: A ``MSModelUtils`` object which possesses the model that will be manipulated and simulated. +- *growth_threshold* ``float``: The objective value threshold for the growth phenotype that is examined by this class. +- *add_missing_exchanges* ``bool``: specifies whether the missing exchange reactions will be added to the model. +- *save_fluxes* ``bool``: specifies whether the solution fluxes will be stored in the results dictionary. + +**Returns** *results* ``dict``: The organization of simulation results and intermediate values in key-value pairs, including whether the growth predictions were correct or false. + +--------------------------------- +gapfill_model_for_phenotype() +--------------------------------- + +Formats COBRA reactions and metabolites for ModelSEED operations, respectively: + +.. code-block:: python + + gpf_model = gfhelper.convert_modelreaction(modelutl, default_gapfill_templates, test_conditions, default_gapfill_models=[], blacklist=[], growth_threshold=0.001, add_missing_exchanges=False) + +- *modelutl* ``modelseedpy.core.msmodelutl.MSModelUtil``: A ``MSModelUtils`` object which possesses the model that will be gapfilled. +- *default_gapfill_templates* & *test_conditions* ``list``: A collection of gapfilling templates and test conditions that will be used to gapfill the model. +- *default_gapfill_models* ``list``: The collection of models that will extend ``modelutl.model`` for gapfilling. +- *blacklist* ``list``: The collection of reactions that will not be included during gapfilling. +- *growth_threshold* ``float``: The objective value threshold for the growth phenotype that is examined by this class. +- *add_missing_exchanges* ``bool``: specifies whether the missing exchange reactions will be added to the model. + +**Returns** *gpf_model* ``cobra.core.model.Model``: The gapfilled model. + ++++++++++++++++++++++ +MSGrowthPhenotypes ++++++++++++++++++++++ + +A class that defines a growth phenotype and combines phenotypes that are defined through ``MSGrowthPhenotype``: + +.. code-block:: python + + mspheno = MSGrowthPhenotype(base_media=None, base_uptake=0, base_excretion=1000) + +- *base_media* ``modelseedpy.core.msmedia.MSMedia``: The media that is associated with the growth phenotype. +- *base_uptake* & *base_excretion* ``int``: The uptake and excretion fluxes for the examined phenotype. + +----------------------- +from_compound_hash() +----------------------- + +``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from a dictionary that describes the compounds of the phenotype: + +.. code-block:: python + + growthpheno = MSGrowthPhenotypes.from_compound_hash(compounds, base_media, base_uptake=0, base_excretion=1000) + +- *compounds* ``list``: The collection of compounds that will comprise the growth phenotype. +- *base_media* ``str``: The media that is associated with the growth phenotype. +- *base_uptake* & *base_excretion* ``int``: The uptake and excretion fluxes for the examined phenotype. + +**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: A growth phenotype that is constructed from a dictionary that describes a compound. + +-------------------------------------- +from_kbase_object() +-------------------------------------- + +``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from KBase through the kbase API object: + +.. code-block:: python + + growthpheno = MSGrowthPhenotypes.from_compound_hash(data, kbase_api) + +- *data* ``dict``: The collection of phenotypes that will be defined and examined (``values``), under the ``phenotypes`` key. +- *kbase_api* ``KBase API``: The KBase API object that can acquire media information from a KBase reference from each phenotype. + +**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: The collective of growth phenotypes that are defined from the ``data`` dictionary. + +-------------------------------------- +from_kbase_file() +-------------------------------------- + +``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from a KBase TSV file: + +.. code-block:: python + + growthpheno = MSGrowthPhenotypes.from_kbase_file(filename, base_media, kbase_api) + +- *filename* ``str``: The name of the TSV file -- with a header of "media mediaws growth geneko addtlCpd" -- that will be parsed into a ``MSGrowthPhenotypes`` object. +- *base_media* ``str``: The media that is associated with the growth phenotype. +- *kbase_api* ``KBase API``: The KBase API object that can acquire media information from a KBase reference from each phenotype. + +**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: The collective of growth phenotypes that are defined from the ``data`` dictionary. + +---------------------- +from_ms_file() +---------------------- + +``staticMethod`` Returns a ``MSGrowthPhenotypes`` object that is constructed from a ModelSEED CSV file: + +.. code-block:: python + + growthpheno = MSGrowthPhenotypes.from_ms_file(filename, base_media, base_uptake=0, base_excretion=100) + +- *filename* ``str``: The name of the CSV file -- with a header of "media mediaws growth geneko addtlCpd" -- that will be parsed into a ``MSGrowthPhenotypes`` object. +- *base_media* ``str``: The media that is associated with the growth phenotype. +- *base_uptake* & *base_excretion* ``int``: The uptake and excretion fluxes for the examined phenotype. + +**Returns** *growthpheno* ``modelseedpy.core.msgrowthphenotypes.MSGrowthPhenotypes``: The collective of growth phenotypes that are defined from the ``data`` dictionary. + +-------------------- +add_phenotypes() +-------------------- + +Constructs a metadata dictionary of a COBRA Reaction object that is returned and can be added to a KBase model: + +.. code-block:: python + + MSGrowthPhenotypes.add_phenotypes(new_phenotypes) + +- *new_phenotypes* ``list``: The collection of phenotypes that will be added to the ``MSGrowthPhenotypes`` object list of phenotypes. + +---------------------------- +simulate_phenotypes() +---------------------------- + +Coverts an old objective function into a variable and constructs a new constraint that the new objective must equate the old object. The variable and constraint are added to the ``cobramodel`` in the extant object: + +.. code-block:: python + + gfhelper.convert_objective_to_constraint(model, biomass, add_missing_exchanges=False, correct_false_negatives=False, template=None, growth_threshold=0.001) + +- *model* ``cobra.core.model.Model``: The model wqhose phenotypes will be simulated. +- *biomass* ``cobra.core.reaction.Reaction``: The biomass reaction which is set as the model objective. +- *add_missing_exchanges* ``bool``: specifies whether the missing exchange reactions will be added to the model. +- *correct_false_negatives* ``bool``: specifies whether false negatives from each phenotype simulation will be corrected. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template that is used to gapfill the model. +- *growth_threshold* ``float``: The objective value threshold for the growth phenotypes. diff --git a/docs/source/core/msmedia_api.rst b/docs/source/core/msmedia_api.rst index 66b494a3..fac75083 100644 --- a/docs/source/core/msmedia_api.rst +++ b/docs/source/core/msmedia_api.rst @@ -1,70 +1,70 @@ -Media Packages --------------------------------------- - -+++++++++++++++++++++ -MediaCompound() -+++++++++++++++++++++ - -This class instantiates a media compound for potential manipulations: - -.. code-block:: python - - from modelseedpy.core import MediaCompound - media_comp = MediaCompound(compound_id, lower_bound, upper_bound, concentration=None) - -- *compound_id* ``str`` & *concentration* ``float``: The ID and concentration of the media compound. -- *lower_bound* & *upper_bound* ``float``: The lower and upper bounds of the exchange reaction for the media compound, respectively. - -+++++++++++++++++++++ -MSMedia() -+++++++++++++++++++++ - -This class instantiates a media for investigation: - -.. code-block:: python - - from modelseedpy.core import MSMedia - msmedia = MSMedia(media_id) - -- *media_id* ``str``: The ID of the investigated media. - -------------------------------------------- -from_dict() -------------------------------------------- - -A function that converts a media dictionary into a media object: - -.. code-block:: python - - media = msmedia.from_dict(media_dictionary) - -- *media_dictionary* ``dict``: A dictionary representation of the media that contains either a list of exchange bounds or the uptake magnitude (``value``) for each compound in the media. - -**returns** *media* ``modelseedpy.core.msmedia.MSMedia``: The media that is constructed from the dictionary format. - -------------------------------------------- -get_media_constraints() -------------------------------------------- - -A function that assigns a compartment to each compound in the media: - -.. code-block:: python - - media = msmedia.get_media_constraints(cmp='e0') - -- *cmp* ``str``: The compartment suffix that will be appended to all compounds in the media, while ``cmp`` is not ``None``. - -**returns** *media* ``dict``: A dictionary of lower and upper bounds (``values``) for each metabolite ID (``key``). - ------------------ -merge() ------------------ - -A function that expands the media compounds according to amendments from the aforementioned ``MediaCompound`` object: - -.. code-block:: python - - msmedia.merge(media, overwrite_overlap=False) - -- *media* ``modelseedpy.core.msmedia.MSMedia``: The media whose compound compartments have been defined to the parameterized compartment. -- *overwrite_overlap* ``bool``: specifies whether existing metabolite IDs will be redefined by the ``modelseedpy.core.msmedia.MediaCompound`` compound object. +msmedia +-------------------------------------- + ++++++++++++++++++++++ +MediaCompound() ++++++++++++++++++++++ + +This class instantiates a media compound for potential manipulations: + +.. code-block:: python + + from modelseedpy.core import MediaCompound + media_comp = MediaCompound(compound_id, lower_bound, upper_bound, concentration=None) + +- *compound_id* ``str`` & *concentration* ``float``: The ID and concentration of the media compound. +- *lower_bound* & *upper_bound* ``float``: The lower and upper bounds of the exchange reaction for the media compound, respectively. + ++++++++++++++++++++++ +MSMedia() ++++++++++++++++++++++ + +This class instantiates a media for investigation: + +.. code-block:: python + + from modelseedpy.core import MSMedia + msmedia = MSMedia(media_id) + +- *media_id* ``str``: The ID of the investigated media. + +------------------------------------------- +from_dict() +------------------------------------------- + +A function that converts a media dictionary into a media object: + +.. code-block:: python + + media = msmedia.from_dict(media_dictionary) + +- *media_dictionary* ``dict``: A dictionary representation of the media that contains either a list of exchange bounds or the uptake magnitude (``value``) for each compound in the media. + +**returns** *media* ``modelseedpy.core.msmedia.MSMedia``: The media that is constructed from the dictionary format. + +------------------------------------------- +get_media_constraints() +------------------------------------------- + +A function that assigns a compartment to each compound in the media: + +.. code-block:: python + + media = msmedia.get_media_constraints(cmp='e0') + +- *cmp* ``str``: The compartment suffix that will be appended to all compounds in the media, while ``cmp`` is not ``None``. + +**returns** *media* ``dict``: A dictionary of lower and upper bounds (``values``) for each metabolite ID (``key``). + +----------------- +merge() +----------------- + +A function that expands the media compounds according to amendments from the aforementioned ``MediaCompound`` object: + +.. code-block:: python + + msmedia.merge(media, overwrite_overlap=False) + +- *media* ``modelseedpy.core.msmedia.MSMedia``: The media whose compound compartments have been defined to the parameterized compartment. +- *overwrite_overlap* ``bool``: specifies whether existing metabolite IDs will be redefined by the ``modelseedpy.core.msmedia.MediaCompound`` compound object. diff --git a/docs/source/core/msmodel_api.rst b/docs/source/core/msmodel_api.rst index f786ba6a..35f11094 100644 --- a/docs/source/core/msmodel_api.rst +++ b/docs/source/core/msmodel_api.rst @@ -1,107 +1,107 @@ -MSModel Package --------------------------------------- - -------------------------------------------- -get_reaction_constraints_from_direction() -------------------------------------------- - -A function that converts direction symbols (">" or "<") to lower and upper bound, where any other value is returned as reversible bounds: - -.. code-block:: python - - lower_bound, upper_bound = get_reaction_constraints_from_direction(direction) - -- *direction* ``str``: The name of the metabolite that is will be returned by the function. - -**returns** *lower_bound* & *upper_bound* ``float``: The lower and upper bounds of a reaction are deduced from the parameterized direction string. - -------------------------------------------- -get_direction_from_constraints() -------------------------------------------- - -A function that deduces a direction symbol (">", "<", or "=") from the lower and upper reaction bounds: - -.. code-block:: python - - rxn_direction = get_direction_from_constraints(lower_bound, upper_bound) - -- *lower_bound* & *upper_bound* ``float``: The flux boundaries that are used to deduce the representative reaction direction symbol. - -**returns** *rxn_direction* ``float``: The representative direction symbol for the reaction that is described by the lower and upper flux bounds. - -------------------------------------------- -get_gpr_string() -------------------------------------------- - -A function that constructs a GRP string from the parameterized iterable collection of GRPs: - -.. code-block:: python - - gpr_string = get_gpr_string(gpr) - -- *gpr* ``list``: The collection of GPRs that will be assembled into a string via the function. - -**returns** *gpr_string* ``str``: An assembled string of all GPRs that are provided in the parameterized list. - -------------------------------------------- -split_compartment_from_index() -------------------------------------------- - -A function that splits an index from its associated compartment: - -.. code-block:: python - - compartment, index = split_compartment_from_index(cmp_str) - -- *cmp_str* ``str``: The compartment string that will be parsed. - -**returns** *compartment* & *index* ``str``: The compartment and index of the parameterized compartment string, respectively. - -------------------------------------------- -get_cmp_token() -------------------------------------------- - -A function that filters a list of compartments to determine the compartment of greatest interest: - -.. code-block:: python - - compartment_id = get_cmp_token(compartments) - -- *compartments* ``list``: The collection of compartments that will be parsed. - -**returns** *compartment_id* ``str``: The compartment of greatest interest among the parameterized collection of compartments. - -------------------------------------------- -get_set() -------------------------------------------- - -A function that filters a list of compartments to determine the compartment of greatest interest: - -.. code-block:: python - - dnf_set = get_set(expression_string) - -- *expression_string* ``str``: The expression string that will be parsed. - -**returns** *dnf_set* ``set``: The set collection of all dnf objects from the parameterized expression string. - -+++++++++++++++++++++ -MSModel() -+++++++++++++++++++++ - -This class is a representation of ModelSEED models: - -.. code-block:: python - - from modelseedpy.core import MSModel - msmodel = MSModel(id_or_model=None, genome=None, template=None) - -- *id_or_model* ``str || cobra.core.model.Model``: Either the ID of a model or the actual CobraKBase model object that will be represented through this class. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. -- *genome* ``genome object``: The representative object of the genome. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template of the represented model. - ----------------------- -template() & genome() ----------------------- - -**returns** *template* ``modelseedpy.core.mstemplate.MSTemplate`` & ``genome object`` : The template and genome that are associated with the model that is passed to the class instance. +msmodel +-------------------------------------- + +------------------------------------------- +get_reaction_constraints_from_direction() +------------------------------------------- + +A function that converts direction symbols (">" or "<") to lower and upper bound, where any other value is returned as reversible bounds: + +.. code-block:: python + + lower_bound, upper_bound = get_reaction_constraints_from_direction(direction) + +- *direction* ``str``: The name of the metabolite that is will be returned by the function. + +**returns** *lower_bound* & *upper_bound* ``float``: The lower and upper bounds of a reaction are deduced from the parameterized direction string. + +------------------------------------------- +get_direction_from_constraints() +------------------------------------------- + +A function that deduces a direction symbol (">", "<", or "=") from the lower and upper reaction bounds: + +.. code-block:: python + + rxn_direction = get_direction_from_constraints(lower_bound, upper_bound) + +- *lower_bound* & *upper_bound* ``float``: The flux boundaries that are used to deduce the representative reaction direction symbol. + +**returns** *rxn_direction* ``float``: The representative direction symbol for the reaction that is described by the lower and upper flux bounds. + +------------------------------------------- +get_gpr_string() +------------------------------------------- + +A function that constructs a GRP string from the parameterized iterable collection of GRPs: + +.. code-block:: python + + gpr_string = get_gpr_string(gpr) + +- *gpr* ``list``: The collection of GPRs that will be assembled into a string via the function. + +**returns** *gpr_string* ``str``: An assembled string of all GPRs that are provided in the parameterized list. + +------------------------------------------- +split_compartment_from_index() +------------------------------------------- + +A function that splits an index from its associated compartment: + +.. code-block:: python + + compartment, index = split_compartment_from_index(cmp_str) + +- *cmp_str* ``str``: The compartment string that will be parsed. + +**returns** *compartment* & *index* ``str``: The compartment and index of the parameterized compartment string, respectively. + +------------------------------------------- +get_cmp_token() +------------------------------------------- + +A function that filters a list of compartments to determine the compartment of greatest interest: + +.. code-block:: python + + compartment_index = get_cmp_token(compartments) + +- *compartments* ``list``: The collection of compartments that will be parsed. + +**returns** *compartment_index* ``str``: The compartment of greatest interest among the parameterized collection of compartments. + +------------------------------------------- +get_set() +------------------------------------------- + +A function that filters a list of compartments to determine the compartment of greatest interest: + +.. code-block:: python + + dnf_set = get_set(expression_string) + +- *expression_string* ``str``: The expression string that will be parsed. + +**returns** *dnf_set* ``set``: The set collection of all dnf objects from the parameterized expression string. + ++++++++++++++++++++++ +MSModel() ++++++++++++++++++++++ + +This class is a representation of ModelSEED models: + +.. code-block:: python + + from modelseedpy.core import MSModel + msmodel = MSModel(id_or_model=None, genome=None, template=None) + +- *id_or_model* ``str || cobra.core.model.Model``: Either the ID of a model or the actual CobraKBase model object that will be represented through this class. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. +- *genome* ``genome object``: The representative object of the genome. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template of the represented model. + +---------------------- +template() & genome() +---------------------- + +**returns** *template* ``modelseedpy.core.mstemplate.MSTemplate`` & ``genome object`` : The template and genome that are associated with the model that is passed to the class instance. diff --git a/docs/source/core/msmodelutils_api.rst b/docs/source/core/msmodelutils_api.rst index 30f46f51..38837183 100644 --- a/docs/source/core/msmodelutils_api.rst +++ b/docs/source/core/msmodelutils_api.rst @@ -1,142 +1,142 @@ -Model Utilities --------------------------------------- - -+++++++++++++++++++++ -MSModelUtil() -+++++++++++++++++++++ - -This class offers a suite of utility functions that support editing and manipulating FBA models: - -.. code-block:: python - - from modelseedpy.fbapkg import MSModelUtil - msutil = MSModelUtil(model) - -- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -find_met() ----------------------- - -The COBRA metabolite object is located based upon the metabolite name: - -.. code-block:: python - - metabolite = msutil.find_met(name) - -- *name* ``str``: The name of the metabolite that is will be returned by the function. - -**returns** *metabolite* ``cobra.core.model.Metabolite``: The metabolite that was located by the function, or an empty list if the metabolite was not discovered. - ----------------------- -exchange_list() ----------------------- - -The returns a list of all COBRA reaction objects for the instantiated model whose reaction IDs possess an "EX_", which signifies an exchange reaction: - -.. code-block:: python - - exchange_reactions = msutil.exchange_list() - -**returns** *exchange_reactions* ``list``: The collection of exchange reactions for the instantiated model. - ----------------------- -exchange_hash() ----------------------- - -The returns a dictionary of COBRA metabolite (``key``) : reaction (``value``) pairs for all metabolites in the exchange reactions from ``msutil.exchange_list()``: - -.. code-block:: python - - exchange_reactions = msutil.exchange_hash() - -**returns** *exchange_reactions* ``dict``: The COBRA metabolite (``key``) : reaction (``value``) pairs for all model exchange reactions. - ------------------------------ -add_missing_exchanges() ------------------------------ - -The media compounds that are defined in the exchange reactions of the model are defined with drain reactions: - -.. code-block:: python - - media_compounds = msutil.add_missing_exchanges() - -**returns** *media_compounds* ``list``: The collection of media compounds that are represented in the exchange reactions of the model and for which drain reactions have been created. - -------------------------------------- -add_exchanges_for_metabolites() -------------------------------------- - -The media compounds that are defined in the exchange reactions of the model are defined with drain reactions: - -.. code-block:: python - - drain_reactions = msutil.add_exchanges_for_metabolites(cpds, uptake=0, excretion=0, prefix='EX_', prefix_name='Exchange for ') - -- *cpds* ``list``: The collection of media metabolites that represented in the model and will be added to the model as drain reactions. -- *uptake* & *excretion* ``int``: The magnitudes of the lower and upper bounds of the drain reaction, respectively. -- *prefix* & *prefix_name* ``str``: The prefixes of the compound ID and name, respectively. - -**returns** *drain_reactions* ``list``: The drain reactions that were created for the parameterized list of compounds. - -------------------------------------------- -convert_cobra_compound_to_kbcompound() -------------------------------------------- - -The information of the parameterized compound will be organized into an amenable format for addition to the ``modelcompounds`` attribute of CobraKBase models: - -.. code-block:: python - - cpd_data = msutil.convert_cobra_compound_to_kbcompound(cpd, kbmodel = None) - -- *cpd* ``cobra.core.model.Metaoblite``: The COBRA metabolite whose information will be formatted as a KBase metabolite. -- *kbmodel* ``cobra.core.model.Model``: The CobraKBase model whose ``modelcompounds`` attribute will be appended with data from the COBRA metabolite, where ``None`` specifies that the defined dictionary of compound information will not be added to a model. - -**returns** *cpd_data* ``dict``: The dictionary of compound information in the format of the ``modelcompounds`` attribute of CobraKBase models. - -------------------------------------------- -convert_cobra_reaction_to_kbreaction() -------------------------------------------- - -The information of the parameterized reaction will be organized into an amenable format for addition to the ``modelreactions`` attribute of CobraKBase models: - -.. code-block:: python - - rxn_data = msutil.convert_cobra_reaction_to_kbreaction(rxn, kbmodel, cpd_hash, direction = "=", add_to_model = 1, reaction_genes = {}) - -- *rxn* ``cobra.core.model.Reaction``: The COBRA reaction whose information will be formatted as a KBase reaction. -- *kbmodel* ``cobra.core.model.Model``: The CobraKBase model whose ``modelreactions`` attribute will be appended with data from the COBRA reaction, where ``None`` specifies that the defined dictionary of compound information will not be added to a model. -- *direction* ``str``: Signification of the reversibility of the reaction as either "<", ">", or "=" as equilibrium. -- *reaction_genes* ``dict``: The collection of contribution (``values``) for each gene (``keys``) that contribute to each reaction (``keys``). - -**returns** *rxn_data* ``dict``: The dictionary of reaction information in the format of the ``modelreactions`` attribute of CobraKBase models. - -------------------------------------------- -add_gapfilling_solution_to_kbase_model() -------------------------------------------- - -The parameterized CobraKBase model will be expanded with the content of a gapfilling solution: - -.. code-block:: python - - rxn_data = msutil.add_gapfilling_solution_to_kbase_model(newmodel, gapfilled_reactions, gfid=None, media_ref = None, reaction_genes = None) - -- *newmodel* ``cobra.core.model.Model``: The CobraKBase model whose information will be formatted as a KBase reaction. -- *gapfilled_reactions* ``dict``: The collection of COBRA reactions (``values``) in each "new" and "reversed" category of reactions (``keys``). -- *gfid* ``str``: The gapfilling ID, which defaults to "gf.#" where # is the smallest unused index. -- *media_ref* ``str``: The reference for the gapfilling media. -- *reaction_genes* ``dict``: The collection of contribution (``values``) for each gene (``keys``) that contribute to each reaction (``keys``). - -**returns** *rxn_table* ``list``: A collection of dictionaries, one for each reaction that is added to the CobraKBase model. - ----------------------- -Accessible content ----------------------- - -The ``MSModelUtil`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the MSModelUtil package. -- *metabolite_hash* & *search_metabolite_hash* ``dict``: Lists of metabolite matches (``values``) for each metabolite name and refined search name, respectively. +msmodelutils +-------------------------------------- + ++++++++++++++++++++++ +MSModelUtil() ++++++++++++++++++++++ + +This class offers a suite of utility functions that support editing and manipulating FBA models: + +.. code-block:: python + + from modelseedpy.fbapkg import MSModelUtil + msutil = MSModelUtil(model) + +- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +find_met() +---------------------- + +The COBRA metabolite object is located based upon the metabolite name: + +.. code-block:: python + + metabolite = msutil.find_met(name) + +- *name* ``str``: The name of the metabolite that is will be returned by the function. + +**returns** *metabolite* ``cobra.core.model.Metabolite``: The metabolite that was located by the function, or an empty list if the metabolite was not discovered. + +---------------------- +exchange_list() +---------------------- + +The returns a list of all COBRA reaction objects for the instantiated model whose reaction IDs possess an "EX_", which signifies an exchange reaction: + +.. code-block:: python + + exchange_reactions = msutil.exchange_list() + +**returns** *exchange_reactions* ``list``: The collection of exchange reactions for the instantiated model. + +---------------------- +exchange_hash() +---------------------- + +The returns a dictionary of COBRA metabolite (``key``) : reaction (``value``) pairs for all metabolites in the exchange reactions from ``msutil.exchange_list()``: + +.. code-block:: python + + exchange_reactions = msutil.exchange_hash() + +**returns** *exchange_reactions* ``dict``: The COBRA metabolite (``key``) : reaction (``value``) pairs for all model exchange reactions. + +----------------------------- +add_missing_exchanges() +----------------------------- + +The media compounds that are defined in the exchange reactions of the model are defined with drain reactions: + +.. code-block:: python + + media_compounds = msutil.add_missing_exchanges() + +**returns** *media_compounds* ``list``: The collection of media compounds that are represented in the exchange reactions of the model and for which drain reactions have been created. + +------------------------------------- +add_exchanges_for_metabolites() +------------------------------------- + +The media compounds that are defined in the exchange reactions of the model are defined with drain reactions: + +.. code-block:: python + + drain_reactions = msutil.add_exchanges_for_metabolites(cpds, uptake=0, excretion=0, prefix='EX_', prefix_name='Exchange for ') + +- *cpds* ``list``: The collection of media metabolites that represented in the model and will be added to the model as drain reactions. +- *uptake* & *excretion* ``int``: The magnitudes of the lower and upper bounds of the drain reaction, respectively. +- *prefix* & *prefix_name* ``str``: The prefixes of the compound ID and name, respectively. + +**returns** *drain_reactions* ``list``: The drain reactions that were created for the parameterized list of compounds. + +------------------------------------------- +convert_cobra_compound_to_kbcompound() +------------------------------------------- + +The information of the parameterized compound will be organized into an amenable format for addition to the ``modelcompounds`` attribute of CobraKBase models: + +.. code-block:: python + + cpd_data = msutil.convert_cobra_compound_to_kbcompound(cpd, kbmodel = None) + +- *cpd* ``cobra.core.model.Metaoblite``: The COBRA metabolite whose information will be formatted as a KBase metabolite. +- *kbmodel* ``cobra.core.model.Model``: The CobraKBase model whose ``modelcompounds`` attribute will be appended with data from the COBRA metabolite, where ``None`` specifies that the defined dictionary of compound information will not be added to a model. + +**returns** *cpd_data* ``dict``: The dictionary of compound information in the format of the ``modelcompounds`` attribute of CobraKBase models. + +------------------------------------------- +convert_cobra_reaction_to_kbreaction() +------------------------------------------- + +The information of the parameterized reaction will be organized into an amenable format for addition to the ``modelreactions`` attribute of CobraKBase models: + +.. code-block:: python + + rxn_data = msutil.convert_cobra_reaction_to_kbreaction(rxn, kbmodel, cpd_hash, direction = "=", add_to_model = 1, reaction_genes = {}) + +- *rxn* ``cobra.core.model.Reaction``: The COBRA reaction whose information will be formatted as a KBase reaction. +- *kbmodel* ``cobra.core.model.Model``: The CobraKBase model whose ``modelreactions`` attribute will be appended with data from the COBRA reaction, where ``None`` specifies that the defined dictionary of compound information will not be added to a model. +- *direction* ``str``: Signification of the reversibility of the reaction as either "<", ">", or "=" as equilibrium. +- *reaction_genes* ``dict``: The collection of contribution (``values``) for each gene (``keys``) that contribute to each reaction (``keys``). + +**returns** *rxn_data* ``dict``: The dictionary of reaction information in the format of the ``modelreactions`` attribute of CobraKBase models. + +------------------------------------------- +add_gapfilling_solution_to_kbase_model() +------------------------------------------- + +The parameterized CobraKBase model will be expanded with the content of a gapfilling solution: + +.. code-block:: python + + rxn_data = msutil.add_gapfilling_solution_to_kbase_model(newmodel, gapfilled_reactions, gfid=None, media_ref = None, reaction_genes = None) + +- *newmodel* ``cobra.core.model.Model``: The CobraKBase model whose information will be formatted as a KBase reaction. +- *gapfilled_reactions* ``dict``: The collection of COBRA reactions (``values``) in each "new" and "reversed" category of reactions (``keys``). +- *gfid* ``str``: The gapfilling ID, which defaults to "gf.#" where # is the smallest unused index. +- *media_ref* ``str``: The reference for the gapfilling media. +- *reaction_genes* ``dict``: The collection of contribution (``values``) for each gene (``keys``) that contribute to each reaction (``keys``). + +**returns** *rxn_table* ``list``: A collection of dictionaries, one for each reaction that is added to the CobraKBase model. + +---------------------- +Accessible content +---------------------- + +The ``MSModelUtil`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the MSModelUtil package. +- *metabolite_hash* & *search_metabolite_hash* ``dict``: Lists of metabolite matches (``values``) for each metabolite name and refined search name, respectively. diff --git a/docs/source/core/mstemplate_api.rst b/docs/source/core/mstemplate_api.rst index 4c625d3d..6c7de65f 100644 --- a/docs/source/core/mstemplate_api.rst +++ b/docs/source/core/mstemplate_api.rst @@ -1,627 +1,627 @@ -Template packages --------------------------------------- - -+++++++++++++++++++++ -TemplateReactionType -+++++++++++++++++++++ - -A class that defines reaction types, where the attributes ``CONDITIONAL``, ``UNIVERSAL``, ``SPONTANEOUS``, and ``GAPFILLING`` correspond to the strings ``"conditional"``, ``"universal"``, ``"spontaneous"``, and ``"gapfilling"``, respectively: - -+++++++++++++++++++++ -MSTemplateMetabolite -+++++++++++++++++++++ - -A function that assembles a unique list of features for the specified genome: - -.. code-block:: python - - met_template = MSTemplateMetabolite(cpd_id, formula=None, name='', default_charge=None, mass=None, - delta_g=None, delta_g_error=None, is_cofactor=False, abbreviation='', aliases=None) - -- *cpd_id*, *name*, *formula*, *abbreviation*, & *aliases* ``str``: The ID, name, formula, abbreviation, and alias of the ModelSEED compound that will be constructed into a template. -- *default_charge*, *mass*, *delta_g*, & *delta_g_error* ``float``: The charge, mass, :math:`\Delta` g, and error in the :math:`\Delta` g that describe the metabolite that will be constructed into a template. -- *is_cofactor* ``bool``: A description of whether the metabolite is a cofactor in metabolic reactions. - - ------------------- -from_dict() ------------------- - -Returns a ``MSTemplateMetabolite`` object from a metabolite dictionary: - -.. code-block:: python - - metabolite_template = met_template.from_dict(met_dict) - -- *met_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"formula"``, ``"name"``, ``"defaultCharge"``, ``"mass"``, ``"deltaG"``, ``"deltaGErr"``, ``"isCofactor"``, ``"abbreviation"``, & ``"aliases"``. - -**Returns** *metabolite_template* ``modelseedpy.core.mstemplate.MSTemplateMetabolite``: The metabolite object that embodies the content from the dictionary. - ------------------- -get_data() ------------------- - -Returns the metabolite template content. - -.. code-block:: python - - met_template_dict = met_template.get_data() - -**Returns** *met_template_dict* ``dict``: A dictionary of the ``MSTemplateMetabolite`` content. - ---------------------------------------- -__repr__() & __str__() & _repr_html_() ---------------------------------------- - -Constructs strings of the metabolite template content. - -.. code-block:: python - - met_template_str = met_template.__repr__() - met_template_str = met_template.__str__() - met_template_str = met_template.__repr_html__() - -**Returns** *met_template_str* ``str``: formulations of the ``MSTemplateMetabolite`` content. - - -+++++++++++++++++++++ -MSTemplateSpecies -+++++++++++++++++++++ - -A class that defines a metabolite of a template: - -.. code-block:: python - - met_template = MSTemplateSpecies(comp_cpd_id: str, charge: int, compartment: str, cpd_id, max_uptake=0, template=None) - -- *cobra_cpd_id*, *compartment*, & *cpd_id* ``str``: The COBRA ID, compartment, and ModelSEED ID for the respective compound. -- *charge* & *max_uptake* ``int``: The compound charge and max uptake of the compound by the examined model. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template in which the compound will be searched. - ----------------- -to_metabolite() ----------------- - -Creates a COBRA object for a ModelSEEDpy metabolite: - -.. code-block:: python - - met = met_template.to_metabolite(index='0') - -- *index* ``string``: The compartment index of the respective metabolite. - -**returns** *met* ``cobra.core.metabolite.Metabolite``: The COBRA metabolite object of the respective metabolite. - --------------------------------- -compound(), name(), & formula() --------------------------------- - -Property methods that return the object, name, or formula of the template compound, respectively: - -.. code-block:: python - - template_compound = met_template.compound() - compound_name = met_template.name() - compound_formula = met_template.formula() - --------------------------------- -name() & formula() --------------------------------- - -Property setter methods that set the name or formula of the template compound, respectively: - -.. code-block:: python - - met_template.name(name) - met_template.formula(formula) - -- *name* & *formula* ``string``: The name and formula that will be assigned to the respective metabolite. - --------------------------------- -from_dict() --------------------------------- - -Returns methods that return the template compound object: - -.. code-block:: python - - template_compound = met_template.from_dict(met_dict, template) - -- *met_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"charge"``, ``"templatecompartment_ref"``, & ``"templatecompound_ref"``. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template in which the compound will be searched. - ------------------- -get_data() ------------------- - -Returns the metabolite template content. - -.. code-block:: python - - met_template_dict = met_template.get_data() - -**Returns** *met_template_dict* ``dict``: A dictionary of the ``MSTemplateMetabolite`` content. - - -+++++++++++++++++++++ -MSTemplateReaction -+++++++++++++++++++++ - -A class that defines a metabolite of a template: - -.. code-block:: python - - rxn_template = MSTemplateSpecies(rxn_id: str, reference_id: str, name='', subsystem='', lower_bound=0.0, - upper_bound=None,reaction_type=TemplateReactionType.CONDITIONAL, gapfill_direction='=', - base_cost=1000, reverse_penalty=1000, forward_penalty=1000, status='OK') - -- *rxn_id*, *reference_id*, *name*, *subsystem*, & *gapfill_direction* ``str``: The COBRA ID, KBase reference ID, name, subsystem, and gapfilling direction of the respective reaction. -- *lower_bound* & *upper_bound* ``int``: The reaction flux limitations. -- *reaction_type* ``modelseedpy.core.mstemplate.TemplateReactionType``: A description of the reaction type from the set of four options that are offered in the ``TemplateReactionType`` class. -- *base_cost*, *reverse_penalty*, & *forward_penalty* ``float``: defines the minimal flux cost and the specific costs of reverse and forward fluxes, respectively. -- *status* ``str``: specifies the gapfilling status. - ----------------------- -gene_reaction_rule() ----------------------- - -Property methods that return the gene complexes for the reaction: - -.. code-block:: python - - gene_rules = rxn_template.gene_reaction_rule() - -**returns** *gene_rules* ``str``: The set of gene complexes, delimited by ``" or "``. - --------------------------- -compartment() --------------------------- - -Property methods that return the interesting compartment of the respective reaction: - - comptment = rxn_template.compartment() - -**returns** *comptment* ``str``: The interesting compartment character from the reaction. - --------------- -to_reaction() --------------- - -Creates a COBRA object for a ModelSEEDpy reaction: - -.. code-block:: python - - reaction = rxn_template.to_reaction(model=None, index='0') - -- *model* ``cobra.core.model.Model``: The CobraKBase model in which the examined reaction exists. -- *index* ``string``: The compartment within which the reaction executes. - -**returns** *reaction* ``cobra.core.reaction.Reaction``: The COBRA metabolite object of the respective metabolite. - --------------------------------- -from_dict() --------------------------------- - -Returns methods that return the template compound object and the name of the template compound, respectively: - -.. code-block:: python - - reaction = rxn_template.from_dict(rxn_dict, template) - -- *rxn_dict* ``dict``: A dictionary description of the ModelSEED reaction that possesses the following keys ``"id"``, ``"reaction_ref"``, ``"name"``, ``"type"``, ``"GapfillDirection"``, ``"base_cost"``, ``"reverse_penalty"``, ``"forward_penalty"``, & ``"status"``. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template in which the reaction will be searched. - ------------------------------------- -add_complexes() & get_complexes() ------------------------------------- - -Concatenates a list of complexes to the existing list of complexes, and returns the list of complexes, respectively. - -.. code-block:: python - - rxn_template.add_complexes(complex_list) - complexes = rxn_template.get_complexes() - -- *complex_list* ``list``: The list of complexes that will be extended to the existing list of complexes. - -**returns** *complexes* ``list``: The collection of complexes in the ``MSTemplateReaction`` object. - ------------------- -cstoichiometry() ------------------- - -Property methods that return a dictionary of stoichiometric coefficients for each metabolite in the reaction: - -.. code-block:: python - - rxn_stoichiometry = rxn_template.cstoichiometry() - -**returns** *rxn_stoichiometry* ``dict``: The stoichiometry of each metabolite in the reaction (``value``) for each metabolite ID and compartment as a tuple (``key``). - --------------- -get_roles() --------------- - -The set of all roles in all complexes are returned: - -.. code-block:: python - - roles = rxn_template.get_roles() - -**returns** *roles* ``set``: The set of all roles in the complexes of the ``MSTemplateReaction`` object. - ----------------------- -get_complex_roles() ----------------------- - -The creates a dictionary of the roles for each complex: - -.. code-block:: python - - roles = rxn_template.get_complex_roles() - -**returns** *roles* ``dict``: The set of all roles (``keys``) for each complex in the ``MSTemplateReaction`` object. - ------------------- -get_data() ------------------- - -Returns the reaction template content. - -.. code-block:: python - - rxn_template_dict = rxn_template.get_data() - -**Returns** *rxn_template_dict* ``dict``: A dictionary of the ``MSTemplateReaction`` content. - -+++++++++++++++++++++ -NewModelTemplateRole -+++++++++++++++++++++ - -A class that defines a template role for a model: - -.. code-block:: python - - new_model_tmp = NewModelTemplateRole(role_id, name, features=None, source='', aliases=None) - -- *role_id* & *name* ``str``: The ID and name of the role that will be refined into a template. -- *features* & *aliases* ``list``: The collections of features and aliases of the role that will be translated into a template. -- *source* ``str``: The source of the role. - ----------------- -from_dict() ----------------- - -Returns a role template object that is constructed from a dictionary: - -.. code-block:: python - - role_template = new_model_tmp.from_dict(role_dict) - -- *role_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"name"``, ``"features"``, ``"source"``, & ``"aliases"``. - -**Returns** *role_template* ``modelseedpy.core.mstemplate.NewModelTemplateRole``: A template role object. - ------------------- -get_data() ------------------- - -Returns the reaction template content. - -.. code-block:: python - - role_template_dict = new_model_tmp.get_data() - -**Returns** *role_template_dict* ``dict``: A dictionary of the ``NewModelTemplateRole`` content. - ---------------------------------------- -__repr__() & __str__() & _repr_html_() ---------------------------------------- - -Constructs strings of the template content. - -.. code-block:: python - - role_template_str = new_model_tmp.__repr__() - role_template_str = new_model_tmp.__str__() - role_template_str = new_model_tmp.__repr_html__() - -**Returns** *role_template_str* ``str``: formulations of the ``NewModelTemplateRole`` content. - -+++++++++++++++++++++++++++++ -NewModelTemplateComplex -+++++++++++++++++++++++++++++ - -A class that defines a template for a protein complex: - -.. code-block:: python - - complex_template = NewModelTemplateComplex(complex_id, name, source='', reference='', confidence=0, template=None) - -- *complex_id*, *name*, *source*, *reference* ``str``: The ID, name, source, and reference of the complex that will be refined into a template. -- *confidence* ``int``: A confidence rating of the -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. - ----------------- -from_dict() ----------------- - -Returns a complex template object that is constructed from a dictionary: - -.. code-block:: python - - complex = complex_template.from_dict(complex_dict, template) - -- *complex_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"name"``, ``"source"``, ``"reference"``, & ``"confidence"``. -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. - -**Returns** *complex* ``modelseedpy.core.mstemplate.NewModelTemplateComplex``: A complex template object. - -------------- -add_role() -------------- - -Adds triggering and optional functions of a role to the dictionary of roles for the respective complex: - -.. code-block:: python - - complex_template.add_role(role, triggering=True, optional=False) - -- *role* ``modelseedpy.core.mstemplate.NewModelTemplateRole``: The role that will be added to the collection of roles for the complex. -- *triggering* & *optional* ``bool``: Descriptions of the role that will be added. - -------------- -get_data() -------------- - -Returns the complex template information: - -.. code-block:: python - - complex_data = complex_template.get_data() - -**Returns** *complex_data* ``dict``: The complex template information. - ---------------------------------------- -__repr__() & __str__() & _repr_html_() ---------------------------------------- - -Constructs strings of the template content. - -.. code-block:: python - - complex_template_str = complex_template.__repr__() - complex_template_str = complex_template.__str__() - complex_template_str = complex_template.__repr_html__() - -**Returns** *complex_template_str* ``str``: formulations of the ``NewModelTemplateComplex`` content. - - -+++++++++++++++++++++++++++++ -MSTemplateCompartment -+++++++++++++++++++++++++++++ - -A class that defines template compartments: - -.. code-block:: python - - complex_template = NewModelTemplateComplex(compartment_id: str, name: str, ph: float, hierarchy=0, aliases=None) - -- *compartment_id* & *name* ``str``: The ID and name of the compartment that will be refined into a template. -- *ph* ``float``: The pH of the compartment. -- *hierarchy* ``float``: The pH of the compartment. -- *aliases* ``list``: The collection of alternative identifications for the compartment. - ----------------- -from_dict() ----------------- - -Returns a compartment template object that is constructed from a dictionary: - -.. code-block:: python - - compartment = complex_template.from_dict(compartment_dict) - -- *compartment_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"name"``, ``"pH"``, ``"hierarchy"``, & ``"aliases"``. - -**Returns** *compartment* ``modelseedpy.core.mstemplate.MSTemplateCompartment``: A compartment template object. - -------------- -get_data() -------------- - -Returns the compartment template information: - -.. code-block:: python - - complex_data = complex_template.get_data() - -**Returns** *complex_data* ``dict``: The complex template information. - - -+++++++++++++++++++++++++++++ -MSTemplate -+++++++++++++++++++++++++++++ - -A class that defines model templates, while leveraging the aforementioned classes: - -.. code-block:: python - - template = MSTemplate(template_id, name='', domain='', template_type='', version=1, info=None, args=None) - -- *template_id*, *name*, *domain*, & *template_type* ``str``: The ID, name, domain, and type of the template that will be constructed. -- *version* ``int``: The version of the template. - ------------------------------------------------------------------------------------------------------------ -add_compartments(), add_roles(), add_complexes(), add_compounds(), add_comp_compounds(), & add_reactions() ------------------------------------------------------------------------------------------------------------ - -Functions that add compartments, roles, complexes, compartment compounds, and reactions, respectively, to the developing template. These functions will only add the provided values to the template when they are all unique: - -.. code-block:: python - - template.add_compartments(compartments) - template.add_roles(roles) - template.add_complexes(complexes) - template.add_compounds(compounds) - template.add_comp_compounds(comp_compounds) - template.add_reactions(reactions) - -- *compartments*, *roles*, *complexes*, *compounds*, *comp_compounds*, & *reactions* ``list``: The collections of compartments, roles, complexes, compounds, comp_compounds, and reactions that will be added to the template, provided that all list elements are not extant in the model. - ------------------------------- -get_complex_from_roles() ------------------------------- - -A function that yields a complex based upon a descriptive set of complex roles: - -.. code-block:: python - - complex = template.get_complex_from_roles(roles) - -- *roles* ``list``: The collection of complex roles that will be used to discern the associated complex. - -**Returns** *complex* ``modelseedpy.core.mstemplate.NewModelTemplateComplex``: The complex that is discerned from the collection of roles. - ------------------------------- -get_last_id_value() ------------------------------- - -A function that yields the largest id from a collection of COBRA objects: - -.. code-block:: python - - last_id = template.get_complex_from_roles(objects) - -- *objects* ``list``: The collection of COBRA objects whose IDs will be examined. - -**Returns** *last_id* ``int``: The largest ID from the collection of COBRA objects. - ------------------------------------------------- -get_complex(), get_reaction(), & get_role() ------------------------------------------------- - -A function that yields the largest id from a collection of COBRA objects: - -.. code-block:: python - - complex = template.get_complex(obj_id) - reaction = template.get_reaction(obj_id) - role = template.get_role(obj_id) - -- *obj_id* ``str``: The COBRA ID whose associated complex, reaction, and role will be examined. - -**Returns** *complex* ``modelseedpy.core.mstemplate.NewModelTemplateComplex``: The complex that matches the COBRA object ID. -**Returns** *reaction* ``cobra.core.reaction.Reaction``: The COBRA reaction that matches the ID. -**Returns** *role* ``modelseedpy.core.mstemplate.NewModelTemplateRole``: The role that matches the COBRA objects. - ------------- -get_data() ------------- - -A function that returns the template data: - -.. code-block:: python - - template_data = template.get_data() - -**Returns** *template_data* ``dict``: The template data organized into a dictionary structure. - ------------------ -_repr_html_() ------------------ - -Constructs and returns strings of the template content: - -.. code-block:: python - - template_html = template.__repr_html__() - -**Returns** *template_html* ``str``: A str of the template data organized into HTML. - - -+++++++++++++++++++++++++++++ -MSTemplateBuilder -+++++++++++++++++++++++++++++ - -A class that defines model templates, while leveraging the aforementioned classes: - -.. code-block:: python - - template = MSTemplateBuilder(template_id, name='', domain='', template_type='', version=1, info=None, - biochemistry=None, biomasses=None, pathways=None, subsystems=None) - -- *template_id*, *name*, *domain*, & *template_type* ``str``: The ID, name, domain, and type of the template that will be constructed. -- *version* ``int``: The version of the template. -- *info* ``str``: A description of the template that will be stored with the constructed template. - ----------------- -from_dict() ----------------- - -Returns a template builder object that is constructed from a dictionary: - -.. code-block:: python - - builder = complex_template.from_dict(template_dict) - -- *template_dict* ``dict``: A dictionary description of the template, which possesses keys of ``"id"``, ``"name"``, ``"domain"``, ``"type"``, ``"__VERSION__"``, ``"compartments"``, ``"roles"``, ``"complexes"``, ``"compounds"``, ``"compcompounds"``, ``"reactions"``, ``"biochemistry_ref"``, & ``"biomasses"``. - -**Returns** *builder* ``modelseedpy.core.mstemplate.MSTemplateBuilder``: The template builder object that was constructed from the dictionary. - ------------------ -from_template() ------------------ - -Returns a template builder object whose compartments are copied from an existing template: - -.. code-block:: python - - builder = complex_template.from_dict(template) - -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. - -**Returns** *builder* ``modelseedpy.core.mstemplate.MSTemplateBuilder``: The template builder object that was partly copied from the existing template. - ------------------ -with_role() ------------------ - -Returns the complex reference for the given reaction and role IDs: - -.. code-block:: python - - complex_ref = complex_template.with_role(template_rxn, role_ids, auto_complex=False) - -- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. -- *role_ids* ``list``: The collection of role IDs for the complex that will identify the corresponding complex ID. -- *auto_complex* ``bool``: specifies whether a complex will be added from the roles if roles are not identified with an associated complex. - -**Returns** *complex_ref* ``str``: The complex reference path with the determined complex ID. - ----------------------- -with_compartment() ----------------------- - -Returns a matched compartment with the provided ID, otherwise the compartment is added to the MSTemplateBuilder object and the MSBuilder object is returned: - -.. code-block:: python - - compartment = complex_template.with_compartment(cmp_id, name, ph=7, index='0') - -- *cmp_id*, *name*, & *index* ``str``: The ID, name, and index of the compartment that will be returned or added to the template. -- *ph* ``float``: The pH of the corresponding compartment. - -**Returns** *compartment* ``str``: The compartment, or the first of numerous compartments, that matches the provided ID. - ------------ -build() ------------ - -The function that amalgamates the content of the MSTemplateBuilder object into a MSTemplate object: - -.. code-block:: python - - template = complex_template.build() - -**Returns** *template* ``modelseedpy.core.mstemplate.MSTemplate``: The MSTemplate object that is constructed from the content of the MSTemplateBuilder object. +mstemplate +-------------------------------------- + ++++++++++++++++++++++ +TemplateReactionType ++++++++++++++++++++++ + +A class that defines reaction types, where the attributes ``CONDITIONAL``, ``UNIVERSAL``, ``SPONTANEOUS``, and ``GAPFILLING`` correspond to the strings ``"conditional"``, ``"universal"``, ``"spontaneous"``, and ``"gapfilling"``, respectively: + ++++++++++++++++++++++ +MSTemplateMetabolite ++++++++++++++++++++++ + +A function that assembles a unique list of features for the specified genome: + +.. code-block:: python + + met_template = MSTemplateMetabolite(cpd_id, formula=None, name='', default_charge=None, mass=None, + delta_g=None, delta_g_error=None, is_cofactor=False, abbreviation='', aliases=None) + +- *cpd_id*, *name*, *formula*, *abbreviation*, & *aliases* ``str``: The ID, name, formula, abbreviation, and alias of the ModelSEED compound that will be constructed into a template. +- *default_charge*, *mass*, *delta_g*, & *delta_g_error* ``float``: The charge, mass, :math:`\Delta` g, and error in the :math:`\Delta` g that describe the metabolite that will be constructed into a template. +- *is_cofactor* ``bool``: A description of whether the metabolite is a cofactor in metabolic reactions. + + +------------------ +from_dict() +------------------ + +Returns a ``MSTemplateMetabolite`` object from a metabolite dictionary: + +.. code-block:: python + + metabolite_template = met_template.from_dict(met_dict) + +- *met_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"formula"``, ``"name"``, ``"defaultCharge"``, ``"mass"``, ``"deltaG"``, ``"deltaGErr"``, ``"isCofactor"``, ``"abbreviation"``, & ``"aliases"``. + +**Returns** *metabolite_template* ``modelseedpy.core.mstemplate.MSTemplateMetabolite``: The metabolite object that embodies the content from the dictionary. + +------------------ +get_data() +------------------ + +Returns the metabolite template content. + +.. code-block:: python + + met_template_dict = met_template.get_data() + +**Returns** *met_template_dict* ``dict``: A dictionary of the ``MSTemplateMetabolite`` content. + +--------------------------------------- +__repr__() & __str__() & _repr_html_() +--------------------------------------- + +Constructs strings of the metabolite template content. + +.. code-block:: python + + met_template_str = met_template.__repr__() + met_template_str = met_template.__str__() + met_template_str = met_template.__repr_html__() + +**Returns** *met_template_str* ``str``: formulations of the ``MSTemplateMetabolite`` content. + + ++++++++++++++++++++++ +MSTemplateSpecies ++++++++++++++++++++++ + +A class that defines a metabolite of a template: + +.. code-block:: python + + met_template = MSTemplateSpecies(comp_cpd_id: str, charge: int, compartment: str, cpd_id, max_uptake=0, template=None) + +- *cobra_cpd_id*, *compartment*, & *cpd_id* ``str``: The COBRA ID, compartment, and ModelSEED ID for the respective compound. +- *charge* & *max_uptake* ``int``: The compound charge and max uptake of the compound by the examined model. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template in which the compound will be searched. + +---------------- +to_metabolite() +---------------- + +Creates a COBRA object for a ModelSEEDpy metabolite: + +.. code-block:: python + + met = met_template.to_metabolite(index='0') + +- *index* ``string``: The compartment index of the respective metabolite. + +**returns** *met* ``cobra.core.metabolite.Metabolite``: The COBRA metabolite object of the respective metabolite. + +-------------------------------- +compound(), name(), & formula() +-------------------------------- + +Property methods that return the object, name, or formula of the template compound, respectively: + +.. code-block:: python + + template_compound = met_template.compound() + compound_name = met_template.name() + compound_formula = met_template.formula() + +-------------------------------- +name() & formula() +-------------------------------- + +Property setter methods that set the name or formula of the template compound, respectively: + +.. code-block:: python + + met_template.name(name) + met_template.formula(formula) + +- *name* & *formula* ``string``: The name and formula that will be assigned to the respective metabolite. + +-------------------------------- +from_dict() +-------------------------------- + +Returns methods that return the template compound object: + +.. code-block:: python + + template_compound = met_template.from_dict(met_dict, template) + +- *met_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"charge"``, ``"templatecompartment_ref"``, & ``"templatecompound_ref"``. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template in which the compound will be searched. + +------------------ +get_data() +------------------ + +Returns the metabolite template content. + +.. code-block:: python + + met_template_dict = met_template.get_data() + +**Returns** *met_template_dict* ``dict``: A dictionary of the ``MSTemplateMetabolite`` content. + + ++++++++++++++++++++++ +MSTemplateReaction ++++++++++++++++++++++ + +A class that defines a metabolite of a template: + +.. code-block:: python + + rxn_template = MSTemplateSpecies(rxn_id: str, reference_id: str, name='', subsystem='', lower_bound=0.0, + upper_bound=None,reaction_type=TemplateReactionType.CONDITIONAL, gapfill_direction='=', + base_cost=1000, reverse_penalty=1000, forward_penalty=1000, status='OK') + +- *rxn_id*, *reference_id*, *name*, *subsystem*, & *gapfill_direction* ``str``: The COBRA ID, KBase reference ID, name, subsystem, and gapfilling direction of the respective reaction. +- *lower_bound* & *upper_bound* ``int``: The reaction flux limitations. +- *reaction_type* ``modelseedpy.core.mstemplate.TemplateReactionType``: A description of the reaction type from the set of four options that are offered in the ``TemplateReactionType`` class. +- *base_cost*, *reverse_penalty*, & *forward_penalty* ``float``: defines the minimal flux cost and the specific costs of reverse and forward fluxes, respectively. +- *status* ``str``: specifies the gapfilling status. + +---------------------- +gene_reaction_rule() +---------------------- + +Property methods that return the gene complexes for the reaction: + +.. code-block:: python + + gene_rules = rxn_template.gene_reaction_rule() + +**returns** *gene_rules* ``str``: The set of gene complexes, delimited by ``" or "``. + +-------------------------- +compartment() +-------------------------- + +Property methods that return the interesting compartment of the respective reaction: + + comptment = rxn_template.compartment() + +**returns** *comptment* ``str``: The interesting compartment character from the reaction. + +-------------- +to_reaction() +-------------- + +Creates a COBRA object for a ModelSEEDpy reaction: + +.. code-block:: python + + reaction = rxn_template.to_reaction(model=None, index='0') + +- *model* ``cobra.core.model.Model``: The CobraKBase model in which the examined reaction exists. +- *index* ``string``: The compartment within which the reaction executes. + +**returns** *reaction* ``cobra.core.reaction.Reaction``: The COBRA metabolite object of the respective metabolite. + +-------------------------------- +from_dict() +-------------------------------- + +Returns methods that return the template compound object and the name of the template compound, respectively: + +.. code-block:: python + + reaction = rxn_template.from_dict(rxn_dict, template) + +- *rxn_dict* ``dict``: A dictionary description of the ModelSEED reaction that possesses the following keys ``"id"``, ``"reaction_ref"``, ``"name"``, ``"type"``, ``"GapfillDirection"``, ``"base_cost"``, ``"reverse_penalty"``, ``"forward_penalty"``, & ``"status"``. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The model template in which the reaction will be searched. + +------------------------------------ +add_complexes() & get_complexes() +------------------------------------ + +Concatenates a list of complexes to the existing list of complexes, and returns the list of complexes, respectively. + +.. code-block:: python + + rxn_template.add_complexes(complex_list) + complexes = rxn_template.get_complexes() + +- *complex_list* ``list``: The list of complexes that will be extended to the existing list of complexes. + +**returns** *complexes* ``list``: The collection of complexes in the ``MSTemplateReaction`` object. + +------------------ +cstoichiometry() +------------------ + +Property methods that return a dictionary of stoichiometric coefficients for each metabolite in the reaction: + +.. code-block:: python + + rxn_stoichiometry = rxn_template.cstoichiometry() + +**returns** *rxn_stoichiometry* ``dict``: The stoichiometry of each metabolite in the reaction (``value``) for each metabolite ID and compartment as a tuple (``key``). + +-------------- +get_roles() +-------------- + +The set of all roles in all complexes are returned: + +.. code-block:: python + + roles = rxn_template.get_roles() + +**returns** *roles* ``set``: The set of all roles in the complexes of the ``MSTemplateReaction`` object. + +---------------------- +get_complex_roles() +---------------------- + +The creates a dictionary of the roles for each complex: + +.. code-block:: python + + roles = rxn_template.get_complex_roles() + +**returns** *roles* ``dict``: The set of all roles (``keys``) for each complex in the ``MSTemplateReaction`` object. + +------------------ +get_data() +------------------ + +Returns the reaction template content. + +.. code-block:: python + + rxn_template_dict = rxn_template.get_data() + +**Returns** *rxn_template_dict* ``dict``: A dictionary of the ``MSTemplateReaction`` content. + ++++++++++++++++++++++ +NewModelTemplateRole ++++++++++++++++++++++ + +A class that defines a template role for a model: + +.. code-block:: python + + new_model_tmp = NewModelTemplateRole(role_id, name, features=None, source='', aliases=None) + +- *role_id* & *name* ``str``: The ID and name of the role that will be refined into a template. +- *features* & *aliases* ``list``: The collections of features and aliases of the role that will be translated into a template. +- *source* ``str``: The source of the role. + +---------------- +from_dict() +---------------- + +Returns a role template object that is constructed from a dictionary: + +.. code-block:: python + + role_template = new_model_tmp.from_dict(role_dict) + +- *role_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"name"``, ``"features"``, ``"source"``, & ``"aliases"``. + +**Returns** *role_template* ``modelseedpy.core.mstemplate.NewModelTemplateRole``: A template role object. + +------------------ +get_data() +------------------ + +Returns the reaction template content. + +.. code-block:: python + + role_template_dict = new_model_tmp.get_data() + +**Returns** *role_template_dict* ``dict``: A dictionary of the ``NewModelTemplateRole`` content. + +--------------------------------------- +__repr__() & __str__() & _repr_html_() +--------------------------------------- + +Constructs strings of the template content. + +.. code-block:: python + + role_template_str = new_model_tmp.__repr__() + role_template_str = new_model_tmp.__str__() + role_template_str = new_model_tmp.__repr_html__() + +**Returns** *role_template_str* ``str``: formulations of the ``NewModelTemplateRole`` content. + ++++++++++++++++++++++++++++++ +NewModelTemplateComplex ++++++++++++++++++++++++++++++ + +A class that defines a template for a protein complex: + +.. code-block:: python + + complex_template = NewModelTemplateComplex(complex_id, name, source='', reference='', confidence=0, template=None) + +- *complex_id*, *name*, *source*, *reference* ``str``: The ID, name, source, and reference of the complex that will be refined into a template. +- *confidence* ``int``: A confidence rating of the +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. + +---------------- +from_dict() +---------------- + +Returns a complex template object that is constructed from a dictionary: + +.. code-block:: python + + complex = complex_template.from_dict(complex_dict, template) + +- *complex_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"name"``, ``"source"``, ``"reference"``, & ``"confidence"``. +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. + +**Returns** *complex* ``modelseedpy.core.mstemplate.NewModelTemplateComplex``: A complex template object. + +------------- +add_role() +------------- + +Adds triggering and optional functions of a role to the dictionary of roles for the respective complex: + +.. code-block:: python + + complex_template.add_role(role, triggering=True, optional=False) + +- *role* ``modelseedpy.core.mstemplate.NewModelTemplateRole``: The role that will be added to the collection of roles for the complex. +- *triggering* & *optional* ``bool``: Descriptions of the role that will be added. + +------------- +get_data() +------------- + +Returns the complex template information: + +.. code-block:: python + + complex_data = complex_template.get_data() + +**Returns** *complex_data* ``dict``: The complex template information. + +--------------------------------------- +__repr__() & __str__() & _repr_html_() +--------------------------------------- + +Constructs strings of the template content. + +.. code-block:: python + + complex_template_str = complex_template.__repr__() + complex_template_str = complex_template.__str__() + complex_template_str = complex_template.__repr_html__() + +**Returns** *complex_template_str* ``str``: formulations of the ``NewModelTemplateComplex`` content. + + ++++++++++++++++++++++++++++++ +MSTemplateCompartment ++++++++++++++++++++++++++++++ + +A class that defines template compartments: + +.. code-block:: python + + complex_template = NewModelTemplateComplex(compartment_index: str, name: str, ph: float, hierarchy=0, aliases=None) + +- *compartment_index* & *name* ``str``: The ID and name of the compartment that will be refined into a template. +- *ph* ``float``: The pH of the compartment. +- *hierarchy* ``float``: The pH of the compartment. +- *aliases* ``list``: The collection of alternative identifications for the compartment. + +---------------- +from_dict() +---------------- + +Returns a compartment template object that is constructed from a dictionary: + +.. code-block:: python + + compartment = complex_template.from_dict(compartment_dict) + +- *compartment_dict* ``dict``: A dictionary description of the ModelSEED compound that possesses the following keys ``"id"``, ``"name"``, ``"pH"``, ``"hierarchy"``, & ``"aliases"``. + +**Returns** *compartment* ``modelseedpy.core.mstemplate.MSTemplateCompartment``: A compartment template object. + +------------- +get_data() +------------- + +Returns the compartment template information: + +.. code-block:: python + + complex_data = complex_template.get_data() + +**Returns** *complex_data* ``dict``: The complex template information. + + ++++++++++++++++++++++++++++++ +MSTemplate ++++++++++++++++++++++++++++++ + +A class that defines model templates, while leveraging the aforementioned classes: + +.. code-block:: python + + template = MSTemplate(template_id, name='', domain='', template_type='', version=1, info=None, args=None) + +- *template_id*, *name*, *domain*, & *template_type* ``str``: The ID, name, domain, and type of the template that will be constructed. +- *version* ``int``: The version of the template. + +----------------------------------------------------------------------------------------------------------- +add_compartments(), add_roles(), add_complexes(), add_compounds(), add_comp_compounds(), & add_reactions() +----------------------------------------------------------------------------------------------------------- + +Functions that add compartments, roles, complexes, compartment compounds, and reactions, respectively, to the developing template. These functions will only add the provided values to the template when they are all unique: + +.. code-block:: python + + template.add_compartments(compartments) + template.add_roles(roles) + template.add_complexes(complexes) + template.add_compounds(compounds) + template.add_comp_compounds(comp_compounds) + template.add_reactions(reactions) + +- *compartments*, *roles*, *complexes*, *compounds*, *comp_compounds*, & *reactions* ``list``: The collections of compartments, roles, complexes, compounds, comp_compounds, and reactions that will be added to the template, provided that all list elements are not extant in the model. + +------------------------------ +get_complex_from_roles() +------------------------------ + +A function that yields a complex based upon a descriptive set of complex roles: + +.. code-block:: python + + complex = template.get_complex_from_roles(roles) + +- *roles* ``list``: The collection of complex roles that will be used to discern the associated complex. + +**Returns** *complex* ``modelseedpy.core.mstemplate.NewModelTemplateComplex``: The complex that is discerned from the collection of roles. + +------------------------------ +get_last_id_value() +------------------------------ + +A function that yields the largest id from a collection of COBRA objects: + +.. code-block:: python + + last_id = template.get_complex_from_roles(objects) + +- *objects* ``list``: The collection of COBRA objects whose IDs will be examined. + +**Returns** *last_id* ``int``: The largest ID from the collection of COBRA objects. + +------------------------------------------------ +get_complex(), get_reaction(), & get_role() +------------------------------------------------ + +A function that yields the largest id from a collection of COBRA objects: + +.. code-block:: python + + complex = template.get_complex(obj_id) + reaction = template.get_reaction(obj_id) + role = template.get_role(obj_id) + +- *obj_id* ``str``: The COBRA ID whose associated complex, reaction, and role will be examined. + +**Returns** *complex* ``modelseedpy.core.mstemplate.NewModelTemplateComplex``: The complex that matches the COBRA object ID. +**Returns** *reaction* ``cobra.core.reaction.Reaction``: The COBRA reaction that matches the ID. +**Returns** *role* ``modelseedpy.core.mstemplate.NewModelTemplateRole``: The role that matches the COBRA objects. + +------------ +get_data() +------------ + +A function that returns the template data: + +.. code-block:: python + + template_data = template.get_data() + +**Returns** *template_data* ``dict``: The template data organized into a dictionary structure. + +----------------- +_repr_html_() +----------------- + +Constructs and returns strings of the template content: + +.. code-block:: python + + template_html = template.__repr_html__() + +**Returns** *template_html* ``str``: A str of the template data organized into HTML. + + ++++++++++++++++++++++++++++++ +MSTemplateBuilder ++++++++++++++++++++++++++++++ + +A class that defines model templates, while leveraging the aforementioned classes: + +.. code-block:: python + + template = MSTemplateBuilder(template_id, name='', domain='', template_type='', version=1, info=None, + biochemistry=None, biomasses=None, pathways=None, subsystems=None) + +- *template_id*, *name*, *domain*, & *template_type* ``str``: The ID, name, domain, and type of the template that will be constructed. +- *version* ``int``: The version of the template. +- *info* ``str``: A description of the template that will be stored with the constructed template. + +---------------- +from_dict() +---------------- + +Returns a template builder object that is constructed from a dictionary: + +.. code-block:: python + + builder = complex_template.from_dict(template_dict) + +- *template_dict* ``dict``: A dictionary description of the template, which possesses keys of ``"id"``, ``"name"``, ``"domain"``, ``"type"``, ``"__VERSION__"``, ``"compartments"``, ``"roles"``, ``"complexes"``, ``"compounds"``, ``"compcompounds"``, ``"reactions"``, ``"biochemistry_ref"``, & ``"biomasses"``. + +**Returns** *builder* ``modelseedpy.core.mstemplate.MSTemplateBuilder``: The template builder object that was constructed from the dictionary. + +----------------- +from_template() +----------------- + +Returns a template builder object whose compartments are copied from an existing template: + +.. code-block:: python + + builder = complex_template.from_dict(template) + +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. + +**Returns** *builder* ``modelseedpy.core.mstemplate.MSTemplateBuilder``: The template builder object that was partly copied from the existing template. + +----------------- +with_role() +----------------- + +Returns the complex reference for the given reaction and role IDs: + +.. code-block:: python + + complex_ref = complex_template.with_role(template_rxn, role_ids, auto_complex=False) + +- *template* ``modelseedpy.core.mstemplate.MSTemplate``: The template upon which the complex will be added. +- *role_ids* ``list``: The collection of role IDs for the complex that will identify the corresponding complex ID. +- *auto_complex* ``bool``: specifies whether a complex will be added from the roles if roles are not identified with an associated complex. + +**Returns** *complex_ref* ``str``: The complex reference path with the determined complex ID. + +---------------------- +with_compartment() +---------------------- + +Returns a matched compartment with the provided ID, otherwise the compartment is added to the MSTemplateBuilder object and the MSBuilder object is returned: + +.. code-block:: python + + compartment = complex_template.with_compartment(cmp_id, name, ph=7, index='0') + +- *cmp_id*, *name*, & *index* ``str``: The ID, name, and index of the compartment that will be returned or added to the template. +- *ph* ``float``: The pH of the corresponding compartment. + +**Returns** *compartment* ``str``: The compartment, or the first of numerous compartments, that matches the provided ID. + +----------- +build() +----------- + +The function that amalgamates the content of the MSTemplateBuilder object into a MSTemplate object: + +.. code-block:: python + + template = complex_template.build() + +**Returns** *template* ``modelseedpy.core.mstemplate.MSTemplate``: The MSTemplate object that is constructed from the content of the MSTemplateBuilder object. diff --git a/docs/source/core/rpcclient_api.rst b/docs/source/core/rpcclient_api.rst index f4560f63..54e42d61 100644 --- a/docs/source/core/rpcclient_api.rst +++ b/docs/source/core/rpcclient_api.rst @@ -1,66 +1,66 @@ -RPC Client Packages ---------------------------- - -+++++++++++++++++++++ -ServerError() -+++++++++++++++++++++ - -This class constructs a descriptive string of a Server Error: - -.. code-block:: python - - from modelseedpy.core import ServerError - servErr = ServerError(name, code, message, data=None, error=None) - -- *name* & *message* ``str``: The name and message of the error. -- *code* ``int``: The numerical code number of the error. -- *data* & *error* ``str``: The data and error of the server error, respectively, where only one of these will be included when the string is constructed. - ----------------- -__str__() ----------------- - -**returns** *error_string* ``str``: A descriptive string of the Server Error that consists of the content that was provided in the initiation of the class. - -------------------------------------- -Accessible content -------------------------------------- - -The *name*, *message*, *code*, and *data* or *error* parameters that comprise the *error_string* from the ``__str__ function are accessible from the class. - -+++++++++++++++++++++ -RPCClient() -+++++++++++++++++++++ - -This class offers a suite of static method functions that assist users in editing and expanding COBRA models: - -.. code-block:: python - - from modelseedpy.core import RPCClient - rpcCli = RPCClient(url,token=None,version="1.0",timeout=30 * 60,trust_all_ssl_certificates=False) - -- *url* & *token* ``str``: The URL that will be parsed via requests, and the token that authorizes access to the URL site. -- *version* ``str``: The version of the URL that will be parsed. -- *timeout* ``float``: The limit of seconds at which requests post will terminate. -- *trust_all_ssl_certificates* ``bool``: specifies whether the requests posts will be verified. - -------------- -call() -------------- - -**returns** *error_string* ``str``: A descriptive string of the Server Error that consists of the content that was provided in the initiation of the class. - -.. code-block:: python - - resp_result = rpcCli.call(method, params, token=None) - -- *method* ``str`` & *params* ``dict``: Components that are passed as data to the URL request. -- *token* ``str``: The token that authorizes access to the URL site. - -**returns** *resp_result* ``str``: The requests result where it exists, otherwise ``None``. - -------------------------------------- -Accessible content -------------------------------------- - -The *url*, *version*, *token*, *timeout*, and *trust_all_ssl_certificates* parameters are accessible from the class. +rpcclient +--------------------------- + ++++++++++++++++++++++ +ServerError() ++++++++++++++++++++++ + +This class constructs a descriptive string of a Server Error: + +.. code-block:: python + + from modelseedpy.core import ServerError + servErr = ServerError(name, code, message, data=None, error=None) + +- *name* & *message* ``str``: The name and message of the error. +- *code* ``int``: The numerical code number of the error. +- *data* & *error* ``str``: The data and error of the server error, respectively, where only one of these will be included when the string is constructed. + +---------------- +__str__() +---------------- + +**returns** *error_string* ``str``: A descriptive string of the Server Error that consists of the content that was provided in the initiation of the class. + +------------------------------------- +Accessible content +------------------------------------- + +The *name*, *message*, *code*, and *data* or *error* parameters that comprise the *error_string* from the ``__str__ function are accessible from the class. + ++++++++++++++++++++++ +RPCClient() ++++++++++++++++++++++ + +This class offers a suite of static method functions that assist users in editing and expanding COBRA models: + +.. code-block:: python + + from modelseedpy.core import RPCClient + rpcCli = RPCClient(url,token=None,version="1.0",timeout=30 * 60,trust_all_ssl_certificates=False) + +- *url* & *token* ``str``: The URL that will be parsed via requests, and the token that authorizes access to the URL site. +- *version* ``str``: The version of the URL that will be parsed. +- *timeout* ``float``: The limit of seconds at which requests post will terminate. +- *trust_all_ssl_certificates* ``bool``: specifies whether the requests posts will be verified. + +------------- +call() +------------- + +**returns** *error_string* ``str``: A descriptive string of the Server Error that consists of the content that was provided in the initiation of the class. + +.. code-block:: python + + resp_result = rpcCli.call(method, params, token=None) + +- *method* ``str`` & *params* ``dict``: Components that are passed as data to the URL request. +- *token* ``str``: The token that authorizes access to the URL site. + +**returns** *resp_result* ``str``: The requests result where it exists, otherwise ``None``. + +------------------------------------- +Accessible content +------------------------------------- + +The *url*, *version*, *token*, *timeout*, and *trust_all_ssl_certificates* parameters are accessible from the class. diff --git a/docs/source/core/template_api.rst b/docs/source/core/template_api.rst index 71fb9530..dc32ca97 100644 --- a/docs/source/core/template_api.rst +++ b/docs/source/core/template_api.rst @@ -1,53 +1,53 @@ -Template Package -------------------- - -+++++++++++++++++++++ -Template() -+++++++++++++++++++++ - -This class reformats metabolites into compounds and reactions into an amenable format for templates: - -.. code-block:: python - - from modelseedpy.core import Template - bioplate = Template() - ------------------------------- -convert_template_compound() ------------------------------- - -A compound is reformatted for addition to a template: - -.. code-block:: python - - met = bioplate.convert_template_compound(cpdid, index) - -- *cpdid* ``cobra.core.model.Metabolite``: The compound that will be formatted for addition to a complate. -- *index* ``int``: The index of a respective compound, which will be the suffix of the reformatted compound ID. - -**returns** *met* ``cobra.core.model.Metabolite``: The reformatted compound for addition to a model template. - --------------------------------- -convert_template_reaction() --------------------------------- - -A reaction is reformatted for addition to a template: - -.. code-block:: python - - rxn = bioplate.convert_template_reaction(model, rxnid, index, for_gapfilling=True) - -- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. -- *rxnid* ``str``: The ID for the reaction that will be reformatted. -- *index* ``int``: The index of a respective reactuin, which will be the suffix of the reformatted reaction ID and the constituent metabolite IDs. -- *for_gapfilling* ``bool``: specifies whether the reaction direction for gapfilling or not gapfilling is used in the formatted reaction. - -**returns** *rxn* ``cobra.core.model.Reaction``: The reformatted reaction for addition to a model template. - ----------------------- -Accessible content ----------------------- - -The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *compounds*, *compcompounds*, & *reactions* ``DictList``: The assemblies of base compounds, compartmentalized compounds, and reactions that were reformatted by the functions. +template +------------------- + ++++++++++++++++++++++ +Template() ++++++++++++++++++++++ + +This class reformats metabolites into compounds and reactions into an amenable format for templates: + +.. code-block:: python + + from modelseedpy.core import Template + bioplate = Template() + +------------------------------ +convert_template_compound() +------------------------------ + +A compound is reformatted for addition to a template: + +.. code-block:: python + + met = bioplate.convert_template_compound(cpdid, index) + +- *cpdid* ``cobra.core.model.Metabolite``: The compound that will be formatted for addition to a complate. +- *index* ``int``: The index of a respective compound, which will be the suffix of the reformatted compound ID. + +**returns** *met* ``cobra.core.model.Metabolite``: The reformatted compound for addition to a model template. + +-------------------------------- +convert_template_reaction() +-------------------------------- + +A reaction is reformatted for addition to a template: + +.. code-block:: python + + rxn = bioplate.convert_template_reaction(model, rxnid, index, for_gapfilling=True) + +- *model* ``cobra.core.model.Model``: The COBRA model that contains the reactions which are to be reformatted for the template. +- *rxnid* ``str``: The ID for the reaction that will be reformatted. +- *index* ``int``: The index of a respective reactuin, which will be the suffix of the reformatted reaction ID and the constituent metabolite IDs. +- *for_gapfilling* ``bool``: specifies whether the reaction direction for gapfilling or not gapfilling is used in the formatted reaction. + +**returns** *rxn* ``cobra.core.model.Reaction``: The reformatted reaction for addition to a model template. + +---------------------- +Accessible content +---------------------- + +The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *compounds*, *compcompounds*, & *reactions* ``DictList``: The assemblies of base compounds, compartmentalized compounds, and reactions that were reformatted by the functions. diff --git a/docs/source/fbapkg/bilevel_api.rst b/docs/source/fbapkg/bilevel_api.rst index e242eca5..67aa594d 100644 --- a/docs/source/fbapkg/bilevel_api.rst +++ b/docs/source/fbapkg/bilevel_api.rst @@ -1,36 +1,36 @@ -Bilevel -------------------- - -+++++++++++++++++++++ -BilevelPkg() -+++++++++++++++++++++ - -This class applies constraints that consider bilevel interactions: - -.. code-block:: python - - from modelseedpy.fbapkg import BilevelPkg - bilevel = BilevelPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The constraints are applied to the model: - -.. code-block:: python - - bilevel.build_package(binary_variable_count = 0) - -- *binary_variable_count* ``int``: The quantity of binary variables that will be defined in the model, where ``0`` signifies that no binary variables will be created. - ----------------------- -Accessible content ----------------------- - -The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. +bilevel +------------------- + ++++++++++++++++++++++ +BilevelPkg() ++++++++++++++++++++++ + +This class applies constraints that consider bilevel interactions: + +.. code-block:: python + + from modelseedpy.fbapkg import BilevelPkg + bilevel = BilevelPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The constraints are applied to the model: + +.. code-block:: python + + bilevel.build_package(binary_variable_count = 0) + +- *binary_variable_count* ``int``: The quantity of binary variables that will be defined in the model, where ``0`` signifies that no binary variables will be created. + +---------------------- +Accessible content +---------------------- + +The ``BilevelPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. diff --git a/docs/source/fbapkg/chageoptpkg_api.rst b/docs/source/fbapkg/chageoptpkg_api.rst index 91ed2012..8a8dbdec 100644 --- a/docs/source/fbapkg/chageoptpkg_api.rst +++ b/docs/source/fbapkg/chageoptpkg_api.rst @@ -1,37 +1,37 @@ -Change optimum ---------------------- - -+++++++++++++++++++++ -ChangeOptPkg() -+++++++++++++++++++++ - -This class applies constraints that the objective function: - -.. code-block:: python - - from modelseedpy.fbapkg import ChangeOptPkg - bilevel = ChangeOptPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The constraints are applied to the model: - -.. code-block:: python - - bilevel.build_package(target_values = {}, build_objective = True) - -- *target_values* ``dict``: the collection of objective coefficients (the ``values`` within a ``objcoef`` key) for a set of reactions (``keys``). -- *build_objective* ``bool``: specifies whether the redefined objective is set to the model. - ----------------------- -Accessible content ----------------------- - -The ``ChangeOptPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. +changeoptpkg +--------------------- + ++++++++++++++++++++++ +ChangeOptPkg() ++++++++++++++++++++++ + +This class applies constraints that the objective function: + +.. code-block:: python + + from modelseedpy.fbapkg import ChangeOptPkg + bilevel = ChangeOptPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The constraints are applied to the model: + +.. code-block:: python + + bilevel.build_package(target_values = {}, build_objective = True) + +- *target_values* ``dict``: the collection of objective coefficients (the ``values`` within a ``objcoef`` key) for a set of reactions (``keys``). +- *build_objective* ``bool``: specifies whether the redefined objective is set to the model. + +---------------------- +Accessible content +---------------------- + +The ``ChangeOptPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. diff --git a/docs/source/community/commkineticpkg_api.rst b/docs/source/fbapkg/commkineticpkg_api.rst similarity index 96% rename from docs/source/community/commkineticpkg_api.rst rename to docs/source/fbapkg/commkineticpkg_api.rst index 44f9f404..06d55afe 100644 --- a/docs/source/community/commkineticpkg_api.rst +++ b/docs/source/fbapkg/commkineticpkg_api.rst @@ -1,37 +1,37 @@ -CommKinetic -------------------- - -+++++++++++++++++++++ -CommKineticPkg() -+++++++++++++++++++++ - -This class applies kinetic constraints to the individual growth rates of community members: - -.. code-block:: python - - from modelseedpy.community import CommKineticPkg - commkin = CommKineticPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The constraints are applied to the model: - -.. code-block:: python - - commkin.build_package(kinetic_coef, community_model = None) - -- *kinetic_coef* ``float``: the kinetic coefficient that will constrain the cross-feeding interactions amongst the community species. -- *community_model* ``float``: the ``MSCommunity`` model object that will be constrained, where ``None`` specifies the model from the initiation of this package. - ----------------------- -Accessible content ----------------------- - -The ``CommKineticPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is constrained. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. +commkineticpkg +------------------- + ++++++++++++++++++++++ +CommKineticPkg() ++++++++++++++++++++++ + +This class applies kinetic constraints to the individual growth rates of community members: + +.. code-block:: python + + from modelseedpy.community import CommKineticPkg + commkin = CommKineticPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The constraints are applied to the model: + +.. code-block:: python + + commkin.build_package(kinetic_coef, community_model = None) + +- *kinetic_coef* ``float``: the kinetic coefficient that will constrain the cross-feeding interactions amongst the community species. +- *community_model* ``float``: the ``MSCommunity`` model object that will be constrained, where ``None`` specifies the model from the initiation of this package. + +---------------------- +Accessible content +---------------------- + +The ``CommKineticPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is constrained. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. diff --git a/docs/source/fbapkg/drainfluxes_api.rst b/docs/source/fbapkg/drainfluxes_api.rst index bcafa76e..f85a58b8 100644 --- a/docs/source/fbapkg/drainfluxes_api.rst +++ b/docs/source/fbapkg/drainfluxes_api.rst @@ -1,49 +1,49 @@ -Drain fluxes -------------------- - -+++++++++++++++++++++ -DrainFluxPkg() -+++++++++++++++++++++ - -This class adds drain reactions for each specified drain compound: - -.. code-block:: python - - from modelseedpy.fbapkg import DrainFluxPkg - drainflux = DrainFluxPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be expanded with drain reactions. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The drain reactions are created through this function: - -.. code-block:: python - - drainflux.build_package(parameters) - -- *parameters* ``dict``: The parameters that govern how the drain reactions will be created and implemented into the model. The default dictionary - -.. code-block:: json - - { - "add_all_intracellular_drains":false, - "default_uptake":0, - "default_excretion":100, - "drain_compounds":{}, - "set_minimal_drain_objective":false, - "update_drain_fluxes":false - } - -can be supplanted in the ``parameters`` argument by listing the ``key`` to be changed with the new ``value``. - ----------------------- -Accessible content ----------------------- - -The ``DrainFluxPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. +drainfluxpkg +------------------- + ++++++++++++++++++++++ +DrainFluxPkg() ++++++++++++++++++++++ + +This class adds drain reactions for each specified drain compound: + +.. code-block:: python + + from modelseedpy.fbapkg import DrainFluxPkg + drainflux = DrainFluxPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be expanded with drain reactions. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The drain reactions are created through this function: + +.. code-block:: python + + drainflux.build_package(parameters) + +- *parameters* ``dict``: The parameters that govern how the drain reactions will be created and implemented into the model. The default dictionary + +.. code-block:: json + + { + "add_all_intracellular_drains":false, + "default_uptake":0, + "default_excretion":100, + "drain_compounds":{}, + "set_minimal_drain_objective":false, + "update_drain_fluxes":false + } + +can be supplanted in the ``parameters`` argument by listing the ``key`` to be changed with the new ``value``. + +---------------------- +Accessible content +---------------------- + +The ``DrainFluxPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. diff --git a/docs/source/fbapkg/elementuptakepkg_api.rst b/docs/source/fbapkg/elementuptakepkg_api.rst index 4050aa35..19862f4e 100644 --- a/docs/source/fbapkg/elementuptakepkg_api.rst +++ b/docs/source/fbapkg/elementuptakepkg_api.rst @@ -1,36 +1,36 @@ -Elemental Uptake ------------------------ - -+++++++++++++++++++++ -ElementUptakePkg() -+++++++++++++++++++++ - -This class applies constraints of elemental consumption to the nutrient intake, which can influence cross-feeding interactions within a community: - -.. code-block:: python - - from modelseedpy.community import ElementUptakePkg - eleup = ElementUptakePkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The uptake constraints are applied to the model: - -.. code-block:: python - - eleup.build_package(element_limits) - -- *element_limits* ``dict``: a dictionary of the uptake limits (``values``) for each elemental symbol (``keys``). - ----------------------- -Accessible content ----------------------- - -The ``ElementUptakePkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. +elementuptakepkg +----------------------- + ++++++++++++++++++++++ +ElementUptakePkg() ++++++++++++++++++++++ + +This class applies constraints of elemental consumption to the nutrient intake, which can influence cross-feeding interactions within a community: + +.. code-block:: python + + from modelseedpy.community import ElementUptakePkg + eleup = ElementUptakePkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The uptake constraints are applied to the model: + +.. code-block:: python + + eleup.build_package(element_limits) + +- *element_limits* ``dict``: a dictionary of the uptake limits (``values``) for each elemental symbol (``keys``). + +---------------------- +Accessible content +---------------------- + +The ``ElementUptakePkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively. diff --git a/docs/source/fbapkg/fbapkg_index.rst b/docs/source/fbapkg/fbapkg_index.rst deleted file mode 100644 index 765aa9d6..00000000 --- a/docs/source/fbapkg/fbapkg_index.rst +++ /dev/null @@ -1,43 +0,0 @@ -fbapkg -________________________________________________________________________ - -|PyPI version| |License| |Downloads| - -.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen - :target: https://pypi.org/project/modelseedpy/ - :alt: PyPI version - -.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg - :target: https://github.com/freiburgermsu/modelseedpy/actions - :alt: Actions Status - -.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg - :target: https://opensource.org/licenses/MIT - :alt: License - -.. |Downloads| image:: https://pepy.tech/badge/modelseedpy - :target: https://pepy.tech/project/modelseedpy - :alt: Downloads - - -The collection of packages that constrain and investigate, e.g. dFBA, metabolic models are assembled into the ``fbapkg`` directory of ModelSEEDpy. These packages are imported:: - - from modelseedpy.fbapkg import * - - -and include the following: - -.. toctree:: - - bilevel_api - changeoptpkg_api - drainfluxes_api - elementuptakepkg_api - flexiblebiomass_api - fluxfitting_api - gapfillingpkg_api - kbasemedia_api - metabofba_api - proteomefitting_api - reactionuse_api - tfa_api diff --git a/docs/source/fbapkg/flexiblebiomass_api.rst b/docs/source/fbapkg/flexiblebiomass_api.rst index d83a6073..354c6e71 100644 --- a/docs/source/fbapkg/flexiblebiomass_api.rst +++ b/docs/source/fbapkg/flexiblebiomass_api.rst @@ -1,48 +1,48 @@ -Flexible biomass --------------------------------------- - -+++++++++++++++++++++ -FlexibleBiomassPkg() -+++++++++++++++++++++ - -This class constrains metabolites of the biomass reaction and adjusts the objective values: - -.. code-block:: python - - from modelseedpy.fbapkg import FlexibleBiomassPkg - flexbio = FlexibleBiomassPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The drain reactions are created through this function: - -.. code-block:: python - - flexbio.build_package(parameters) - -- *parameters* ``dict``: The parameters that govern how the constraints be created and implemented into the model. The only require ``key:value`` entry is specifying the ``bio_rxn_id`` of the biomass reaction. The default dictionary - -.. code-block:: json - - { - "flex_coefficient":0.75, - "use_rna_class":[-0.75,0.75], - "use_dna_class":[-0.75,0.75], - "use_protein_class":[-0.75,0.75], - "use_energy_class":[-0.1,0.1], - } - -can be supplanted in the ``parameters`` argument by listing the ``key`` to be changed with the new ``value``. - ----------------------- -Accessible content ----------------------- - -The ``FlexibleBiomassPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +flexiblebiomass +-------------------------------------- + ++++++++++++++++++++++ +FlexibleBiomassPkg() ++++++++++++++++++++++ + +This class constrains metabolites of the biomass reaction and adjusts the objective values: + +.. code-block:: python + + from modelseedpy.fbapkg import FlexibleBiomassPkg + flexbio = FlexibleBiomassPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The drain reactions are created through this function: + +.. code-block:: python + + flexbio.build_package(parameters) + +- *parameters* ``dict``: The parameters that govern how the constraints be created and implemented into the model. The only require ``key:value`` entry is specifying the ``bio_rxn_id`` of the biomass reaction. The default dictionary + +.. code-block:: json + + { + "flex_coefficient":0.75, + "use_rna_class":[-0.75,0.75], + "use_dna_class":[-0.75,0.75], + "use_protein_class":[-0.75,0.75], + "use_energy_class":[-0.1,0.1], + } + +can be supplanted in the ``parameters`` argument by listing the ``key`` to be changed with the new ``value``. + +---------------------- +Accessible content +---------------------- + +The ``FlexibleBiomassPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. diff --git a/docs/source/fbapkg/fluxfitting_api.rst b/docs/source/fbapkg/fluxfitting_api.rst index f0d641eb..9c32e5a1 100644 --- a/docs/source/fbapkg/fluxfitting_api.rst +++ b/docs/source/fbapkg/fluxfitting_api.rst @@ -1,49 +1,49 @@ -Flux fitting --------------------------------------- - -+++++++++++++++++++++ -FluxFittingPkg() -+++++++++++++++++++++ - -This class constrains metabolites of the biomass reaction and adjusts the objective values: - -.. code-block:: python - - from modelseedpy.fbapkg import FluxFittingPkg - flexbio = FluxFittingPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The drain reactions are created through this function: - -.. code-block:: python - - flexbio.build_package(parameters) - -- *parameters* ``dict``: The parameters that govern how the constraints will be created and implemented into the model. The default dictionary - -.. code-block:: json - - { - "target_flux":{}, - "totalflux":0, - "set_objective":1, - "default_rescaling":0.1, - "rescale_vfit_by_flux":true - } - -can be supplanted in the ``parameters`` argument by listing the ``key`` to be changed with the new ``value``. The ``target_flux`` sub-dictionary specifies the fluxes (``values``) for each reaction ID (``keys``) that will be constrained through this package. - ----------------------- -Accessible content ----------------------- - -The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. +fluxfittingpkg +-------------------------------------- + ++++++++++++++++++++++ +FluxFittingPkg() ++++++++++++++++++++++ + +This class constrains metabolites of the biomass reaction and adjusts the objective values: + +.. code-block:: python + + from modelseedpy.fbapkg import FluxFittingPkg + flexbio = FluxFittingPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The drain reactions are created through this function: + +.. code-block:: python + + flexbio.build_package(parameters) + +- *parameters* ``dict``: The parameters that govern how the constraints will be created and implemented into the model. The default dictionary + +.. code-block:: json + + { + "target_flux":{}, + "totalflux":0, + "set_objective":1, + "default_rescaling":0.1, + "rescale_vfit_by_flux":true + } + +can be supplanted in the ``parameters`` argument by listing the ``key`` to be changed with the new ``value``. The ``target_flux`` sub-dictionary specifies the fluxes (``values``) for each reaction ID (``keys``) that will be constrained through this package. + +---------------------- +Accessible content +---------------------- + +The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. diff --git a/docs/source/fbapkg/gapfillingpkg_api.rst b/docs/source/fbapkg/gapfillingpkg_api.rst index 3cd3e1d2..f4e43ef7 100644 --- a/docs/source/fbapkg/gapfillingpkg_api.rst +++ b/docs/source/fbapkg/gapfillingpkg_api.rst @@ -1,164 +1,164 @@ -GapFilling Package --------------------------------------- - -+++++++++++++++++++++ -GapfillingPkg() -+++++++++++++++++++++ - -This class constrains the sum progressions of sets of reactions: - -.. code-block:: python - - from modelseedpy.fbapkg import ReactionUsePkg - gapfill = GapfillingPkg(model) - -- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build() ----------------------- - -The model is gapfilled with default parameters - -.. code-block:: json - - { - "gapfill_all_indecies_with_default_templates": 1, - "set_objective": 1 - } - -and specifications of the template and the minimum objective value: - -.. code-block:: python - - gapfill.build(template, minimum_objective=0.01) - -- *template* ``list``: The collection of templates that will be used to gap-fill the model. -- *minimum_objective* ``float``: The minimum permissible objective value. - ----------------------- -build_package() ----------------------- - -The model is gapfilled: - -.. code-block:: python - - gapfill.build_package(parameters) - -- *parameters* ``dict``: The parameters that will supplant default values - -.. code-block:: json - - { - "auto_sink": ["cpd02701", "cpd11416", "cpd15302"], - "extend_with_template":1, - "model_penalty":1, - "default_gapfill_models":[], - "default_gapfill_templates":[], - "gapfill_templates_by_index":{}, - "gapfill_models_by_index":{}, - "reaction_scores":{}, - "gapfill_all_indecies_with_default_templates":1, - "gapfill_all_indecies_with_default_models":1, - "default_excretion":100, - "default_uptake":-100, - "minimum_obj":0.01, - "set_objective":1, - "blacklist":"default_blacklist" - } - -where the ``default_blacklist`` value is a list of approximately 100 reaction IDs that will not be included while gapfilling. - ----------------------------------------------- -extend_model_with_model_for_gapfilling() ----------------------------------------------- - -The reactions and metabolites from a source COBRA model are introduced to the autosink and exchange reactions of the model that is initiated by this class: - -.. code-block:: python - - gapfill.extend_model_with_model_for_gapfilling(source_model, index) - -- *source_model* ``cobra.core.model.Model``: The COBRA model whose reactions and metabolites will be imposed in the initiated model of the class. -- *index* ``int``: The number that corresponds with the species, which is relevant for distinguishing species in a community model. - ----------------------------------------------- -extend_model_with_template_for_gapfilling() ----------------------------------------------- - -Adds new reactions and metabolites from a template to the exchange reactions of the model that is initiated by this class: - -.. code-block:: python - - gapfill.extend_model_with_template_for_gapfilling(template, index) - -- *template* ``modelseedpy.core.mstemplate.MSTemplateBuilder``: The templates that will be used to gap-fill the model. -- *index* ``int``: The number that corresponds with the species, which is relevant for distinguishing species in a community model. - - ----------------------------------------------- -binary_check_gapfilling_solution() ----------------------------------------------- - -Redefining the objective to the minimum sum of the reaction fluxes that are in the parameterized COBRA solution: - -.. code-block:: python - - check_solution = gapfill.binary_check_gapfilling_solution(solution=None, flux_values=None) - -- *solution* ``cobra.core.solution.Solution``: The FBA solution from a simulation of the respective model. -- *flux_values* ``dict``: The forward and reverse fluxes (``values``) are stored within "forward" and "reverse" keys for the IDs of all reactions (``keys``). - -**Returns** *check_solution* ``dict``: The collection of "<" or ">" directions for all reversed reactions in the model that are described with gapfilling penalties. - ----------------------------------------------- -run_test_conditions() ----------------------------------------------- - -Redefining the objective to the minimum sum of the reaction fluxes that are in the parameterized COBRA solution: - -.. code-block:: python - - gapfill.run_test_conditions(condition_list, solution = None, max_iterations = 10) - -- *condition_list* ``list``: A list of simulation conditions that will be each be examined during the simulation. -- *solution* ``cobra.core.solution.Solution``: The COBRA solution that contains the reactions that will be examined in simulations for all conditions. -- *max_iterations* ``int``: The number of iterations through which the solution and conditions will be examined. - - ----------------------------------------------- -filter_database_based_on_tests() ----------------------------------------------- - -Silencing reactions that have associated gapfilling penalties: - -.. code-block:: python - - gapfill.run_test_conditions(condition_list) - -- *condition_list* ``list``: A list of simulation conditions that are examined during the simulation to acquire the list of reactions to be silenced. - - ----------------------------------------------- -filter_database_based_on_tests() ----------------------------------------------- - -Silencing reactions that have associated gapfilling penalties: - -.. code-block:: python - - gapfill.run_test_conditions(condition_list) - -- *condition_list* ``list``: A list of simulation conditions that are examined during the simulation to acquire the list of reactions to be silenced. - ----------------------- -Accessible content ----------------------- - -The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. -- *gapfilling_penalties* ``dict``: A dictionary -- *new_metabolites* & *new_reactions* ``dict``: Dictionaries of metabolite and reaction COBRA objects (``values``) for all metabolite and reaction IDs (``keys``) that were added to the model. +gapfillingpkg +-------------------------------------- + ++++++++++++++++++++++ +GapfillingPkg() ++++++++++++++++++++++ + +This class constrains the sum progressions of sets of reactions: + +.. code-block:: python + + from modelseedpy.fbapkg import ReactionUsePkg + gapfill = GapfillingPkg(model) + +- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build() +---------------------- + +The model is gapfilled with default parameters + +.. code-block:: json + + { + "gapfill_all_indecies_with_default_templates": 1, + "set_objective": 1 + } + +and specifications of the template and the minimum objective value: + +.. code-block:: python + + gapfill.build(template, minimum_objective=0.01) + +- *template* ``list``: The collection of templates that will be used to gap-fill the model. +- *minimum_objective* ``float``: The minimum permissible objective value. + +---------------------- +build_package() +---------------------- + +The model is gapfilled: + +.. code-block:: python + + gapfill.build_package(parameters) + +- *parameters* ``dict``: The parameters that will supplant default values + +.. code-block:: json + + { + "auto_sink": ["cpd02701", "cpd11416", "cpd15302"], + "extend_with_template":1, + "model_penalty":1, + "default_gapfill_models":[], + "default_gapfill_templates":[], + "gapfill_templates_by_index":{}, + "gapfill_models_by_index":{}, + "reaction_scores":{}, + "gapfill_all_indecies_with_default_templates":1, + "gapfill_all_indecies_with_default_models":1, + "default_excretion":100, + "default_uptake":-100, + "minimum_obj":0.01, + "set_objective":1, + "blacklist":"default_blacklist" + } + +where the ``default_blacklist`` value is a list of approximately 100 reaction IDs that will not be included while gapfilling. + +---------------------------------------------- +extend_model_with_model_for_gapfilling() +---------------------------------------------- + +The reactions and metabolites from a source COBRA model are introduced to the autosink and exchange reactions of the model that is initiated by this class: + +.. code-block:: python + + gapfill.extend_model_with_model_for_gapfilling(source_model, index) + +- *source_model* ``cobra.core.model.Model``: The COBRA model whose reactions and metabolites will be imposed in the initiated model of the class. +- *index* ``int``: The number that corresponds with the species, which is relevant for distinguishing species in a community model. + +---------------------------------------------- +extend_model_with_template_for_gapfilling() +---------------------------------------------- + +Adds new reactions and metabolites from a template to the exchange reactions of the model that is initiated by this class: + +.. code-block:: python + + gapfill.extend_model_with_template_for_gapfilling(template, index) + +- *template* ``modelseedpy.core.mstemplate.MSTemplateBuilder``: The templates that will be used to gap-fill the model. +- *index* ``int``: The number that corresponds with the species, which is relevant for distinguishing species in a community model. + + +---------------------------------------------- +binary_check_gapfilling_solution() +---------------------------------------------- + +Redefining the objective to the minimum sum of the reaction fluxes that are in the parameterized COBRA solution: + +.. code-block:: python + + check_solution = gapfill.binary_check_gapfilling_solution(solution=None, flux_values=None) + +- *solution* ``cobra.core.solution.Solution``: The FBA solution from a simulation of the respective model. +- *flux_values* ``dict``: The forward and reverse fluxes (``values``) are stored within "forward" and "reverse" keys for the IDs of all reactions (``keys``). + +**Returns** *check_solution* ``dict``: The collection of "<" or ">" directions for all reversed reactions in the model that are described with gapfilling penalties. + +---------------------------------------------- +run_test_conditions() +---------------------------------------------- + +Redefining the objective to the minimum sum of the reaction fluxes that are in the parameterized COBRA solution: + +.. code-block:: python + + gapfill.run_test_conditions(condition_list, solution = None, max_iterations = 10) + +- *condition_list* ``list``: A list of simulation conditions that will be each be examined during the simulation. +- *solution* ``cobra.core.solution.Solution``: The COBRA solution that contains the reactions that will be examined in simulations for all conditions. +- *max_iterations* ``int``: The number of iterations through which the solution and conditions will be examined. + + +---------------------------------------------- +filter_database_based_on_tests() +---------------------------------------------- + +Silencing reactions that have associated gapfilling penalties: + +.. code-block:: python + + gapfill.run_test_conditions(condition_list) + +- *condition_list* ``list``: A list of simulation conditions that are examined during the simulation to acquire the list of reactions to be silenced. + + +---------------------------------------------- +filter_database_based_on_tests() +---------------------------------------------- + +Silencing reactions that have associated gapfilling penalties: + +.. code-block:: python + + gapfill.run_test_conditions(condition_list) + +- *condition_list* ``list``: A list of simulation conditions that are examined during the simulation to acquire the list of reactions to be silenced. + +---------------------- +Accessible content +---------------------- + +The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +- *gapfilling_penalties* ``dict``: A dictionary +- *new_metabolites* & *new_reactions* ``dict``: Dictionaries of metabolite and reaction COBRA objects (``values``) for all metabolite and reaction IDs (``keys``) that were added to the model. diff --git a/docs/source/fbapkg/kbasemedia_api.rst b/docs/source/fbapkg/kbasemedia_api.rst index b690c024..90b81dfd 100644 --- a/docs/source/fbapkg/kbasemedia_api.rst +++ b/docs/source/fbapkg/kbasemedia_api.rst @@ -1,48 +1,48 @@ -KBase Media Package --------------------------------------- - -+++++++++++++++++++++ -KBaseMediaPkg() -+++++++++++++++++++++ - -This class constrains exchange reactions and media compounds: - -.. code-block:: python - - from modelseedpy.fbapkg import KBaseMediaPkg - kbmedia = KBaseMediaPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be edited. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The drain reactions are created through this function: - -.. code-block:: python - - kbmedia.build_package(media_or_parameters, default_uptake=None, default_excretion=None) - -- *media_or_parameters* ``dict | cobrakbase.core.kbasebiochem.media.Media``: The parameters that govern flux bounds of the exchange reactions, or the media that will be simulated with the specified model. The default parameters - -.. code-block:: json - - { - "default_uptake": 0, - "default_excretion": 100, - "media": null - } - -can be supplanted in the ``parameters`` argument by replacing the ``value`` of each ``key``. - ----------------------- -Accessible content ----------------------- - -The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. -- *modelutl* ``modelseedpy.core.msmodelutl.MSModelUtil``: A utilities class that converts between COBRA and CobraKBase nomenclature and performs helpful tasks. +KBasemediapkg +-------------------------------------- + ++++++++++++++++++++++ +KBaseMediaPkg() ++++++++++++++++++++++ + +This class constrains exchange reactions and media compounds: + +.. code-block:: python + + from modelseedpy.fbapkg import KBaseMediaPkg + kbmedia = KBaseMediaPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be edited. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The drain reactions are created through this function: + +.. code-block:: python + + kbmedia.build_package(media_or_parameters, default_uptake=None, default_excretion=None) + +- *media_or_parameters* ``dict | cobrakbase.core.kbasebiochem.media.Media``: The parameters that govern flux bounds of the exchange reactions, or the media that will be simulated with the specified model. The default parameters + +.. code-block:: json + + { + "default_uptake": 0, + "default_excretion": 100, + "media": null + } + +can be supplanted in the ``parameters`` argument by replacing the ``value`` of each ``key``. + +---------------------- +Accessible content +---------------------- + +The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. +- *modelutl* ``modelseedpy.core.msmodelutl.MSModelUtil``: A utilities class that converts between COBRA and CobraKBase nomenclature and performs helpful tasks. diff --git a/docs/source/fbapkg/metabofba_api.rst b/docs/source/fbapkg/metabofba_api.rst index e41418d6..c3d52f93 100644 --- a/docs/source/fbapkg/metabofba_api.rst +++ b/docs/source/fbapkg/metabofba_api.rst @@ -1,45 +1,45 @@ -Metabolite FBA --------------------------------------- - -+++++++++++++++++++++ -MetaboFBAPkg() -+++++++++++++++++++++ - -This class constrains metabolites in the parameterized peaks to zero and adds simple thermodynamic constraints: - -.. code-block:: python - - from modelseedpy.fbapkg import MetaboFBAPkg - metFBA = MetaboFBAPkg(model) - -- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The COBRA metabolite object is constrained: - -.. code-block:: python - - metFBA.build_package(parameters) - -- *parameters* ``dict``: The parameters that will govern how the model is constrained, with a default entry - -.. code-block:: json - - { - "set_objective":true, - } - -and a required key of ``peaks`` whose value is a list of paek data that will be used to identify the metabolites that are constrained. - ----------------------- -Accessible content ----------------------- - -The ``MetaboFBAPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the MetaboFBAPkg package. +metaboFBApkg +-------------------------------------- + ++++++++++++++++++++++ +MetaboFBAPkg() ++++++++++++++++++++++ + +This class constrains metabolites in the parameterized peaks to zero and adds simple thermodynamic constraints: + +.. code-block:: python + + from modelseedpy.fbapkg import MetaboFBAPkg + metFBA = MetaboFBAPkg(model) + +- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The COBRA metabolite object is constrained: + +.. code-block:: python + + metFBA.build_package(parameters) + +- *parameters* ``dict``: The parameters that will govern how the model is constrained, with a default entry + +.. code-block:: json + + { + "set_objective":true, + } + +and a required key of ``peaks`` whose value is a list of paek data that will be used to identify the metabolites that are constrained. + +---------------------- +Accessible content +---------------------- + +The ``MetaboFBAPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the MetaboFBAPkg package. diff --git a/docs/source/fbapkg/proteomefitting_api.rst b/docs/source/fbapkg/proteomefitting_api.rst index 1b28cdb2..5f99b264 100644 --- a/docs/source/fbapkg/proteomefitting_api.rst +++ b/docs/source/fbapkg/proteomefitting_api.rst @@ -1,56 +1,56 @@ -Proteome Fitting Package --------------------------------------- - -+++++++++++++++++++++ -ProteomeFittingPkg() -+++++++++++++++++++++ - -This class constrains the sum progressions of sets of reactions: - -.. code-block:: python - - from modelseedpy.fbapkg import ProteomeFittingPkg - proteofit = ProteomeFittingPkg(model) - -- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The reactions that are defined in the protemoe are constrained and used to refine the objective: - -.. code-block:: python - - proteofit.build_package(parameters) - -- *parameters* ``dict``: The parameters that will supplant default values - -.. code-block:: json - - { - "flux_values":{}, - "kcat_values":{}, - "prot_coef" : 0.1, - "totalflux" : 1, - "kcat_coef" : 0.333, - "obj_kfit":1, - "obj_kvfit":1, - "obj_vfit":1, - "set_objective":1, - "rescale_vfit_by_flux":true, - "default_rescaling":0.1, - "default_expression":10 - } - -where keys of ``proteome`` and ``condition``, which lack default values, must be defined. - ----------------------- -Accessible content ----------------------- - -The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. +proteomefittingpkg +-------------------------------------- + ++++++++++++++++++++++ +ProteomeFittingPkg() ++++++++++++++++++++++ + +This class constrains the sum progressions of sets of reactions: + +.. code-block:: python + + from modelseedpy.fbapkg import ProteomeFittingPkg + proteofit = ProteomeFittingPkg(model) + +- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The reactions that are defined in the protemoe are constrained and used to refine the objective: + +.. code-block:: python + + proteofit.build_package(parameters) + +- *parameters* ``dict``: The parameters that will supplant default values + +.. code-block:: json + + { + "flux_values":{}, + "kcat_values":{}, + "prot_coef" : 0.1, + "totalflux" : 1, + "kcat_coef" : 0.333, + "obj_kfit":1, + "obj_kvfit":1, + "obj_vfit":1, + "set_objective":1, + "rescale_vfit_by_flux":true, + "default_rescaling":0.1, + "default_expression":10 + } + +where keys of ``proteome`` and ``condition``, which lack default values, must be defined. + +---------------------- +Accessible content +---------------------- + +The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. diff --git a/docs/source/fbapkg/reactionuse_api.rst b/docs/source/fbapkg/reactionuse_api.rst index 83a33e15..45036225 100644 --- a/docs/source/fbapkg/reactionuse_api.rst +++ b/docs/source/fbapkg/reactionuse_api.rst @@ -1,49 +1,49 @@ -Reaction Use Package --------------------------------------- - -+++++++++++++++++++++ -ReactionUsePkg() -+++++++++++++++++++++ - -This class constrains the sum progressions of sets of reactions: - -.. code-block:: python - - from modelseedpy.fbapkg import ReactionUsePkg - rxnuse = ReactionUsePkg(model) - -- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -The drain reactions are created through this function: - -.. code-block:: python - - rxnuse.build_package(rxn_filter = None, reversibility = 0) - -- *rxn_filter* ``dict``: The reaction directions (``values``) for all reaction IDs (``keys``) that will be constrained, where ``None`` signifies that all reactions will be constrained as equilibria. -- *reversibility* ``bool``: specifies whether the constrained reactions are reversible. - ----------------------------------- -build_exclusion_constraint() ----------------------------------- - -The drain reactions are created through this function: - -.. code-block:: python - - rxnuse.build_exclusion_constraint(flux_values = None) - -- *flux_values* ``dict``: A dictionary of the fluxes (``values``) for the reactions IDs (``keys``) that will be constrained, which determines whether the reaction proceeds forwards or backwards. The ``None`` value defaults to determining the fluxes for all reactions in the model. - ----------------------- -Accessible content ----------------------- - -The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: - -- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. +reactionusepkg +-------------------------------------- + ++++++++++++++++++++++ +ReactionUsePkg() ++++++++++++++++++++++ + +This class constrains the sum progressions of sets of reactions: + +.. code-block:: python + + from modelseedpy.fbapkg import ReactionUsePkg + rxnuse = ReactionUsePkg(model) + +- *model* ``cobra.core.model.Model``: The CobraKBase model that will be constrained. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +The drain reactions are created through this function: + +.. code-block:: python + + rxnuse.build_package(rxn_filter = None, reversibility = 0) + +- *rxn_filter* ``dict``: The reaction directions (``values``) for all reaction IDs (``keys``) that will be constrained, where ``None`` signifies that all reactions will be constrained as equilibria. +- *reversibility* ``bool``: specifies whether the constrained reactions are reversible. + +---------------------------------- +build_exclusion_constraint() +---------------------------------- + +The drain reactions are created through this function: + +.. code-block:: python + + rxnuse.build_exclusion_constraint(flux_values = None) + +- *flux_values* ``dict``: A dictionary of the fluxes (``values``) for the reactions IDs (``keys``) that will be constrained, which determines whether the reaction proceeds forwards or backwards. The ``None`` value defaults to determining the fluxes for all reactions in the model. + +---------------------- +Accessible content +---------------------- + +The ``FluxFittingPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting: + +- *model* ``cobra.core.model.Model``: The cobrakbase model that possesses the implemented drain reactions. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and simulation parameters, respectively. diff --git a/docs/source/fbapkg/tfa_api.rst b/docs/source/fbapkg/tfa_api.rst index 92d8e8f1..d700e854 100644 --- a/docs/source/fbapkg/tfa_api.rst +++ b/docs/source/fbapkg/tfa_api.rst @@ -1,85 +1,85 @@ -Full Thermo Package (TFA) ------------------------------ - -+++++++++++++++++++++ -FullThermoPkg() -+++++++++++++++++++++ - -This class applies and simulates rigorous thermodynamic constraints upon COBRA models: - -.. code-block:: python - - from modelseedpy.fbapkg import FullThermoPkg - tfa = FullThermoPkg(model) - -- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. - ----------------------- -build_package() ----------------------- - -A cobrakbase model is simulated with the parameterized kinetics data over the defined time and conditions: - -.. code-block:: python - - tfa.build_package(parameters, verbose = True) - -- *parameters* ``dict``: specifies simulations parameters in base metric units -- e.g. Molar, Kilojoules per mol, and Kelvins -- that are used to populate the FBA simulation. The default concentrations, - -.. code-block:: json - - { - "cpd00067_c0":[0.0000001,0.0000001], - "cpd00007_c0":[1E-07,8.2E-06], - "cpd00011_c0":[1E-08,0.0014], - "cpd00067_e0":[3.16228E-07,3.16228E-07], - "cpd00009_e0":[0.056,0.056], - "cpd00048_e0":[0.0030,0.0030], - "cpd00013_e0":[0.019,0.019], - "cpd00971_e0":[0.16,0.16], - "cpd00205_e0":[0.022,0.022], - "cpd10515_e0":[0.062,0.062], - "cpd00011_e0":[0.00010,0.00010], - "cpd00007_e0":[8.2E-06,8.2E-06], - "cpd00027_e0":[0.020,0.020] - } - -and compartment potentials (the extracellular environment is 0 by definition to facilitate community modeling), - -.. code-block:: json - - { - "e0":0, - "c0":-160 - } - -are supplanted by specified parameters - -.. code-block:: json - - { - "default_max_conc":0.02, - "default_min_conc":0.000001, - "default_max_error":5, - "custom_concentrations":{}, - "custom_deltaG_error":{}, - "compartment_potential":{}, - "temperature":298, - "filter":null, - "infeasible_model": false, - "dgbin":false - } - -that can be adjusted through the ``parameters`` argument. The only required key in ``parameters`` that must be provided by the user is the ``modelseed_db_path`` that enables the import of the ModelSEED Database. - -- *verbose* ``bool``: specifies whether simulation details and calculations will be printed, which is valuable for troubleshooting. - ----------------------- -Accessible content ----------------------- - -Several objects within the ``FullThermo`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: - -- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. -- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters. -- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. +fullthermopkg +----------------------------- + ++++++++++++++++++++++ +FullThermoPkg() ++++++++++++++++++++++ + +This class applies and simulates rigorous thermodynamic constraints upon COBRA models: + +.. code-block:: python + + from modelseedpy.fbapkg import FullThermoPkg + tfa = FullThermoPkg(model) + +- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models `_ to CobraKBase models is facilitated by the `cobrakbase` package. + +---------------------- +build_package() +---------------------- + +A cobrakbase model is simulated with the parameterized kinetics data over the defined time and conditions: + +.. code-block:: python + + tfa.build_package(parameters, verbose = True) + +- *parameters* ``dict``: specifies simulations parameters in base metric units -- e.g. Molar, Kilojoules per mol, and Kelvins -- that are used to populate the FBA simulation. The default concentrations, + +.. code-block:: json + + { + "cpd00067_c0":[0.0000001,0.0000001], + "cpd00007_c0":[1E-07,8.2E-06], + "cpd00011_c0":[1E-08,0.0014], + "cpd00067_e0":[3.16228E-07,3.16228E-07], + "cpd00009_e0":[0.056,0.056], + "cpd00048_e0":[0.0030,0.0030], + "cpd00013_e0":[0.019,0.019], + "cpd00971_e0":[0.16,0.16], + "cpd00205_e0":[0.022,0.022], + "cpd10515_e0":[0.062,0.062], + "cpd00011_e0":[0.00010,0.00010], + "cpd00007_e0":[8.2E-06,8.2E-06], + "cpd00027_e0":[0.020,0.020] + } + +and compartment potentials (the extracellular environment is 0 by definition to facilitate community modeling), + +.. code-block:: json + + { + "e0":0, + "c0":-160 + } + +are supplanted by specified parameters + +.. code-block:: json + + { + "default_max_conc":0.02, + "default_min_conc":0.000001, + "default_max_error":5, + "custom_concentrations":{}, + "custom_deltaG_error":{}, + "compartment_potential":{}, + "temperature":298, + "filter":null, + "infeasible_model": false, + "dgbin":false + } + +that can be adjusted through the ``parameters`` argument. The only required key in ``parameters`` that must be provided by the user is the ``modelseed_db_path`` that enables the import of the ModelSEED Database. + +- *verbose* ``bool``: specifies whether simulation details and calculations will be printed, which is valuable for troubleshooting. + +---------------------- +Accessible content +---------------------- + +Several objects within the ``FullThermo`` class may be useful for subsequent post-processing or troubleshooting of the simulation results: + +- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is simulated. +- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters. +- *pkgmgr* ``modelseedpy.fbapkg.mspackagemanager.MSPackageManager``: The collection of associated classes that are used in the FullThermo package. diff --git a/docs/source/gapfill.rst b/docs/source/gapfill.rst index e5eb5782..74f91085 100644 --- a/docs/source/gapfill.rst +++ b/docs/source/gapfill.rst @@ -1,6 +1,6 @@ -Gapfilling a Model -________________________________________________________________________ - -Constructed ``COBRAkbase`` models are gapfilled through the following sequence. - -1) +Gapfilling a Model +________________________________________________________________________ + +Constructed ``COBRAkbase`` models are gapfilled through the following sequence. + +1) diff --git a/docs/source/index.rst b/docs/source/index.rst index 4ebf46e5..f172fe4e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,59 +1,64 @@ -.. image:: https://raw.githubusercontent.com/freiburgermsu/modelseedpy/main/examples/ms-logo-horizontal.png?sanitize=true - -Metabolic modeling with the ModelSEED Database -________________________________________________________________________ - -|PyPI version| |Downloads| |License| - -.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/modelseedpy) - :target: https://pypi.org/project/modelseedpy/ - :alt: Python versions - -.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen - :target: https://pypi.org/project/modelseedpy/ - :alt: PyPI version - -.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg - :target: https://github.com/freiburgermsu/modelseedpy/actions - :alt: Actions Status - -.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg - :target: https://opensource.org/licenses/MIT - :alt: License - -.. |Downloads| image:: https://pepy.tech/badge/modelseedpy - :target: https://pepy.tech/project/modelseedpy - :alt: Downloads - -Metabolic modeling is an pivotal method for computational research in synthetic biology and precision medicine. The metabolic models, such as the constrint-based flux balance analysis (FBA) algorithm, are improved with comprehensive datasets that capture more metabolic chemistry in the model and improve the accuracy of simulation predictions. We therefore developed ModelSEEDpy as a comprehensive suite of packages that bootstrap metabolic modeling with the ModelSEED Database (`Seaver et al., 2021 `_ ). These packages parse and manipulate (e.g. gapfill missing reactions or calculated chemical properties of metabolites), constrain (with kinetic, thermodynamics, and nutrient uptake), and simulate cobrakbase models (both individual models and communities). This is achieved by standardizing COBRA models through the ``cobrakbase`` module into a form that is amenable with the KBase/ModelSEED ecosystem. These functionalities are exemplified in `Python Notebooks `_ . Please submit errors, inquiries, or suggestions as `GitHub issues `_ where they can be addressed by our developers. - - -.. note:: - - This project is under active development, and may be subject to losing back-compatibility. - ----------------------- -Installation ----------------------- - -ModelSEEDpy can be installed via ``pip`` through the ``PyPI`` channel:: - - pip install modelseedpy - -The associated ModelSEED Database, which is required for a few packages, is simply downloaded by cloning the GitHub repository:: - - git clone https://github.com/ModelSEED/ModelSEEDDatabase.git - -and the path to this repository is passed as an argument to the corresponding packages. - -**Windows users** must separately install the ``pyeda`` module: 1) download the appropriate wheel for your Python version from `this website `_ ; and 2) install the wheel through the following commands in a command prompt/powershell console:: - - cd path/to/pyeda/wheel - pip install pyeda_wheel_name.whl - - -.. toctree:: - :hidden: - - simulate - api +.. image:: https://raw.githubusercontent.com/freiburgermsu/modelseedpy/main/examples/ms-logo-horizontal.png?sanitize=true + +Metabolic modeling with the ModelSEED Database +________________________________________________________________________ + +|PyPI version| |Downloads| |License| + +.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/modelseedpy) + :target: https://pypi.org/project/modelseedpy/ + :alt: Python versions + +.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen + :target: https://pypi.org/project/modelseedpy/ + :alt: PyPI version + +.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg + :target: https://github.com/freiburgermsu/modelseedpy/actions + :alt: Actions Status + +.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg + :target: https://opensource.org/licenses/MIT + :alt: License + +.. |Downloads| image:: https://pepy.tech/badge/modelseedpy + :target: https://pepy.tech/project/modelseedpy + :alt: Downloads + +Metabolic modeling is an pivotal method for computational research in synthetic biology and precision medicine. The metabolic models, such as the constrint-based flux balance analysis (FBA) algorithm, are improved with comprehensive datasets that capture more metabolic chemistry in the model and improve the accuracy of simulation predictions. We therefore developed ModelSEEDpy as a comprehensive suite of packages that bootstrap metabolic modeling with the ModelSEED Database (`Seaver et al., 2021 `_ ). These packages parse and manipulate (e.g. gapfill missing reactions or calculated chemical properties of metabolites), constrain (with kinetic, thermodynamics, and nutrient uptake), and simulate cobrakbase models (both individual models and communities). This is achieved by standardizing COBRA models through the ``cobrakbase`` module into a form that is amenable with the KBase/ModelSEED ecosystem. These functionalities are exemplified in `Python Notebooks `_ . Please submit errors, inquiries, or suggestions as `GitHub issues `_ where they can be addressed by our developers. + + +.. note:: + + This project is under active development, and may be subject to losing back-compatibility. + +---------------------- +Installation +---------------------- + +ModelSEEDpy can be installed via ``pip`` through the ``PyPI`` channel:: + + pip install modelseedpy + +The associated ModelSEED Database, which is required for a few packages, is simply downloaded by cloning the GitHub repository:: + + git clone https://github.com/ModelSEED/ModelSEEDDatabase.git + +and the path to this repository is passed as an argument to the corresponding packages. + +**Windows users** must separately install the ``pyeda`` module: 1) download the appropriate wheel for your Python version from `this website `_ ; and 2) install the wheel through the following commands in a command prompt/powershell console:: + + cd path/to/pyeda/wheel + pip install pyeda_wheel_name.whl + + +.. toctree:: + :hidden: + + model_reconstruction/index + simulate + escher/Index + kbase/Index + others/Index + webinars + api diff --git a/docs/source/ml/ml_index.rst b/docs/source/ml/ml_index.rst deleted file mode 100644 index 4d22c133..00000000 --- a/docs/source/ml/ml_index.rst +++ /dev/null @@ -1,30 +0,0 @@ -ml -________________________________________________________________________ - -|PyPI version| |License| |Downloads| - -.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen - :target: https://pypi.org/project/modelseedpy/ - :alt: PyPI version - -.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg - :target: https://github.com/freiburgermsu/modelseedpy/actions - :alt: Actions Status - -.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg - :target: https://opensource.org/licenses/MIT - :alt: License - -.. |Downloads| image:: https://pepy.tech/badge/modelseedpy - :target: https://pepy.tech/project/modelseedpy - :alt: Downloads - -These packages are imported via:: - - from modelseedpy.ml import * - -and include the following - -.. toctree:: - - predict_phenotypes_api diff --git a/docs/source/ml/predict_phenotypes_api.rst b/docs/source/ml/predict_phenotypes_api.rst index 9684ba36..a70c0dca 100644 --- a/docs/source/ml/predict_phenotypes_api.rst +++ b/docs/source/ml/predict_phenotypes_api.rst @@ -1,62 +1,62 @@ -Predict Phenotype functions --------------------------------------- - -------------------------------------------- -get_functional_roles() -------------------------------------------- - -A function that determines the set of genome feature that match the parameterized ontological term: - -.. code-block:: python - - roles = get_functional_roles(genome, ontology_term) - -- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. -- *ontology_term* ``str``: The ontological criteria that will assess the genome. - -**returns** *roles* ``set``: The set of genome features that match the parameterized ontological term. - -------------------------------------------- -get_list_functional_roles_from_kbase() -------------------------------------------- - -A function that determines the set of genome feature that match the parameterized ontological term: - -.. code-block:: python - - roles = get_list_functional_roles_from_kbase(genome_ref, ws_client) - -- *genome_ref* ``str``: The KBase genome reference that is used to extract content from a respective KBase workspace. -- *ws_client* ``KBase object``: The KBase client that is used to acquire the genome from the KBase workspace. - -**returns** *list_functional_roles* ``list``: The list of functional roles in the loaded genome. - -------------------------------------------- -extract_features_from_genome() -------------------------------------------- - -A function that assembles a unique list of features for the specified genome: - -.. code-block:: python - - genome_features = genclass.extract_features_from_genome(genome, ontology_term) - -- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. -- *ontology_term* ``str``: The ontological criteria that will assess the genome. - -**returns** *genome_features* ``dict``: A list of genome features ``value`` with the key of ``"genome"``. - ------------------- -classify() ------------------- - -A function that predicts FBA solutions based upon a set of genome features and indicators: - -.. code-block:: python - - media = genclass.classify(genome, ontology_term='RAST') - -- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. -- *ontology_term* ``str``: The ontological criteria that will assess the genome. - -**returns** *prediction* ``str``: The numerical prediction of the model based upon the set of genome features and indicators. +predict_phenotype functions +-------------------------------------- + +------------------------------------------- +get_functional_roles() +------------------------------------------- + +A function that determines the set of genome feature that match the parameterized ontological term: + +.. code-block:: python + + roles = get_functional_roles(genome, ontology_term) + +- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. +- *ontology_term* ``str``: The ontological criteria that will assess the genome. + +**returns** *roles* ``set``: The set of genome features that match the parameterized ontological term. + +------------------------------------------- +get_list_functional_roles_from_kbase() +------------------------------------------- + +A function that determines the set of genome feature that match the parameterized ontological term: + +.. code-block:: python + + roles = get_list_functional_roles_from_kbase(genome_ref, ws_client) + +- *genome_ref* ``str``: The KBase genome reference that is used to extract content from a respective KBase workspace. +- *ws_client* ``KBase object``: The KBase client that is used to acquire the genome from the KBase workspace. + +**returns** *list_functional_roles* ``list``: The list of functional roles in the loaded genome. + +------------------------------------------- +extract_features_from_genome() +------------------------------------------- + +A function that assembles a unique list of features for the specified genome: + +.. code-block:: python + + genome_features = genclass.extract_features_from_genome(genome, ontology_term) + +- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. +- *ontology_term* ``str``: The ontological criteria that will assess the genome. + +**returns** *genome_features* ``dict``: A list of genome features ``value`` with the key of ``"genome"``. + +------------------ +classify() +------------------ + +A function that predicts FBA solutions based upon a set of genome features and indicators: + +.. code-block:: python + + media = genclass.classify(genome, ontology_term='RAST') + +- *genome* ``ModelSEED Genome``: The ModelSEED Genome that will be classified. +- *ontology_term* ``str``: The ontological criteria that will assess the genome. + +**returns** *prediction* ``str``: The numerical prediction of the model based upon the set of genome features and indicators. diff --git a/docs/source/simulate.rst b/docs/source/simulate.rst index 128e91ec..648074d9 100644 --- a/docs/source/simulate.rst +++ b/docs/source/simulate.rst @@ -1,101 +1,117 @@ -Simulating a Model -________________________________________________________________________ - -Complete ``COBRAkbase`` models can be simulated through a multitude of FBA methods, and a subset of community methods. Individual and community ``COBRAkbase`` models can initially be constrained for various biochemical and physical processes. - -++++++++++++ -Constraints -++++++++++++ - -Elemental uptake ---------------------- - -The total uptake of specific elements can be constrained through the ``ElementUptakePkg`` package: - -.. code-block:: python - - from modelseedpy.fbapkg import ElementUptakePkg - eleup = ElementUptakePkg(model) - eleup.build_package(element_limits) - -The package applies uptake limits for any elemental symbol (``values`` and ``keys`` of the ``element_limits`` dictionary, respectively) to a given model. - -Reaction Thermodynamics -------------------------- - -The thermodynamic free energy of each reaction, and variable formation energies of each metabolite, can be constrained through the ``FullThermoPkg`` package: - -.. code-block:: python - - from modelseedpy.fbapkg import FullThermoPkg - tfa = FullThermoPkg(model) - tfa.build_package(parameters) - -The package applies free energy constraints for all reactions in a given model, based upon the free energy data in the ModelSEED Database. The user must specify the ``"modelseed_db_path" `` in the argument (*parameters* ``dict``). The user is also able to redefine default values through *parameters*, which is detailed in the respective API documentation. - -Community member growth rates -------------------------------- - -The growth rate of community members can be constrained with a kinetic rate constant through the ``CommKineticPkg`` package: - -.. code-block:: python - - from modelseedpy.community import CommKineticPkg - commkin = CommKineticPkg(model) - commkin.build_package(kinetic_coef) - -The package applies the kinetic coefficient (*kinetic_coef* ``float``) to the biomass reaction of each species in a given community model. - - - -++++++++++++ -FBA Methods -++++++++++++ - -``COBRAkbase`` models, either with or without additional constraints, can be simulated through a few FBA processes. - -Bilevel ---------------------- - - - -reactionuse ---------------------- - - - -dFBA ---------------------- - - - -metabofba ---------------------- - - -+++++++++++++++++++ -Community Methods -+++++++++++++++++++ - -``COBRAkbase`` community models, either with or without additional constraints, can be simulated through a few packages. - -MSCommunity ---------------------- - -The ``MSCommunity`` package is an original package from ModelSEEDpy that resolves metabolite-level cross-feeding and provides a concise API for numerous constraints and FBA methods: - -.. code-block:: python - - from modelseedpy.community import MSCommunity - mscom = MSCommunity(model, names=[], abundances=None, pfba = True, lp_filename = None) - solution = mscom.run(media = None, pfba = True) - -A community COBRA model is passed to the package with a list of the community members, which are indexed sequentially according to their community number. The abundances of the community members can be provided in relative or absolute terms (``values`` & ``keys``, respectively, in *abdundances* ``dict``). The community can then be simulated in an arbitrary KBase media, where ``None`` specifies a complete media. - -Community cross-feeding is calculated through the ``compute_interactions`` interactions function: - -.. code-block:: python - - cross_feeding_df = mscom.compute_interactions(solution = None, threshold=1) - -An FBA solution, such as that from ``mscom.run``, is parsed to determine the cross-feeding interactions of the community that surpass a flux threshold (*threshold* ``int``). The function returns a `Pandas DataFrame `_ , which conveniently permits user manipulation of the data. +Simulating a Model +________________________________________________________________________ + +Complete ``COBRAkbase`` models can be simulated through a multitude of FBA methods, and a subset of community methods. Individual and community ``COBRAkbase`` models can initially be constrained for various biochemical and physical processes. + +++++++++++++ +Constraints +++++++++++++ + +Elemental uptake +--------------------- + +The total uptake of specific elements can be constrained through the ``ElementUptakePkg`` package: + +.. code-block:: python + + from modelseedpy.fbapkg import ElementUptakePkg + eleup = ElementUptakePkg(model) + eleup.build_package(element_limits) + +The package applies uptake limits for any elemental symbol (``values`` and ``keys`` of the ``element_limits`` dictionary, respectively) to a given model. + +Reaction Thermodynamics +------------------------- + +The thermodynamic free energy of each reaction, and variable formation energies of each metabolite, can be constrained through the ``FullThermoPkg`` package: + +.. code-block:: python + + from modelseedpy.fbapkg import FullThermoPkg + tfa = FullThermoPkg(model) + tfa.build_package(parameters) + +The package applies free energy constraints for all reactions in a given model, based upon the free energy data in the ModelSEED Database. The user must specify the ``"modelseed_db_path" `` in the argument (*parameters* ``dict``). The user is also able to redefine default values through *parameters*, which is detailed in the respective API documentation. + +An example of ``FullThermoPkg`` is available `here `_ . + +Community member growth rates +------------------------------- + +The growth rate of community members can be constrained with a kinetic rate constant through the ``CommKineticPkg`` package: + +.. code-block:: python + + from modelseedpy.community import CommKineticPkg + commkin = CommKineticPkg(model) + commkin.build_package(kinetic_coef) + +The package applies the kinetic coefficient (*kinetic_coef* ``float``) to the biomass reaction of each species in a given community model. + + + +++++++++++++ +FBA Methods +++++++++++++ + +``COBRAkbase`` models, either with or without additional constraints, can be simulated through a few FBA processes. A broad example of FBA in ModelSEEDpy is available `here `_ . + +Bilevel +--------------------- + + + +reactionuse +--------------------- + + + +dFBA +--------------------- + + + +metabofba +--------------------- + +The ``MetaboFBA`` Package forces flux through observed metabolites in metabolomics data. An example is available `here `_ . + + +Flexible Biomass +--------------------- + +The ``FlexibleBiomass`` Package enables the coefficients on a biomass reaction to vary. An example is available `here `_ . + + +Media Scan +--------------------- + +The ``Media Scan`` Package concisely tests numerous media for a single model. An example is available `here `_ . + + ++++++++++++++++++++ +Community Methods ++++++++++++++++++++ + +``COBRAkbase`` community models, either with or without additional constraints, can be simulated through a few packages. + +MSCommunity +--------------------- + +The ``MSCommunity`` package is an original package from ModelSEEDpy that resolves metabolite-level cross-feeding and provides a concise API for numerous constraints and FBA methods: + +.. code-block:: python + + from modelseedpy.community import MSCommunity + mscom = MSCommunity(model, names=[], abundances=None, pfba = True, lp_filename = None) + solution = mscom.run(media = None, pfba = True) + +A community COBRA model is passed to the package with a list of the community members, which are indexed sequentially according to their community number. The abundances of the community members can be provided in relative or absolute terms (``values`` & ``keys``, respectively, in *abdundances* ``dict``). The community can then be simulated in an arbitrary KBase media, where ``None`` specifies a complete media. + +Community cross-feeding is calculated through the ``compute_interactions`` interactions function: + +.. code-block:: python + + cross_feeding_df = mscom.compute_interactions(solution = None, threshold=1) + +An FBA solution, such as that from ``mscom.run``, is parsed to determine the cross-feeding interactions of the community that surpass a flux threshold (*threshold* ``int``). The function returns a `Pandas DataFrame `_ , which conveniently permits user manipulation of the data. diff --git a/docs/source/utilities.rst b/docs/source/utilities.rst index 91cf14d5..253a936b 100644 --- a/docs/source/utilities.rst +++ b/docs/source/utilities.rst @@ -1,12 +1,12 @@ -Building a Model -________________________________________________________________________ - -The detailed documentation of all user-operable classes and functions in the ModelSEEDpy library are provided. - -.. toctree:: - :hidden: - - contents - core/core_index - community/community_index - fbapkg/fbapkg_index +Building a Model +________________________________________________________________________ + +The detailed documentation of all user-operable classes and functions in the ModelSEEDpy library are provided. + +.. toctree:: + :hidden: + + contents + core/core_index + community/community_index + fbapkg/fbapkg_index diff --git a/docs/source/webinars.rst b/docs/source/webinars.rst index e69de29b..c2b10b4f 100644 --- a/docs/source/webinars.rst +++ b/docs/source/webinars.rst @@ -0,0 +1,11 @@ +Webinars +_________________________________________ + +Myriad tutorials for ModelSEEDpy and KBASE are located interspersed in the `KBase webinars `_ . + + +---------------- +Meet the Team +---------------- + +The leaders of the ModelSEED and KBase projects are `Chris S. Henry `_ and `Adam Arkin `_ , respectively.