本文整理汇总了Python中pysam.Samfile.gettid方法的典型用法代码示例。如果您正苦于以下问题:Python Samfile.gettid方法的具体用法?Python Samfile.gettid怎么用?Python Samfile.gettid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysam.Samfile
的用法示例。
在下文中一共展示了Samfile.gettid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pysam import Samfile [as 别名]
# 或者: from pysam.Samfile import gettid [as 别名]
def main(args):
option = "r" if args.samformat else "rb"
samfile = Samfile(args.bamfile, "rb")
ref_ids = [samfile.gettid(r) for r in samfile.references]
#Iterates over each read instead of each contig
reads_to_print = []
for aln in samfile.fetch(until_eof = True):
if pair_is_aligned(aln, ref_ids):
if args.read_pair == 1 and aln.is_read1:
reads_to_print.append(aln)
elif args.read_pair == 2 and aln.is_read2:
reads_to_print.append(aln)
elif args.read_pair == 0:
reads_to_print.append(aln)
if len(reads_to_print) >= 10000:
# Flush the reads collected
print_reads(reads_to_print)
reads_to_print = []
print_reads(reads_to_print)
示例2: main
# 需要导入模块: from pysam import Samfile [as 别名]
# 或者: from pysam.Samfile import gettid [as 别名]
def main(args):
option = "r" if args.samformat else "rb"
samfile = Samfile(args.bamfile, option)
ref_ids = [samfile.gettid(r) for r in samfile.references]
#Iterates over each read instead of each contig
reads_to_print_1 = []
reads_to_print_2 = []
reads_to_print_u = []
for aln in samfile.fetch(until_eof = True):
if aln.tid in ref_ids: # This read is aligned
if aln.rnext in ref_ids: # The mate is also aligned
if aln.is_read1:
reads_to_print_1.append(aln)
reads_to_print_1 = flush_reads(reads_to_print_1, args.R1)
elif aln.is_read2:
reads_to_print_2.append(aln)
reads_to_print_2 = flush_reads(reads_to_print_2, args.R2)
else:
reads_to_print_u.append(aln)
reads_to_print_u = flush_reads(reads_to_print_u, args.u)
print_reads(reads_to_print_1, args.R1)
print_reads(reads_to_print_2, args.R2)
print_reads(reads_to_print_u, args.u)