美文网首页程序员
2018-03-10 multiprocessing 多线程

2018-03-10 multiprocessing 多线程

作者: e8a37405cb53 | 来源:发表于2018-03-10 09:29 被阅读0次
    import sys,os,time
    
    import multiprocessing as mp
    
    bamfile = sys.argv[1]
    
    #desDir = '/public0/nong/tcga_luad/bedgraph_test'
    desDir = sys.argv[2]
    os.system('mkdir -p ' + desDir)
    
    bams = open(bamfile,'r').read().strip().split('\n')
    cmd_filter = 'python3 '+ os.path.join(os.path.dirname(sys.argv[0]), '2.1_filter_chr.py')
    def genomceCoverage(bam, outdir):
    
        bamname = os.path.basename(bam)
        graph = os.path.join(outdir,bamname ) + '.bedgraph'
        cmd = 'genomeCoverageBed -bg -ibam '+bam + ' -g /public0/nong/source/hg38.chrom.chr.sizes -split | ' + cmd_filter + ' >' + graph
        print(cmd)
        os.system(cmd)
    
    
    pool = mp.Pool(8) #多线程, 以及线程数!
    for bam in bams:
        t = pool.apply_async(genomceCoverage, (bam, desDir))
    pool.close()
    pool.join()
    
    

    相关文章

      网友评论

        本文标题:2018-03-10 multiprocessing 多线程

        本文链接:https://www.haomeiwen.com/subject/tuevfftx.html