本文整理汇总了Python中bag.Bag.itercounts方法的典型用法代码示例。如果您正苦于以下问题:Python Bag.itercounts方法的具体用法?Python Bag.itercounts怎么用?Python Bag.itercounts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bag.Bag
的用法示例。
在下文中一共展示了Bag.itercounts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evaluate_pathway
# 需要导入模块: from bag import Bag [as 别名]
# 或者: from bag.Bag import itercounts [as 别名]
def evaluate_pathway(list_of_paths):
scores = []
# create a set of all participating enzymes, and count the number of enzymes that are not trivial
total_path_length = 0
enzyme_bag = Bag()
enzyme_type_bag = Bag()
for path in list_of_paths:
for enzyme in path_to_enzyme_list(path):
if (not enzyme in pp_enzymes):
total_path_length += 1
enzyme_bag[enzyme] += 1
enzyme_type_bag[enzyme_types[enzyme]] += 1
scores.append((params['TL'], total_path_length))
scores.append((params['NE'], enzyme_type_bag['EPI']))
scores.append((params['NI'], enzyme_type_bag['ISO']))
scores.append((params['NK'], enzyme_type_bag['KIN']))
scores.append((params['ND'], enzyme_type_bag['DHG']))
num_isoenzymes = 0
for (enzyme, count) in enzyme_bag.itercounts():
if (count > 1):
num_isoenzymes += 1
scores.append((params['MIE'], num_isoenzymes))
total_phosphorilation_distance = 0
for path in list_of_paths:
for enzyme in path_to_enzyme_list(path):
if (enzyme_types[enzyme] == "KIN"):
break
else:
total_phosphorilation_distance += 1
scores.append((params['TPD'], total_phosphorilation_distance))
# NTE - Number maximum number of same-product epimerases
G = pathway_to_graph(list_of_paths)
max_epimerase_count = 0
max_split = 0
for v in G.itervertices():
epimerase_count = 0
for child in G[v]:
if (enzyme_types[(v, child)] == "EPI"):
epimerase_count += 1
max_epimerase_count = max(max_epimerase_count, epimerase_count)
max_split = max(max_split, len(G[v]))
scores.append((params['NTE'], max_epimerase_count))
# copy on the scores that have a parameter which is not None.
chosen_scores = []
for (p, s) in scores:
if (p != None):
chosen_scores.append((p, s))
chosen_scores.sort()
return tuple([s[1] for s in chosen_scores])