testdupsinglemarkedsortedqreset.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #! /bin/bash
  2. SCRIPTDIR=`dirname "${BASH_SOURCE[0]}"`
  3. pushd ${SCRIPTDIR}
  4. SCRIPTDIR=`pwd`
  5. popd
  6. source ${SCRIPTDIR}/dupsinglemarked.sh
  7. source ${SCRIPTDIR}/dupsinglemarkedsortedqreset.sh
  8. function reset
  9. {
  10. dupsinglemarked | ../src/bamsort SO=queryname | ../src/bamreset resetsortorder=0
  11. }
  12. ./bamcmp <(reset) <(dupsinglemarkedsortedqreset)
  13. if [ $? -ne 0 ] ; then
  14. exit 1
  15. fi
  16. SORTORDER=unknown
  17. for i in `reset | ./bamtosam | head -n 1 | egrep "^@HD"` ; do
  18. if [ ! -z "`echo $i | egrep \"^SO:\"`" ] ; then
  19. SORTORDER=`echo $i | perl -p -e "s/^SO://"`
  20. fi
  21. done
  22. if [ "${SORTORDER}" != "queryname" ] ; then
  23. exit 1
  24. fi
  25. # check reset by column
  26. COL2=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $2}' | sort -u`
  27. COL2CNT=`echo $COL2 | wc -l`
  28. if [ "${COL2CNT}" -ne 1 ] ; then
  29. exit 1
  30. fi
  31. if [ "${COL2}" != "4" ] ; then
  32. exit 1
  33. fi
  34. COL3=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $3}' | sort -u`
  35. COL3CNT=`echo "${COL3}" | wc -l`
  36. if [ "${COL3CNT}" -ne 1 ] ; then
  37. exit 1
  38. fi
  39. if [ "${COL3}" != "*" ] ; then
  40. exit 1
  41. fi
  42. COL4=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $4}' | sort -u`
  43. COL4CNT=`echo "${COL4}" | wc -l`
  44. if [ "${COL4CNT}" -ne 1 ] ; then
  45. exit 1
  46. fi
  47. if [ "${COL4}" != "0" ] ; then
  48. exit 1
  49. fi
  50. COL5=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $5}' | sort -u`
  51. COL5CNT=`echo "${COL5}" | wc -l`
  52. if [ "${COL5CNT}" -ne 1 ] ; then
  53. exit 1
  54. fi
  55. if [ "${COL5}" != "0" ] ; then
  56. exit 1
  57. fi
  58. COL6=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $6}' | sort -u`
  59. COL6CNT=`echo "${COL6}" | wc -l`
  60. if [ "${COL6CNT}" -ne 1 ] ; then
  61. exit 1
  62. fi
  63. if [ "${COL6}" != "*" ] ; then
  64. exit 1
  65. fi
  66. COL7=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $7}' | sort -u`
  67. COL7CNT=`echo "${COL7}" | wc -l`
  68. if [ "${COL7CNT}" -ne 1 ] ; then
  69. exit 1
  70. fi
  71. if [ "${COL7}" != "*" ] ; then
  72. exit 1
  73. fi
  74. COL8=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $8}' | sort -u`
  75. COL8CNT=`echo "${COL8}" | wc -l`
  76. if [ "${COL8CNT}" -ne 1 ] ; then
  77. exit 1
  78. fi
  79. if [ "${COL8}" != "0" ] ; then
  80. exit 1
  81. fi
  82. COL9=`reset | ./bamtosam | egrep -v "^@" | awk -F '\t' '{print $9}' | sort -u`
  83. COL9CNT=`echo "${COL9}" | wc -l`
  84. if [ "${COL9CNT}" -ne 1 ] ; then
  85. exit 1
  86. fi
  87. if [ "${COL9}" != "0" ] ; then
  88. exit 1
  89. fi
  90. exit 0