File tree 1 file changed +41
-0
lines changed 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/bash
2
+ # $ -j y
3
+ # $ -V
4
+ # $ -l m_mem_free=32G,h_vmem=64G
5
+ # $ -pe smp 1
6
+ # $ -cwd
7
+
8
+ # script extracts regions of interest specified in a bed file, from bam file
9
+ # samtools and bedtools are used to calculate depth of coverage for the regions extracted
10
+ # results in a ROI_bam file, and two text files with results from samtools and bedtools respectively
11
+ # all the processes run in parallel
12
+
13
+ function back_ground_process () {
14
+ # fetch regions of interest from BAM files to speed up the process
15
+ samtools view -bh /mnt/isilon/maris_lab/target_nbl_ngs/CellLineExome/aligned_2019/${1} .sorted.reheader.bam -L allExons.bed > ROI_bams/${1} _regionofinterest.bam
16
+
17
+ # Calculate average exome coverage
18
+ samtools depth -b allExons.bed ROI_bams/${1} _regionofinterest.bam | awk ' {sum+=$3} END { print "Average = ",sum/NR}' >> ${1} _samtools_exomCoverage.txt
19
+
20
+ # output the mean depth of coverage for each region in the BED file
21
+ bedtools coverage -a allExons.bed -b ROI_bams/${1} _regionofinterest.bam -mean >> ${1} _bedtools_exomCoverage.txt
22
+ # wk '{sum+=$4} END { print "'$1' Average = ",sum/NR}' ${1}_bedtools_exomCoverage.txt >> exomeCov_bedtools.txt
23
+ echo " ${1} done!"
24
+ }
25
+
26
+ # array in shell script
27
+ arr=(" CHLA15_NoIndex_L002" " CHLA20_CTTGTA_L006" " CHP134_NoIndex_L006" " COGN415_NoIndex_L003" " COGN426_NoIndex_L004" " IMR5_NoIndex_L007" " Kelly_NoIndex_L008" " LAN5_CAGATC_L001" " NB1691_ACTTGA_L002" " NB1_GGCTAC_L005" " NB69_NoIndex_L008" " NBEBc1_GATCAG_L003" " NBLS_NoIndex_L007" " NBSD_TAGCTT_L004" " NGP_NoIndex_L008" " NLF_NoIndex_L001" " SKNAS_NoIndex_L002" " SKNBE1_NoIndex_L006" " SKNBE2C_NoIndex_L005" " SKNBE2_NoIndex_L003" " SKNDZ_NoIndex_L004" " SKNFI_NoIndex_L006" " SKNKAN_NoIndex_L008" " SKNKANR_NoIndex_L007" " SKNSH_NoIndex_L007" " XNB20_NoIndex_L005" )
28
+
29
+ # @ means all elements in array
30
+ for i in ${arr[@]} ; do
31
+ # run back_ground_process function in background
32
+ # pass element of array as argument
33
+ # make log file
34
+ back_ground_process $i > ~ /KP/ExomeDepth/log_${i} .txt &
35
+ done
36
+
37
+
38
+ # wait until all child processes are done
39
+ wait
40
+
41
+ echo " All background processes are done!"
You can’t perform that action at this time.
0 commit comments