【问题标题】:Error message when use Python multiprocessing使用 Python 多处理时的错误消息
【发布时间】:2015-10-29 20:23:09
【问题描述】:

我需要将一个非常大的 .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 不支持这种并行性?我用一个普通的文本文件测试了这段代码,它运行良好(例如代码被注释了)。

【问题讨论】:

    标签: python parallel-processing multiprocessing pysam


    【解决方案1】:

    pysam 确实存在一些并发问题。如果你看到 source code for fetch 你会看到有一个 problem with concurrency and iterating 它是返回类型

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      • 2016-12-14
      • 2011-10-20
      • 2021-07-16
      相关资源
      最近更新 更多