本文整理汇总了Python中cobra.DictList.remove方法的典型用法代码示例。如果您正苦于以下问题:Python DictList.remove方法的具体用法?Python DictList.remove怎么用?Python DictList.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cobra.DictList
的用法示例。
在下文中一共展示了DictList.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MEmodel
# 需要导入模块: from cobra import DictList [as 别名]
# 或者: from cobra.DictList import remove [as 别名]
#.........这里部分代码省略.........
def construct_attribute_vector(self, attr_name, growth_rate):
"""build a vector of a reaction attribute at a specific growth rate
Mainly used for upper and lower bounds"""
return array([float(value.subs(mu, growth_rate))
if hasattr(value, "subs") else float(value)
for value in self.reactions.list_attr(attr_name)])
def compute_solution_error(self, solution=None):
errors = {}
if solution is None:
solution = self.solution
S = self.construct_S(solution.f)
lb = self.construct_attribute_vector("lower_bound", solution.f)
ub = self.construct_attribute_vector("upper_bound", solution.f)
x = array(solution.x)
err = abs(S * x)
errors["max_error"] = err.max()
errors["sum_error"] = err.sum()
ub_err = min(ub - x)
errors["upper_bound_error"] = abs(ub_err) if ub_err < 0 else 0
lb_err = min(x - lb)
errors["lower_bound_error"] = abs(lb_err) if lb_err < 0 else 0
return errors
def update(self):
"""updates all component reactions"""
for r in self.reactions:
if hasattr(r, "update"):
r.update()
def prune(self):
"""remove all unused metabolites and reactions
This should be run after the model is fully built. It will be
difficult to add new content to the model once this has been run.
"""
complex_data_list = [i.id for i in self.complex_data]
for c_d in complex_data_list:
c = self.complex_data.get_by_id(c_d)
cplx = c.complex
if len(cplx.reactions) == 1:
list(cplx.reactions)[0].delete(remove_orphans=True)
self.complex_data.remove(self.complex_data.get_by_id(c_d))
for p in self.metabolites.query(re.compile('^protein_')):
if isinstance(p, ProcessedProtein):
delete = True
for rxn in p._reaction:
try:
if p in rxn.reactants:
delete = False
except Exception as e:
print(rxn)
raise e
if delete:
while len(p._reaction) > 0:
list(p._reaction)[0].delete(remove_orphans=True)
for data in self.posttranslation_data.query(p.id):
self.posttranslation_data.remove(data.id)
for p in self.metabolites.query(re.compile('^protein_')):
if isinstance(p, TranslatedGene):
delete = True