Merge pull request #378 from taoliu/fix_setup_script_364
[MACS.git] / test / cmdlinetest_narrowpeak_pe
blob11823c6a17df8ade9213510686fac4d9e02ee6cc
1 #!/bin/bash
3 # integrative subcmds testing
5 if [ $# -lt 1 ];then
6 echo "Run all tests for subcommands of MACS2. Need 1 parameter for a tag name! A unique string combining date, time and MACS2 version is recommended. ./test.sh <TAG>"
7 exit
8 fi
10 # test all sub-commands
11 TAG=$1
13 CHIP=CTCF_SE_ChIP_chr22_50k.bed.gz
14 CTRL=CTCF_SE_CTRL_chr22_50k.bed.gz
16 CHIPPE=CTCF_PE_ChIP_chr22_50k.bam
17 CTRLPE=CTCF_PE_CTRL_chr22_50k.bam
19 CHIPBEDPE=CTCF_PE_ChIP_chr22_50k.bedpe.gz
20 CTRLBEDPE=CTCF_PE_CTRL_chr22_50k.bedpe.gz
22 CHIPCONTIGS50K=contigs50k.bed.gz
24 CHIPBIGSPEEDTEST=CTCF_12878_5M.bed.gz
25 CTRLBIGSPEEDTEST=input_12878_5M.bed.gz
27 # callpeak
28 echo "1. callpeak"
30 mkdir ${TAG}_run_callpeak_pe_narrow
31 mkdir ${TAG}_run_callpeak_narrow
33 macs2 callpeak -g 52000000 -t $CHIP -c $CTRL -n run_callpeak_narrow0 -B --outdir ${TAG}_run_callpeak_narrow --cutoff-analysis &> ${TAG}_run_callpeak_narrow/run_callpeak_narrow0.log
35 cat ${TAG}_run_callpeak_narrow/run_callpeak_narrow0.log
37 macs2 callpeak -g 52000000 -f BAMPE -t $CHIPPE -c $CTRLPE -n run_callpeak_bampe_narrow -B --outdir ${TAG}_run_callpeak_pe_narrow --call-summits --verbose 3 &> ${TAG}_run_callpeak_pe_narrow/run_callpeak_bampe_narrow.log
39 cat ${TAG}_run_callpeak_pe_narrow/run_callpeak_bampe_narrow.log
41 echo "2. search for errors or warnings in log files"
42 flag=0
43 for i in `ls ${TAG}_run_*/*.log`;do
44 echo " checking $i..."
45 egrep -A 2 -B 2 -i "error|warning" $i;
46 if [[ $? == 0 ]];then
47 echo " ... error/warning found!"
48 let "flag=1";
49 else
50 echo " ... clear!"
52 done;
54 if [[ $flag == 1 ]]; then
55 echo " Error or Warning can be found! Quit the test!"
56 exit 1;
59 echo "3. compare with standard outputs"
61 flag=0
62 # we do not check the consistency of random subsampling results
63 subfolders=(callpeak_pe_narrow callpeak_narrow)
65 m=0
66 n=0
67 for i in ${subfolders[@]};do
68 let "m+=1"
69 let "n=0"
70 for j in `ls standard_results_${i}/*`; do
71 k=`basename $j`
72 let "n+=1"
73 echo "14.${m}.${n} checking $i $k ..."
74 fq=${TAG}_run_${i}/${k}
75 fs=standard_results_${i}/${k}
76 if [ ! -f "$fq" ]; then
77 continue
79 sort $fq > tmp_fq.txt
80 sort $fs > tmp_fs.txt
81 d=`diff tmp_fq.txt tmp_fs.txt`
82 if [ -z "$d" ]; then
83 echo " ... success!"
84 else
85 echo " ... failed! Difference:"
86 diff tmp_fq.txt tmp_fs.txt | head -10
87 let "flag=1";
89 done
90 done
91 rm -f tmp_fq.txt tmp_fs.txt
93 # exit with 1 if test fails
94 if [ $flag -eq 1 ];then
95 exit $flag;
98 # END of test