예제 #1
0
def build_bowtie2db(ifn_markers, tmp_dir, error_pipe=None):
    # build bowtie2-index
    if not os.path.isfile(ifn_markers):
        error = 'ifn_markers %s does not exist!' % ifn_markers
        logger.error(error)
        raise Exception(error)

    if not os.path.isdir(tmp_dir):
        ooSubprocess.mkdir(tmp_dir)
    bt2_base = ooSubprocess.splitext(ifn_markers)[0]
    index_fns = glob.glob('%s/%s.*' % (tmp_dir, bt2_base))
    index_path = os.path.join(tmp_dir, bt2_base)
    oosp = ooSubprocess.ooSubprocess(tmp_dir)
    if index_fns == []:
        oosp.ex('bowtie2-build', ['--quiet', ifn_markers, index_path],
                stderr=error_pipe)
    else:
        logger.warning('bowtie2-indexes of %s are ready, skip rebuilding!' %
                       (bt2_base))
    return index_path
예제 #2
0
def main(args):
    ooSubprocess.mkdir(args['output_dir'])
    manager = multiprocessing.Manager()

    if args['input_type'] == 'fastq':
        index_path = build_bowtie2db(args['ifn_markers'], args['output_dir'])
        args['index_path'] = index_path

    args_list = []
    for ifn_sample in args['ifn_samples']:
        args_list.append([ifn_sample, args])

    #ooSubprocess.parallelize(run_sample, args_list, args['nprocs'])
    pool = multiprocessing.Pool(args['nprocs'])
    results = []
    for a in args_list:
        r = pool.apply_async(run_sample, [a])
        results.append(r)
    for r in results:
        try:
            r.get()
        except Exception as e:
            print e