本文整理匯總了Python中IOTools.flatten方法的典型用法代碼示例。如果您正苦於以下問題:Python IOTools.flatten方法的具體用法?Python IOTools.flatten怎麽用?Python IOTools.flatten使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IOTools
的用法示例。
在下文中一共展示了IOTools.flatten方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: iterator_sorted
# 需要導入模塊: import IOTools [as 別名]
# 或者: from IOTools import flatten [as 別名]
def iterator_sorted( gff_iterator, sort_order = "gene" ):
'''sort input and yield sorted output.'''
entries = list(gff_iterator)
if sort_order == "gene":
entries.sort( key = lambda x: (x.gene_id, x.transcript_id, x.contig, x.start) )
elif sort_order == "gene":
entries.sort( key = lambda x: (x.gene_id, x.contig, x.start) )
elif sort_order == "contig+gene":
entries.sort( key = lambda x: (x.contig,x.gene_id,x.transcript_id,x.start) )
elif sort_order == "transcript":
entries.sort( key = lambda x: (x.transcript_id, x.contig, x.start) )
elif sort_order == "position":
entries.sort( key = lambda x: (x.contig, x.start) )
elif sort_order == "position+gene":
entries.sort( key = lambda x: (x.gene_id, x.start) )
genes = list( flat_gene_iterator(entries) )
genes.sort( key = lambda x: (x[0].contig, x[0].start) )
entries = IOTools.flatten( genes )
for entry in entries:
yield entry