在使用 pysam 模块时,我试图将标准输出重定向到一个文件,如下所示:
bam=sys.argv[1]
samfile = pysam.AlignmentFile(bam, "rb")
for alignment in samfile:
reverse=isReverse(alignment.flag)
if (reverse):
outfile = pysam.AlignmentFile("-", "w", template=samfile)
with open('reverse.sam', 'w') as f:
with (f):
for s in samfile:
print('HEY')
outfile.write(s)
虽然“print('HEY')”被写入reverse.sam,但“outfile.write(s)”不是。我应该怎么做呢?
谢谢马克