testfastqbamloop.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #! /bin/bash
  2. function precollated_fq_1
  3. {
  4. cat <<EOF
  5. @A/1
  6. ACGTACGT
  7. +
  8. HGFEDCBA
  9. EOF
  10. }
  11. function precollated_fq_2
  12. {
  13. cat <<EOF
  14. @A/2
  15. GTCAGTCA
  16. +
  17. GHGFEDCB
  18. EOF
  19. }
  20. function precollated_fq
  21. {
  22. precollated_fq_1
  23. precollated_fq_2
  24. }
  25. function runopts
  26. {
  27. ../src/fastqtobam $* <(precollated_fq) | ../src/bamtofastq | cmp <(precollated_fq)
  28. # copy pipe return status array
  29. PIPESTAT=( ${PIPESTATUS[*]} )
  30. if [ ${PIPESTAT[0]} -ne 0 ] ; then
  31. echo 'fastqtobam failed'
  32. return 1
  33. elif [ ${PIPESTAT[1]} -ne 0 ] ; then
  34. echo 'bamtofastq failed'
  35. return 1
  36. elif [ ${PIPESTAT[2]} -ne 0 ] ; then
  37. echo 'cmp failed'
  38. return 1
  39. else
  40. return 0
  41. fi
  42. }
  43. function runopts2
  44. {
  45. ../src/fastqtobam $* <(precollated_fq_1) <(precollated_fq_2) | ../src/bamtofastq | cmp <(precollated_fq)
  46. # copy pipe return status array
  47. PIPESTAT=( ${PIPESTATUS[*]} )
  48. if [ ${PIPESTAT[0]} -ne 0 ] ; then
  49. echo 'fastqtobam failed'
  50. return 1
  51. elif [ ${PIPESTAT[1]} -ne 0 ] ; then
  52. echo 'bamtofastq failed'
  53. return 1
  54. elif [ ${PIPESTAT[2]} -ne 0 ] ; then
  55. echo 'cmp failed'
  56. return 1
  57. else
  58. return 0
  59. fi
  60. }
  61. function runoptsfile
  62. {
  63. ../src/fastqtobam $* <(precollated_fq) | ../src/bamtofastq filename=/dev/stdin | cmp <(precollated_fq)
  64. # copy pipe return status array
  65. PIPESTAT=( ${PIPESTATUS[*]} )
  66. if [ ${PIPESTAT[0]} -ne 0 ] ; then
  67. echo 'fastqtobam failed'
  68. return 1
  69. elif [ ${PIPESTAT[1]} -ne 0 ] ; then
  70. echo 'bamtofastq failed'
  71. return 1
  72. elif [ ${PIPESTAT[2]} -ne 0 ] ; then
  73. echo 'cmp failed'
  74. return 1
  75. else
  76. return 0
  77. fi
  78. }
  79. function runoptsfile2
  80. {
  81. ../src/fastqtobam $* <(precollated_fq_1) <(precollated_fq_2) | ../src/bamtofastq filename=/dev/stdin | cmp <(precollated_fq)
  82. # copy pipe return status array
  83. PIPESTAT=( ${PIPESTATUS[*]} )
  84. if [ ${PIPESTAT[0]} -ne 0 ] ; then
  85. echo 'fastqtobam failed'
  86. return 1
  87. elif [ ${PIPESTAT[1]} -ne 0 ] ; then
  88. echo 'bamtofastq failed'
  89. return 1
  90. elif [ ${PIPESTAT[2]} -ne 0 ] ; then
  91. echo 'cmp failed'
  92. return 1
  93. else
  94. return 0
  95. fi
  96. }
  97. function runoptsgz
  98. {
  99. ../src/fastqtobam $* <(precollated_fq) | ../src/bamtofastq gz=1 | zcat | cmp <(precollated_fq)
  100. # copy pipe return status array
  101. PIPESTAT=( ${PIPESTATUS[*]} )
  102. if [ ${PIPESTAT[0]} -ne 0 ] ; then
  103. echo 'fastqtobam failed'
  104. return 1
  105. elif [ ${PIPESTAT[1]} -ne 0 ] ; then
  106. echo 'bamtofastq failed'
  107. return 1
  108. elif [ ${PIPESTAT[2]} -ne 0 ] ; then
  109. echo 'cmp failed'
  110. return 1
  111. else
  112. return 0
  113. fi
  114. }
  115. function runoptsgz2
  116. {
  117. ../src/fastqtobam $* <(precollated_fq_1) <(precollated_fq_2) | ../src/bamtofastq gz=1 | zcat | cmp <(precollated_fq)
  118. # copy pipe return status array
  119. PIPESTAT=( ${PIPESTATUS[*]} )
  120. if [ ${PIPESTAT[0]} -ne 0 ] ; then
  121. echo 'fastqtobam failed'
  122. return 1
  123. elif [ ${PIPESTAT[1]} -ne 0 ] ; then
  124. echo 'bamtofastq failed'
  125. return 1
  126. elif [ ${PIPESTAT[2]} -ne 0 ] ; then
  127. echo 'cmp failed'
  128. return 1
  129. else
  130. return 0
  131. fi
  132. }
  133. #
  134. runopts ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  135. runopts namescheme=generic ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  136. echo "This is expected to fail:"
  137. runopts namescheme=c18s ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  138. echo "This is expected to fail:"
  139. runopts namescheme=c18pe ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  140. runopts namescheme=pairedfiles ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  141. runopts2 ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  142. runopts2 namescheme=generic ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  143. echo "This is expected to fail:"
  144. runopts2 namescheme=c18s ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  145. echo "This is expected to fail:"
  146. runopts2 namescheme=c18pe ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  147. runopts2 namescheme=pairedfiles ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  148. #
  149. runoptsfile ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  150. runoptsfile namescheme=generic ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  151. echo "This is expected to fail:"
  152. runoptsfile namescheme=c18s ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  153. echo "This is expected to fail:"
  154. runoptsfile namescheme=c18pe ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  155. runoptsfile namescheme=pairedfiles ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  156. runoptsfile2 ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  157. runoptsfile2 namescheme=generic ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  158. echo "This is expected to fail:"
  159. runoptsfile2 namescheme=c18s ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  160. echo "This is expected to fail:"
  161. runoptsfile2 namescheme=c18pe ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  162. runoptsfile2 namescheme=pairedfiles ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  163. # gzip
  164. runoptsgz ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  165. runoptsgz namescheme=generic ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  166. echo "This is expected to fail:"
  167. runoptsgz namescheme=c18s ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  168. echo "This is expected to fail:"
  169. runoptsgz namescheme=c18pe ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  170. runoptsgz namescheme=pairedfiles ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  171. runoptsgz2 ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  172. runoptsgz2 namescheme=generic ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  173. echo "This is expected to fail:"
  174. runoptsgz2 namescheme=c18s ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  175. echo "This is expected to fail:"
  176. runoptsgz2 namescheme=c18pe ; R=$? ; if [ ${R} -eq 0 ] ; then exit 1 ; fi
  177. runoptsgz2 namescheme=pairedfiles ; R=$? ; if [ ${R} -ne 0 ] ; then exit ${R} ; fi
  178. exit ${R}