本文整理汇总了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
示例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)