當前位置: 首頁>>代碼示例>>Python>>正文


Python Bag.itercounts方法代碼示例

本文整理匯總了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])
開發者ID:shawn282,項目名稱:bio-pathfinder,代碼行數:56,代碼來源:network_analyzer.py


注:本文中的bag.Bag.itercounts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。