当前位置: 首页>>代码示例>>Python>>正文


Python NGram._split方法代码示例

本文整理汇总了Python中ngram.NGram._split方法的典型用法代码示例。如果您正苦于以下问题:Python NGram._split方法的具体用法?Python NGram._split怎么用?Python NGram._split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ngram.NGram的用法示例。


在下文中一共展示了NGram._split方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_distr

# 需要导入模块: from ngram import NGram [as 别名]
# 或者: from ngram.NGram import _split [as 别名]
def get_distr(strlist, n_len):
    alphabet = ['A', 'C', 'G', 'T', 'N']
    n = NGram(N=n_len, pad_len=0)
    all_ngrams = 0
    grams = init_grams_dict(n_len, alphabet)
    for item in strlist:
        if item == '':
            continue
        ngram_list = list(n._split(item))
        for ng in ngram_list:
            if ng in grams:
                grams[ng] += float(1)
                all_ngrams += 1
    for item in grams.keys():
        grams[item] /= all_ngrams
    return grams
开发者ID:al-indigo,项目名称:transcriptome-assemblies-refiner,代码行数:18,代码来源:validation_checker.py

示例2: print

# 需要导入模块: from ngram import NGram [as 别名]
# 或者: from ngram.NGram import _split [as 别名]
                and oases_item['top'] == trinity_item['top'] \
                and oases_item['n'] == trinity_item['n']\
                and oases_item['kernel'].values()[0] == trinity_item['kernel'].values()[0]:
            print (oases_item, trinity_item)

#intersect = set(good_list_oases) & set(good_list_trinity)

from tr_parser import get_assemblies
(ref, oases_reads, oases_name_index, trinity_reads, trinity_name_index) = get_assemblies("data/ref_for_reads.fasta",
                                                                                         "data/Oases.fasta",
                                                                                         "data/Trinity.fasta")
from ngram import NGram

n = NGram(N=4, pad_len=0)
grams = dict()
for transcript in ref:
    if transcript == '':
        continue
    ngram_list = list(n._split(transcript))
    for ng in ngram_list:
        if ng == 'TTSG':
            pdb.set_trace()
        if ng in grams:
            grams[ng] += 1
        else:
            grams[ng] = 1

pp = pprint.PrettyPrinter()
pp.pprint(grams)
print len(grams)
开发者ID:aimly,项目名称:transcriptome-assemblies-refiner,代码行数:32,代码来源:validation_checker.py


注:本文中的ngram.NGram._split方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。