本文整理汇总了Python中cobra.Model.add_boundary方法的典型用法代码示例。如果您正苦于以下问题:Python Model.add_boundary方法的具体用法?Python Model.add_boundary怎么用?Python Model.add_boundary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cobra.Model
的用法示例。
在下文中一共展示了Model.add_boundary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_model
# 需要导入模块: from cobra import Model [as 别名]
# 或者: from cobra.Model import add_boundary [as 别名]
def build_model():
m = Model("Blazier et al 2012")
m1_e = Metabolite("M1_e")
m1 = Metabolite("M1")
m2 = Metabolite("M2")
m3 = Metabolite("M3")
m4_e = Metabolite("M4_e")
m4 = Metabolite("M4")
m5 = Metabolite("M5")
r1 = Reaction("R1")
r1.add_metabolites({m1_e: -1, m1: 1})
r2 = Reaction("R2")
r2.add_metabolites({m1: -1, m2: 1})
r2.gene_reaction_rule = "Gene2"
r3 = Reaction("R3")
r3.add_metabolites({m2: -1, m3: 1})
r3.gene_reaction_rule = "Gene3"
r4 = Reaction("R4")
r4.add_metabolites({m3: -1})
r5 = Reaction("R5")
r5.add_metabolites({m4_e: -1, m4: 1})
r6 = Reaction("R6")
r6.add_metabolites({m4: -1, m5: 1})
r6.gene_reaction_rule = "Gene6"
r7 = Reaction("R7")
r7.add_metabolites({m5: -1, m2: 1})
r7.lower_bound = -r7.upper_bound
r7.gene_reaction_rule = "Gene7"
r8 = Reaction("R8")
r8.add_metabolites({m5: -1})
m.add_reactions([r1, r2, r3, r4, r5, r6, r7, r8])
EX_M1_e = m.add_boundary(m1_e)
EX_M1_e.lower_bound = -10
EX_M4_e = m.add_boundary(m4_e)
EX_M4_e.lower_bound = -10
m.objective = r4
return m
示例2: construct_universal_model
# 需要导入模块: from cobra import Model [as 别名]
# 或者: from cobra.Model import add_boundary [as 别名]
def construct_universal_model(list_of_db_prefixes, reac_xref, reac_prop, chem_prop):
""""Construct a universal model based on metanetx.
Arguments
---------
list_of_db_prefixes : list
A list of database prefixes, e.g., ['bigg', 'rhea']
reac_xref : pandas.DataFrame
A dataframe of http://www.metanetx.org/cgi-bin/mnxget/mnxref/reac_xref.tsv
reac_prop : pandas.DataFrame
A dataframe of http://www.metanetx.org/cgi-bin/mnxget/mnxref/reac_prop.tsv
chem_prop : pandas.DataFrame
A dataframe of http://www.metanetx.org/cgi-bin/mnxget/mnxref/chem_prop.tsv
"""
# Select which reactions to include in universal reaction database
mnx_reaction_id_selection = set()
for db_prefix in list_of_db_prefixes:
mnx_reaction_id_selection.update(reac_xref[reac_xref.XREF.str.startswith(db_prefix)].MNX_ID)
reaction_selection = reac_prop.loc[mnx_reaction_id_selection]
reactions = list()
for index, row in reaction_selection.iterrows():
try:
stoichiometry = parse_reaction(row.Equation, rev_arrow='=')
except ValueError:
continue
else:
for met, coeff in stoichiometry.items():
met.name = chem_prop.loc[met.id]['name']
try:
met.formula = Formula(chem_prop.loc[met.id].formula)
except:
logger.debug('Cannot parse formula %s. Skipping formula' % chem_prop.loc[met.id].formula)
continue
try:
met.charge = int(chem_prop.loc[met.id].charge)
except (ValueError, TypeError):
logger.debug('Cannot parse charge %s. Skipping charge' % chem_prop.loc[met.id].charge)
pass
rest = chem_prop.loc[met.id].to_dict()
met.annotation = dict((key, rest[key]) for key in rest if key in ('mass', 'InChI', 'source'))
mets = [met.id for met in stoichiometry.keys()]
if len(mets) != len(set(mets)):
continue
reaction = Reaction(index)
reaction.add_metabolites(stoichiometry)
try:
if len(reaction.check_mass_balance()) != 0:
continue
except (AttributeError, ValueError) as e:
logger.debug(str(e))
continue
if row.Balance:
reaction.lower_bound = -1 * reaction.upper_bound
reaction.name = row['Source']
row = row.fillna("")
rest = row.to_dict()
reaction.annotation = dict((key, rest[key]) for key in rest if key in ('EC', 'Description'))
reactions.append(reaction)
model = Model('metanetx_universal_model_' + '_'.join(list_of_db_prefixes))
model.add_reactions(reactions)
# Add demands for all metabolites
for metabolite in model.metabolites:
model.add_boundary(metabolite, type='demand')
return model