我需要将一个非常大的 .bam 文件转换为 .bed 文件,尽管我通过使用 bedops 的 bam2bed 并行找到了一个解决方案,该并行支持 SEG 和 gnuParallel,我可以访问的两个集群仅支持 slurm 和扭矩调度程序,而我不对tcsh了解很多,我什至不能修改脚本来满足slurm和torque的要求。
由于我对 Python 稍有了解,我打算使用 Python 的多处理模块来执行此操作,但是,以下代码引发了一个奇怪的消息:
“Python 在使用 calignmentfile.so 插件时意外退出”
# The code here is just a test code, ignore its real meaning.
import multiprocessing as mp
import pysam
def work(read):
return read.query
# return read.split()[0]
if __name__ == '__main__':
cpu = mp.cpu_count()
pool = mp.Pool(cpu)
sam = pysam.AlignmentFile('foo.bam', 'rb')
read = sam.fetch(until_eof=True)
# f = open('foo.text', 'rb')
# results = pool.map(work, f, cpu)
results = pool.map(work, read, cpu)
print(results)
此消息是否意味着来自 pysam.AlignmentFile() 的读取不支持并行性,或者 Python 不支持这种并行性?我用一个普通的文本文件测试了这段代码,它运行良好(例如代码被注释了)。