PyCoMo Classes

Authors: Michael Predl, Marianne Mießkes The pycomo module contains classes for single species and community metabolic models. They extend the COBRApy classes by meta-information required for community model generation. The community model can be used for simulation, transferred via the sbml format, setting abundances and generation of FBA flux vector tables.

class pycomo.pycomo_models.CommunityModel(models=None, name='', merge_via_annotation=None, mu_c=1.0, max_flux=1000.0, shared_compartment_name='medium', **kwargs)

This class contains the community metabolic model and its meta information. It is used for generating the community metabolic model from its members models. It also provides functionality to analyse community metabolic models, such as detection of thermodynamically infeasible cycles and calculation of all possible exchanged metabolites. The community metabolic model can switch between two states: The fixed abundance state and the fixed growth rate state. These states are important for ensuring the model is in steady-state. Switching between the two states is possible at any point.

Parameters:
  • model – The community metabolic model

  • medium – The medium of the model, defined as a dictionary with exchange reaction IDs as keys and the maximum flux of the respective metabolite as value.

  • f_metabolites – A list of f_metabolites (dummy metabolites controlling the reaction bounds)

  • f_reactions – A list of f_reactions (dummy reactions controlling the reaction bounds)

  • member_models – A list of the models of the community members (SingleOrganismModel class)

  • name – The name of the community metabolic model

  • medium_flag – A flag whether a medium has been applied to the model

  • mu_c – The community growth rate

  • fixed_abundance_flag – A flag, whether the community metabolic model is in fixed abundance state

  • fixed_growth_rate_flag – A flag, whether the community metabolic model is in fixed growth rate state

  • max_flux – The maximum flux for all reactions in the community metabolic model

  • shared_compartment_name – The name of the compartment for sharing metabolites and the medium

add_sink_reactions_to_metabolites(model, constraint_mets, lb=0.0, inplace=True)

Adds sink reactions for dummy metabolites.

Parameters:
  • model – Model to be changed

  • constraint_mets – Metabolites where sink reactions should be added

  • lb – Lower bound of the sink reaction

  • inplace – If true, the input model is changed, otherwise a copy is created

Returns:

If the inplace flag is set to False, the updated model is returned

apply_fixed_abundance(abd_dict)

Applying fixed abundance to the model. This is only available if the model is in fixed abundance structure (check fixed_abundance_flag).

apply_fixed_growth_rate(flux, model=None)

Applies a new fixed growth rate to the model. The model needs to be in fixed growth state, to allow this operation.

Parameters:
  • flux – The new growth rate

  • model – The model to update

Returns:

The updated model

apply_medium(medium=None)

Applies the medium that is specified in the medium attribute to the community metabolic model

Parameters:

medium – Optional. A dictionary with exchange reaction IDs as keys and the maximum flux of the respective metabolite as value. If none is given, the medium in self.medium is applied.

Returns:

The updated model

change_reaction_bounds(reaction: str | Reaction, lower_bound, upper_bound)

This function allows changing reaction bounds in the community metabolic models. It takes care of adjusting the dummy metabolite stoichiometry.

Parameters:
  • reaction – The reaction whose bounds should be set

  • lower_bound – The new lower bound

  • upper_bound – The new upper bound

convert_constraints_to_metabolites(model, member_name)

This function creates dummy metabolites for the constraints of each reaction in a model. This method is used on the member metabolic models during community metabolic model generation.

Parameters:
  • model – Model to be changed

  • member_name – The name of the community member

Returns:

Dictionary of dummy metabolites (keys) and the bound they represent (values)

convert_to_fixed_abundance(abundance_dict=None)

This function changes the model structure to fixed abundance, but variable growth rate. The model is left unchanged if it is already in fixed abundance structure.

convert_to_fixed_growth_rate(mu_c=None)

This function changes the model structure to fixed growth rate, but variable abundance profile. The model is left unchanged if it is already in fixed abundance structure.

convert_to_model_without_fraction_metabolites()

Converts the community metabolic model into an equal model, without dummy metabolites and reactions. This process essentially reverses the equivalent, bound free model structure applied to the models of the community members.

Returns:

An equal model, without dummy metabolites and reactions

create_fraction_reaction(model, member_name)

Creates a reaction producing dummy metabolites, which control the bounds of the regular reactions. This method is used on the member metabolic models during community metabolic model generation.

Parameters:
  • model – Model to be changed

  • member_name – The name of the community member

cross_feeding_metabolites_from_fba(return_flux_vector=False)

Run flux balance analysis and convert the solution flux vector into a table of metabolites, including the solution flux for the exchange reaction of each metabolite for every community member.

Parameters:

return_flux_vector – If True, return the flux vector from FBA output as well

Returns:

A dataframe of the solution flux for the exchange reaction of each metabolite for every community member

cross_feeding_metabolites_from_fva(fraction_of_optimum=0.0, composition_agnostic=False, fva_mu_c=None, loopless=True, processes=None, return_flux_vector=False)

Run flux variability analysis and convert the solution flux ranges into a table of metabolites, including the solution flux ranges for the exchange reaction of each metabolite for every community member.

Parameters:
  • fraction_of_optimum – The fraction of the optimal objective flux that needs to be reached

  • composition_agnostic – Removes constrains set by fixed growth rate or fixed abundance. This also allows solutions without balanced growth, i.e. different growth rate of community members.

  • fva_mu_c – Set a temporary community growth rate for the community metabolic model

  • loopless – Run loopless FVA

  • processes – The number of processes to use

  • return_flux_vector – If True, return the flux vector from FVA output as well

Returns:

A dataframe of the solution flux range for the exchange reaction of each metabolite for every community member

equal_abundance()

Converts the model into fixed abundance state, if it is not already in this state and applies an abundance profile of equal abundance.

property f_metabolites

Getter function for the list of f_metabolites (dummy metabolites controlling the reaction bounds). Finds all metabolites in the compartment for dummy metabolites (fraction_reaction)

Returns:

A list of f_metabolites (dummy metabolites controlling the reaction bounds)

property f_reactions

Getter function for the list of f_reactions (dummy reactions controlling the reaction bounds)

Returns:

A list of f_reactions (dummy reactions controlling the reaction bounds)

fba_solution_flux_vector(file_path='')

Runs flux balance analysis on the community metabolic model and saves the solution flux vector as a csv file.

Parameters:

file_path – Path of the output file

Returns:

Dataframe of the solution flux vector

feasible_composition_range(growth_rate=0.0)

Computes the range of feasible compositions at a given growth rate. Changes the model into fixed growth-rate structure.

Parameters:

growth_rate – the target growth rate

Returns:

maximum growth-rate

format_exchg_rxns(exchg_metabolite_df)

Formats the solution flux dataframe of FBA or FVA to a dataframe that contains which community member consumes or produces a given metabolite in the solution

Parameters:

exchg_metabolite_df – The solution flux dataframe

Returns:

The formatted dataframe

fva_solution_flux_vector(file_path='', fraction_of_optimum=0.9, composition_agnostic=False, loopless=True, processes=None)

Run flux variability analysis on the current configuration of the community metabolic model and save the resulting flux ranges to a csv file.

Parameters:
  • file_path – The fraction of the optimal objective flux that needs to be reached

  • fraction_of_optimum – Path of the output file

  • composition_agnostic – Run FVA with relaxed constraints (composition agnostic)

  • loopless – Run loopless FVA

  • processes – The number of processes to use

Returns:

A dataframe of reaction flux solution ranges. Contains the columns reaction_id, min_flux and max_flux

generate_community_model()

This method generates a community metabolic model by merging the models of its community members. The resulting community metabolic model is in fixed growth state. The procedure is as follows: - Each of the community member models is preprocessed for merging (see SingleOrganismModel class for details) - The preprocessed models are converted into equivalent, bound-free form - The preprocessed, bound-free models are merged into a community metabolic model - The community biomass reaction is created and added - A fixed growth rate is applied and the model is set to fixed growth state - The model is checked for mass and charge balance, warning the user if unbalanced reactions exist

Returns:

The community metabolic model

generate_equal_abundance_dict()

Creates a dictionary with community member names as keys and equal fractions as values

Returns:

Dictionary with community member names as keys and equal fractions as values

generate_member_name_conversion_dict()

Creates a dictionary matching old and current names of each of the community members

Returns:

Dictionary with old names as keys and current names as values

get_loops(processes=None)

This is a function to find closed loops that can sustain flux without any input or output. Such loops are thermodynamically infeasible and biologically nonsensical. Users should be aware of their presence and either remove them or check any model solutions for the presence of these cycles.

Parameters:

processes – The number of processes to use

Returns:

A DataFrame of reactions that carry flux without any metabolite input or output in the model

get_member_name_of_compartment(compartment)

This function will return the name of the member the compartment belongs to by extracting this information from its ID.

Parameters:

compartment – The compartment ID whose community member should be found

Returns:

The name of the community member the compartment belongs to

get_member_name_of_metabolite(metabolite)

This function will return the name of the member the metabolite belongs to by extracting this information from its ID.

Parameters:

metabolite – The metabolite or metabolite ID whose community member should be found

Returns:

The name of the community member the metabolite belongs to

get_member_name_of_reaction(reaction)

This function will return the name of the member the reaction belongs to by extracting this information from its ID.

Parameters:

reaction – The reaction or reaction ID whose community member should be found

Returns:

The name of the community member the reaction belongs to

get_member_names()

Get the names of all community members

Returns:

A list of all community member names

get_unbalanced_reactions()

Checks all functions in the community metabolic model for mass and charge balance. The check itself is performed by the function check_mass_balance of COBRApy.

Returns:

A list of unbalanced reactions

is_mass_balanced()

Checks if all reactions in the community metabolic model are mass and charge balanced. Returns True if mass and charge balance is achieved, else False.

Returns:

True if mass and charge balance is achieved, else False

classmethod load(file_path)

Loads a community metabolic model from SBML file generated by PyCoMo as CommunityModel object.

Parameters:

file_path – The path to the SBML model file

Returns:

The community metabolic model as CommunityModel object

load_medium_from_file(file_path)

Loads a medium for the community metabolic model from file and sets it as the medium attribute of this object. The file needs to be in the following format: A csv file with two columns separated by a comma (,). The two columns are named compounds and maxFlux. The compounds columns contains the metabolite IDs of the boundary metabolites as in the community metabolic model. The maxFlux column contains the maximum influx of the respective value as an integer or float.

Parameters:

file_path – The path to the medium file

max_growth_rate(minimal_abundance=0, return_abundances=False, sensitivity=6)

Computes the overall maximum growth-rate of the community. Changes the model into fixed growth-rate structure, set to the overall maximum growth-rate.

Parameters:
  • minimal_abundance – float indicating the minimal abundance of each member in the community

  • return_abundances – If set to True, returns a dataframe with the ranges of feasible member abundances at the maximum growth rate

  • sensitivity – How many decimal places should be calculated

Returns:

maximum growth-rate

property medium

Getter function for the medium of the community metabolic model.

Raises:

ValueError – If no medium has been set so far, this error is raised

Returns:

A dictionary of reaction IDs as keys and their maximum influx as values

merge_fraction_reactions(merged_model)

Combines the fraction reactions of each of the community members

Parameters:

merged_model – The community metabolic model to be changed

property model

Getter for the community metabolic model (COBRApy model object). If no model is present, it will be generated from the community member models

Returns:

The community metabolic model (COBRApy model object)

potential_metabolite_exchanges(fba=False, composition_agnostic=True, fva_mu_c=None, fraction_of_optimum=0.0, loopless=True, processes=None, return_flux_vector=False)

Calculates all potentially exchanged metabolites between the community members. This can be done via flux balance analysis or flux variability analysis.

Parameters:
  • fba – If true, flux balance analysis, otherwise flux variability analysis is used

  • composition_agnostic – Removes constrains set by fixed growth rate or fixed abundance. This also allows solutions without balanced growth, i.e. different growth rate of community members.

  • fva_mu_c – Set a temporary community growth rate for the analysis (only FVA).

  • fraction_of_optimum – The fraction of the optimal objective flux that needs to be reached (only FVA)

  • loopless – Run loopless FVA

  • processes – The number of processes to use (only FVA)

  • return_flux_vector – If True, return the flux vector from FBA/FVA output as well

Returns:

A dataframe of which metabolites are cross-fed, taken up or secreted by each community member

report(verbose=True, max_reactions=5000)

This function gives a report on the community metabolic model. It includes information on the number of metabolites, reactions and genes, the names and number of community members, the model objective and the presence of mass or charge unbalanced reactions and thermodynamically infeasible cycles.

Parameters:
  • verbose – Prints the report

  • max_reactions – Excludes calculation of thermodynamically infeasible cycles from the report if the number of reactions in the model exceeds the number specified in this parameter. If the parameter is set to None, thermodynamically infeasible cycles are calculated regardless of model size

Returns:

A dictionary of model statistics

run_fba()

Optimizes the community metabolic model with flux balance analysis. Returns the flux vector of the solution as a dataframe.

Returns:

Dataframe of the solution flux vector

run_fva(fraction_of_optimum=0.9, composition_agnostic=False, loopless=False, fva_mu_c=None, only_exchange_reactions=True, reactions=None, verbose=False, processes=None)

Run flux variability on the community metabolic model. By default, only reactions connected to metabolites in the shared exchange compartment are analysed.

Parameters:
  • fraction_of_optimum – The fraction of the optimal objective flux that needs to be reached

  • composition_agnostic – Removes constrains set by fixed growth rate or fixed abundance. This also allows solutions without balanced growth, i.e. different growth rate of community members.

  • loopless – Avoids loops in the solutions, but takes longer to compute

  • fva_mu_c – Set a temporary community growth rate for the community metabolic model

  • only_exchange_reactions – Analyse only reactions connected to metabolites in the shared exchange compartment

  • reactions – A list of reactions that should be analysed. This parameter is overwritten if only_exchange_reactions is set to True

  • verbose – Print progress of loopless FVA

  • processes – The number of processes to use

Returns:

A dataframe of reaction flux solution ranges. Contains the columns reaction_id, min_flux and max_flux

save(file_path)

Save the community model object as a SBML file. This also includes the names of the community members and their abundance (if set).

Parameters:

file_path – The path to the output file

summary(suppress_f_metabolites=True, catch_infeasible=False)

Calls and returns the summary method of community metabolic model. Dummy metabolites and reactions can be excluded from the flux report by setting the suppress_f_metabolites flag.

Parameters:

suppress_f_metabolites – If true, excludes dummy metabolites and reactions from the flux report

Returns:

The COBRApy summary object of the community metabolic model

property transfer_reactions

Getter function for the list of f_reactions (dummy reactions controlling the reaction bounds)

Returns:

A list of f_reactions (dummy reactions controlling the reaction bounds)

property transport_reactions

Getter function for the list of f_reactions (dummy reactions controlling the reaction bounds)

Returns:

A list of f_reactions (dummy reactions controlling the reaction bounds)

class pycomo.pycomo_models.SingleOrganismModel(model, name, biomass_met_id='', name_via_annotation=None, shared_compartment_name='medium')

This class is used to bundle single organism metabolic models with their meta-information necessary for community metabolic model generation. The class also handles quality control and preprocessing for merging into a community model.

Parameters:
  • model (class:cobra.Model) – The model as a COBRApy model object

  • name (str) – The name of the model

  • biomass_met (class:cobra.metabolite) – The biomass metabolite of the model

  • biomass_reaction (class:cobra.reaction) – The biomass reaction of the model

  • biomass_met_id (str) – The ID of the biomass metabolite

  • prepared_model (class:cobra.Model) – The preprocessed model for merging

  • shared_compartment_name (str) – The name of the shared compartment to be used in the community metabolic model

add_boundary_metabolites_to_exchange_compartment(model, new_comp=None, old_comp='', inplace=True)
This function adds boundary metabolites to the new exchange compartment for every metabolite in the old external

compartment

Parameters:
  • model – Model to be changed

  • new_comp – ID of the new compartment

  • old_comp – ID of the old external compartment

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

None if the inplace flag is set, otherwise the updated model

add_exchange_compartment(model, exchg_comp_name=None, add_missing_transfers=False, inplace=True, max_flux=1000.0)

Add a new exchange compartment. This will also copy all metabolites in the current external compartment to the exchange compartment, establish transfer reactions between the two compartments for all metabolites and add new exchange reactions for all copied metabolites.

Parameters:
  • model – Model to be changed

  • exchg_comp_name – Name of the new exchange compartment

  • add_missing_transfers – If True, add exchange reactions and transfer reactions for all metabolites in the old external compartment that did not have any exchange reactions

  • inplace – If True, the input model will be changed, else a copy is made

  • max_flux – Maximum allowed flux

Returns:

Updated model

add_exchange_reactions_to_compartment(model, comp, inplace=True)

This method adds exchange reactions for all metabolites in a specified compartment. The method is used during preprocessing for model merging, to generate exchange reactions for all metabolites in the new compartment shared between community members.

Parameters:
  • model – Model to be changed

  • comp – The compartment ID where exchange metabolites should be added (i.e. the new, shared compartment)

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

None if the inplace flag is set, otherwise the model with added exchange reactions

add_exchange_reactions_to_metabolites(model, mets, lb=0.0, inplace=True)

Adds exchange reactions to a list of metabolites.

Parameters:
  • model – Model to be changed

  • mets – A list of metabolites where exchange reactions should be added

  • lb – The lower bound for the exchange reactions

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

None if the inplace flag is set, otherwise the model with added exchange reactions

convert_exchange_to_transfer_reaction(model, old_comp, inplace=True, max_flux=1000.0)

When preprocessing the model for merging into a community metabolic model, a new shared compartment is added. This new compartment will be the compartment for boundary metabolites, containing all metabolites with exchange reactions. The previous boundary metabolites should then have their exchange reactions converted into transfer reactions, which transfer the metabolites into the new, shared compartment.

Parameters:
  • model – The model to be changed

  • old_comp – The ID of the old exchange compartment

  • inplace – If True, the input model will be changed, else a copy is made

  • max_flux – The maximum allowed flux in the model (used to open the constraints of the transfer reactions)

Returns:

None if the inplace flag is set, otherwise the model with changed reactions

ensure_compartment_suffix(model, inplace=True)

This method checks all metabolite IDs and reaction IDs for a suffix containing the compartment they are in. Should the name of the compartment not be part of the ID, the suffix is added, as it is necessary for some operations of this class. The reaction ID will only be changed to contain a compartment suffix if all metabolites that are part of the reaction are found in the same compartment.

Parameters:
  • model – The model to be changed

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

The updated model

find_metabolites_without_exchange_rxn(model, exchg_comp='')

This method finds metabolites that do not have exchange reactions. This is useful for checking whether all metabolites that are meant to be boundary metabolites actually have an exchange reaction connected.

Parameters:
  • model – Model to be checked

  • exchg_comp – The compartment to be searched for metabolites without exchange reactions

Returns:

A list of metabolites without exchange reactions

force_add_exchange(model, metabolite, reaction_id=None, lb=None, ub=None, sbo_term=None)

A function for adding an exchange reaction. In difference to the COBRApy functionality, this function can also set exchange reactions in compartments other than the exchange compartment.

Parameters:
  • model – Model to be changed

  • metabolite – The metabolite where an exchange reaction should be added

  • reaction_id – An ID for the new reaction ID

  • lb – The lower bound for the exchange reaction

  • ub – The upper bound for the exchange reaction

  • sbo_term – The SBO term to be used for the reaction

Returns:

The added exchange reaction

get_name_conversion()

Retrieve the original and current name of this model.

Returns:

original name, current name

handle_boundary_biomass_reaction()

Checks if identified biomass reaction is a boundary reaction. If so, replace the boundary prefix from the reaction ID (EX, SK, DM). Also removes the SBO term associated with the boundary reaction. In case only a single reactant is present (which is expected), the reactant is moved from the boundary compartment into the ‘bio’ compartment, to avoid further boundary reactions being added to it.

prefix_gene_names(model, prefix, inplace=True)

Adds a prefix to all gene IDs, that do not already have this prefix. Also writes the original gene ID as the gene name, if it is not yet set.

Parameters:
  • model – Model to be changed

  • prefix – The prefix to be added to the gene IDs

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

Updated model

prefix_metabolite_names(model, prefix, exclude_compartment='', inplace=True)

Adds a prefix to all metabolite IDs, that do not already have this prefix.

Parameters:
  • model – Model to be changed

  • prefix – The prefix to be added to the metabolite IDs

  • exclude_compartment – Metabolites in this compartment are not changed

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

Updated model

prefix_reaction_names(model, prefix, exclude_compartment='', inplace=True)

Adds a prefix to all reaction IDs, that do not already have this prefix.

Parameters:
  • model – Model to be changed

  • prefix – The prefix to be added to the reaction IDs

  • exclude_compartment – Reactions with this compartment suffix in their ID are not changed

  • inplace – If True, the input model will be changed, else a copy is made

Returns:

Updated model

prepare_for_merging(shared_compartment_name=None, max_flux=1000.0)

Prepares the model for merging into a community metabolic model. The generated model is SBML conform and all genes, reactions, compartments and metabolites contain the information that they belong to this model (which is important for traceability after merging into a community metabolic model). The procedure is as follows: - Get the ID of the biomass metabolite, if not already specified - Remove the biomass exchange reaction - Ensure SBML conform IDs in the whole model - Add the compartment name as suffix for all metabolites and reactions - Add the new shared exchange compartment and populate it with the boundary metabolites - Prefix all compartments, genes, reactions and metabolites with the name of the model

Parameters:
  • shared_compartment_name – The ID of the new shared exchange compartment

  • max_flux – Maximum allowed flux

Returns:

The model prepared for merging

remove_biomass_exchange_rxn(model, remove_all_consuming_rxns=True)

Removes all exchange reactions of the biomass metabolite. This is used to ensure that the biomass metabolite will only be consumed by the community biomass reaction.

Parameters:
  • model – Model to be changed

  • remove_all_consuming_rxns – If True, remove all reactions consuming the biomass metabolite as well

Returns:

None

rename_comp_in_met_id(model, old_comp, new_comp, inplace=True, change_name=False, remove_comp_from_name=False)

Renames the compartments in metabolite IDs.

Parameters:
  • model – Model to be changed

  • old_comp – The compartment to be renamed

  • new_comp – The new name of the compartment

  • inplace – If True, change the input model, else a copy is created and changed

  • change_name – If True, change the metabolite name in addition to the metabolite ID

  • remove_comp_from_name – If True, remove the compartment from the metabolite name (if present)

Returns:

Model with renamed compartments in metabolite IDs

rename_comp_in_rxn_id(model, old_comp, new_comp, inplace=True, change_name=False)

Renames the compartments in reaction IDs.

Parameters:
  • model – Model to be changed

  • old_comp – The compartment to be renamed

  • new_comp – The new name of the compartment

  • inplace – If True, change the input model, else a copy is created and changed

  • change_name – If True, change the reaction name in addition to the metabolite ID

Returns:

Model with renamed compartments in reaction IDs

rename_compartment(model, rename)

Rename compartments of a model

Parameters:
  • model – Model to be changed

  • rename – A dictionary containing old compartments as keys and the new compartment names as values

Returns:

The model with renamed compartments

set_name_via_annotation(name_via_annotation)

Set the name_via_annotation attribute of the model. If a model was already prepared for merging, the preprocessing is repeated with the newly set attribute.

Parameters:

name_via_annotation – The database to be used for matching boundary metabolites when merging into a community metabolic model. If None, matching of metabolites is done via metabolite IDs instead

pycomo.pycomo_models.doall(model_folder='', models=None, com_model=None, out_dir='', community_name='community_model', fixed_growth_rate=None, abundance='equal', medium=None, fba_solution_file=None, fva_solution_file=None, fva_solution_threshold=0.9, fba_interaction_file=None, fva_interaction_file=None, composition_agnostic=False, max_growth_rate_file=None, sbml_output_file=None, return_as_cobra_model=False, merge_via_annotation=None, loopless=True, num_cores=1)

This method is meant as an interface for command line access to the functionalities of PyCoMo. It includes generation of community metabolic models, their analyses and can save the results of analyses as well as the model to files.

Parameters:
  • model_folder – Path to a directory containing metabolic models to be merged into a community

  • models – A list of file paths to metabolic model files or a list of COBRApy model objects, to be merged into a community

  • com_model – Path to a SBML file of a community metabolic model generated by PyCoMo

  • out_dir – Path to an output directory

  • community_name – The name of the generated community

  • fixed_growth_rate – Sets the community metabolic model to fixed growth state with this value as growth rate

  • abundance – Sets the community metabolic model to fixed abundance state. This parameter can be either None, equal, or an abundance dict (community member names as keys and fractions as values).

  • medium – Path to a medium file to be applied to the community metabolic model

  • fba_solution_file – Run FBA and save the solution to this file

  • fva_solution_file – Run FVA and save the solution to this file

  • fva_solution_threshold – The fraction of the objective optimum needed to be reached in FVA

  • fba_interaction_file – Run FBA to calculate cross-feeding interactions and save the solution to this file

  • fva_interaction_file – Run FVA to calculate cross-feeding interactions and save the solution to this file

  • composition_agnostic – Run FVA with relaxed constraints (composition agnostic)

  • sbml_output_file – If a filename is given, save the community metabolic model as SBML file

  • max_growth_rate_file – If a filename is given, calculate the maximum community growth-rate, including the feasible community composition.

  • return_as_cobra_model – If true, returns the community metabolic model as COBRApy model object, otherwise as PyCoMo CommunityModel object

  • merge_via_annotation – The database to be used for matching boundary metabolites when merging into a community metabolic model. If None, matching of metabolites is done via metabolite IDs instead

  • loopless – Run loopless FVA

  • num_cores – The number of cores to use in flux variability analysis

Returns:

The community metabolic model, either as COBRApy model object or PyCoMo CommunityModel object (see return_as_cobra_model parameter)

pycomo.pycomo_models.main()

The main function to be executed when PyCoMo is used via the command line.