cell_list = [x.split('_')[0] for x in fastq_list] cell_list = list(set(cell_list)) cell_list.sort() if not os.path.exists(options.s + '/work'): subprocess.check_call('mkdir ' + options.s + '/work', shell=True) # parameters = [] for cell in cell_list: work_dir = options.s + '/work/' + cell + '/' if os.path.exists(work_dir): subprocess.check_call('rm -rf ' + work_dir, shell=True) subprocess.check_call('mkdir ' + work_dir, shell=True) input1, input2 = options.s + '/data/' + cell + '_1.trim.fastq', options.s + '/data/' + cell + '_2.trim.fastq' par = [work_dir, cell, options, input1, input2, chr_list] parameters.append(par) #### mapping(par) # pool = Pool(int(options.np)) pool.map(mapping, parameters) pool.close() pool.join() # # for cell in cell_list: work_dir = options.s + '/work/' + cell + '/' marked_bam = work_dir + cell + '.marked.bam' refSeqTSS = work_dir + cell + '.RefSeqTSS' subroutines.draw_TSS_insert(options.tss, marked_bam, refSeqTSS) # #
os.popen('samtools merge -f ' + temp_bam + ' ' + marked) os.popen('samtools index ' + temp_bam) all_temp = ' '.join(temps) os.popen('samtools merge -f ' + merged_bam + ' ' + all_temp) # os.popen('samtools index ' + merged_bam) print '!!!!!! merge done !!!!!!' print # hist_log = peak_folder + 'mergeAll.hist.log' hist_pdf = peak_folder + 'mergeAll.hist.pdf' os.popen('java -XX:+UseSerialGC -Xmx1g -jar '+options.picard+' CollectInsertSizeMetrics VALIDATION_STRINGENCY=SILENT I=' + merged_bam + ' O=' + hist_log + ' H=' + hist_pdf + ' W=1000') # refSeqTSS = peak_folder + 'mergeAll.RefSeqTSS' subroutines.draw_TSS_insert(tssFile, merged_bam, refSeqTSS) # print '!!!!!! call peak by macs2 !!!!!!' peak_file = peak_folder + 'peaks' os.popen('macs2 callpeak --nomodel -t ' + merged_bam + ' -n ' + peak_file + ' --nolambda --keep-dup all --call-summits') print '!!!!!! call peak done !!!!!!' print # summit = peak_folder + 'peaks_summits.bed' filtered_peak = peak_folder + 'filtered_peaks.bed' if options.blist: print '!!!!!! filter peaks !!!!!!' os.popen('bedtools intersect -v -a ' + summit + ' -b ' + options.blist + " | sort -k5 -nr > " + filtered_peak) print '!!!!!! filter peaks done !!!!!!'