Exemple #1
0
def run_single_block(input_list):
	baseName,model,out_dir,rst,window,keep_temp,threshold,penality,DB_file,input_file,chromosome,strand,fa_file,depth,start,end = input_list

	print("Generating blocks ...%s %d %s"%(baseName,start,end))
	####Generate sliding windlows
	gw_start_time = datetime.datetime.now()
	block = split_chr_bedGraph2(out_dir,input_file,chromosome,strand,window,fa_file,depth,start,end)
	#ww = open(baseName,'w')
	#for a,b,c in block:
	#	ww.write('%s\t%s\t%s\n'%(a,b,c))
	#ww.close()
	gw_end_time = datetime.datetime.now()
	print("Generate blocks used time: {}".format(gw_end_time - gw_start_time))

	print("Evaluating blocks ...%s %d %s"%(baseName,start,end))
	gw_start_time = datetime.datetime.now()
	Evaluate(baseName,block,model,out_dir,rst,window,keep_temp)
	gw_end_time = datetime.datetime.now()
	print("Evaluated blocks used time: {}".format(gw_end_time - gw_start_time))

	Scan_Forward(baseName,threshold,penality,out_dir)
	Scan_Backward(baseName,threshold,penality,out_dir)
	if(keep_temp != 'yes'):
		predict_file = out_dir+'/predict/'+baseName+'.txt'
		os.system('rm %s'%predict_file)
	Postprocess(DB_file,baseName,threshold,penality,out_dir)
	if(keep_temp != 'yes'):
		forward_file=out_dir+"/maxSum/%s.forward.%d.%d.txt"%(baseName,threshold,penality)
		backward_file=out_dir+"/maxSum/%s.backward.%d.%d.txt"%(baseName,threshold,penality)
		os.system('rm %s %s'%(forward_file,backward_file))
	print('Finished postprocessing...\n')
def run_single_block(input_list):
    #global ref
    #print(ref.keys())
    baseName, model, out_dir, rst, window, keep_temp, threshold, penality, DB_file, input_file, fa_file, chromosome, strand, depth, start, end = input_list

    #log_dir = out_dir+'/log'
    #if not os.path.exists(log_dir):
    #    os.makedirs(log_dir)
    #log.basicConfig(filename='%s/%s.log'%(log_dir,baseName), level=log.INFO)
    print("Generating blocks ...%s %d %s" % (baseName, start, end))
    ####Generate sliding windlows
    gw_start_time = datetime.datetime.now()
    block = split_chr_bedGraph2(out_dir, input_file, chromosome, strand,
                                window, fa_file, depth, start, end)
    #ww = open(baseName,'w')
    #for a,b,c in block:
    #    ww.write('%s\t%s\t%s\n'%(a,b,c))
    #ww.close()
    gw_end_time = datetime.datetime.now()
    print("Generate blocks used time: {}\n".format(gw_end_time -
                                                   gw_start_time))

    print("Evaluating blocks ...%s %d %s" % (baseName, start, end))
    ev_start_time = datetime.datetime.now()
    Evaluate(baseName, block, model, out_dir, rst, window, keep_temp)

    del block  #destroyed the block reference
    gc.collect()  #manually run garbage collection process

    ev_end_time = datetime.datetime.now()
    print("Evaluated blocks used time: {}\n".format(ev_end_time -
                                                    ev_start_time))

    print("Postprocessing blocks ...%s %d %s" % (baseName, start, end))
    ps_start_time = datetime.datetime.now()
    Scan_Forward(baseName, threshold, penality, out_dir)
    Scan_Backward(baseName, threshold, penality, out_dir)
    if (keep_temp != 'yes'):
        predict_file = out_dir + '/predict/' + baseName + '.txt'
        os.system('rm %s' % predict_file)
    Postprocess(DB_file, baseName, threshold, penality, out_dir)
    ps_end_time = datetime.datetime.now()
    print("Postprocessed blocks used time: {}\n".format(ps_end_time -
                                                        ps_start_time))

    if (keep_temp != 'yes'):
        forward_file = out_dir + "/maxSum/%s.forward.%d.%d.txt" % (
            baseName, threshold, penality)
        backward_file = out_dir + "/maxSum/%s.backward.%d.%d.txt" % (
            baseName, threshold, penality)
        os.system('rm %s %s' % (forward_file, backward_file))
    #print('Finished postprocessing...%s\n'%baseName)
    return [
        gw_end_time - gw_start_time, ev_end_time - ev_start_time,
        ps_end_time - ps_start_time
    ]