本文整理汇总了Python中skbio.Alignment.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python Alignment.iteritems方法的具体用法?Python Alignment.iteritems怎么用?Python Alignment.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.Alignment
的用法示例。
在下文中一共展示了Alignment.iteritems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_deblur_output
# 需要导入模块: from skbio import Alignment [as 别名]
# 或者: from skbio.Alignment import iteritems [as 别名]
def parse_deblur_output(seqs_fp, derep_clusters):
""" Parse deblur output file into an OTU map.
Parameters
----------
seqs_fp: string
file path to deblurred sequences
derep_clusters: dictionary
dictionary of dereplicated sequences map
Returns
-------
clusters: dictionary
dictionary of clusters including dereplicated sequence labels
Notes
-----
For each deblurred sequence in seqs_fp, use the sequence label to
obtain all dereplicated sequence labels belonging to it
(from derep_clusters) to create entries in a new dictionary where the keys
are actual sequences (not the labels). Note not all sequences
in derep_clusters will be in seqs_fp since they could have been removed in
the artifact filtering step.
"""
clusters = {}
# Replace representative sequence name with actual sequence in cluster
msa_fa = Alignment.read(seqs_fp, format='fasta')
for label, seq in Alignment.iteritems(msa_fa):
cluster_id = label.split(';')[0]
seq2 = str(seq.degap())
if seq2 not in clusters:
clusters[seq2] = []
if cluster_id not in derep_clusters:
raise ValueError(
'Seed ID %s does not exist in .uc file' % cluster_id)
else:
clusters[seq2].extend(derep_clusters[cluster_id])
return clusters