当前位置: 首页>>代码示例>>Python>>正文


Python Pool.endswith方法代码示例

本文整理汇总了Python中multiprocessing.Pool.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.endswith方法的具体用法?Python Pool.endswith怎么用?Python Pool.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.Pool的用法示例。


在下文中一共展示了Pool.endswith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __main__

# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import endswith [as 别名]

#.........这里部分代码省略.........
        logging.error("Insert Sizes needs to undefined or match input file count")
        sys.exit(1)

    sampleTags = args.sampleTags
    if len(sampleTags) != len(inputBamFiles):
        logging.error("Sample Tags need to match input file count")
        sys.exit(1)

    tempDir = tempfile.mkdtemp(dir=args.workdir, prefix="pindel_work_")
    print(tempDir)
    try:
        meanInsertSizes = []
        seq_hash = {}
        newInputFiles = []
        i = 0
        #make sure the BAMs are indexed and get the mean insert sizes
        for inputBamFile, inputBamIndex, insertSize, sampleTag in zip(inputBamFiles, inputBamFileIndexes, insertSizes, sampleTags ):
            inputFastaFile, inputBamFile = indexBam(args.workdir, args.inputFastaFile, inputBamFile, i, inputBamIndex)
            i += 1
            newInputFiles.append(inputBamFile)
            if insertSize==None:
                meanInsertSize = getMeanInsertSize(inputBamFile)
            else:
                meanInsertSize=insertSize
            meanInsertSizes.append( meanInsertSize )
            for seq in get_bam_seq(inputBamFile, args.min_chrom_size):
                seq_hash[seq] = True
        seqs = seq_hash.keys()
        configFile = config(newInputFiles, meanInsertSizes, sampleTags, tempDir)

        #run pindel
        pindel_files = []
        if args.procs == 1:
            cmd, pindelFileBase = pindel(inputFastaFile, configFile, args, tempDir)
            execute(cmd)
            for suffix in ["_D", "_SI", "_LI", "_INV", "_TD"]:
                if os.path.exists(pindelFileBase + suffix):
                    pindel_files.append( pindelFileBase + suffix )
        else:
            cmds = []
            runs = []
            for a in seqs:
                cmd, pindelFileBase = pindel(inputFastaFile, configFile, args, tempDir, a)
                cmds.append(cmd)
                runs.append(pindelFileBase)
            p = Pool(args.procs)
            values = p.map(execute, cmds, 1)
            for pindelFileBase in runs:
                for suffix in ["_D", "_SI", "_LI", "_INV", "_TD"]:
                    if os.path.exists(pindelFileBase + suffix):
                        pindel_files.append( pindelFileBase + suffix )

        #run pindel2vcf
        with open(os.path.join(args.workdir, "pindel_all"), "w") as handle:
            for p in pindel_files:
                with open(p) as ihandle:
                    for line in ihandle:
                        handle.write(line)

        if args.outputRaw is not None:
            shutil.copy(os.path.join(args.workdir, "pindel_all"), args.outputRaw)

        if args.outputVcfFile is not None:
            cmd = pindel2vcf(inputFastaFile, args.inputFastaName, os.path.join(args.workdir, "pindel_all"), args.outputVcfFile)
            execute(cmd)
        
        if args.outputSomaticVcfFile is not None:
            with open(os.path.join(args.workdir, "pindel_somatic"), "w") as handle:
                for p in pindel_files:
                    if p.endswith("_D"):
                        with open(p) as ihandle:
                            for line in ihandle:
                                if re.search("ChrID", line):
                                    handle.write(line)
                for p in pindel_files:
                    if p.endswith("_SI"):
                        with open(p) as ihandle:
                            for line in ihandle:
                                if re.search("ChrID", line):
                                    handle.write(line)
            
            with open(os.path.join(args.workdir, "somatic.indel.filter.config"), "w") as handle:
                handle.write("indel.filter.input = %s\n" % os.path.join(args.workdir, "pindel_somatic"))
                handle.write("indel.filter.vaf = %s\n" % (args.somatic_vaf))
                handle.write("indel.filter.cov = %s\n" % (args.somatic_cov))
                handle.write("indel.filter.hom = %s\n" % (args.somatic_hom))
                handle.write("indel.filter.pindel2vcf = %s\n" % (which("pindel2vcf")))
                handle.write("indel.filter.reference =  %s\n" % (inputFastaFile))
                handle.write("indel.filter.referencename = %s\n" % (args.inputFastaName))
                handle.write("indel.filter.referencedate = %s\n" % (datetime.datetime.now().strftime("%Y%m%d")) )
                handle.write("indel.filter.output = %s\n" % (args.outputSomaticVcfFile))

            # The hard-coded paths need to be removed.
            execute("%s ~/bin/somatic_indelfilter.pl %s" % (which("perl"), os.path.join(args.workdir, "somatic.indel.filter.config")) )
            
                

    finally:
        if not args.no_clean and os.path.exists(tempDir):
            shutil.rmtree(tempDir)
开发者ID:jhl667,项目名称:galaxy_tools,代码行数:104,代码来源:pindel.py


注:本文中的multiprocessing.Pool.endswith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。