ngs_server 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +2 -0
  4. data/bin/ngs_server +58 -0
  5. data/data/holder.txt +0 -0
  6. data/ext/bamtools/CMakeLists.txt +49 -0
  7. data/ext/bamtools/LICENSE +22 -0
  8. data/ext/bamtools/README +60 -0
  9. data/ext/bamtools/Tutorial_Toolkit_BamTools-1.0.pdf +0 -0
  10. data/ext/bamtools/docs/Doxyfile +1601 -0
  11. data/ext/bamtools/extconf.rb +9 -0
  12. data/ext/bamtools/src/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
  13. data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/DependInfo.cmake +13 -0
  14. data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/build.make +65 -0
  15. data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/cmake_clean.cmake +8 -0
  16. data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/depend.internal +3 -0
  17. data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/depend.make +3 -0
  18. data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/progress.make +2 -0
  19. data/ext/bamtools/src/CMakeFiles/progress.marks +1 -0
  20. data/ext/bamtools/src/CMakeLists.txt +18 -0
  21. data/ext/bamtools/src/ExportHeader.cmake +31 -0
  22. data/ext/bamtools/src/Makefile +182 -0
  23. data/ext/bamtools/src/api/BamAlignment.cpp +2432 -0
  24. data/ext/bamtools/src/api/BamAlignment.h +206 -0
  25. data/ext/bamtools/src/api/BamAux.h +456 -0
  26. data/ext/bamtools/src/api/BamConstants.h +127 -0
  27. data/ext/bamtools/src/api/BamIndex.h +79 -0
  28. data/ext/bamtools/src/api/BamMultiReader.cpp +395 -0
  29. data/ext/bamtools/src/api/BamMultiReader.h +126 -0
  30. data/ext/bamtools/src/api/BamReader.cpp +369 -0
  31. data/ext/bamtools/src/api/BamReader.h +117 -0
  32. data/ext/bamtools/src/api/BamWriter.cpp +142 -0
  33. data/ext/bamtools/src/api/BamWriter.h +63 -0
  34. data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/DependInfo.cmake +14 -0
  35. data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/build.make +80 -0
  36. data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/cmake_clean.cmake +8 -0
  37. data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/depend.internal +3 -0
  38. data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/depend.make +3 -0
  39. data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/progress.make +2 -0
  40. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamAlignment.cpp.o +0 -0
  41. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamMultiReader.cpp.o +0 -0
  42. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamReader.cpp.o +0 -0
  43. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamWriter.cpp.o +0 -0
  44. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/CXX.includecache +596 -0
  45. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/DependInfo.cmake +41 -0
  46. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamHeader.cpp.o +0 -0
  47. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamProgram.cpp.o +0 -0
  48. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamProgramChain.cpp.o +0 -0
  49. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamReadGroup.cpp.o +0 -0
  50. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamReadGroupDictionary.cpp.o +0 -0
  51. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamSequence.cpp.o +0 -0
  52. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamSequenceDictionary.cpp.o +0 -0
  53. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/build.make +675 -0
  54. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/cmake_clean.cmake +32 -0
  55. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/cmake_clean_target.cmake +3 -0
  56. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/depend.internal +295 -0
  57. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/depend.make +295 -0
  58. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/flags.make +8 -0
  59. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamHeader_p.cpp.o +0 -0
  60. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamIndexFactory_p.cpp.o +0 -0
  61. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamMultiReader_p.cpp.o +0 -0
  62. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamRandomAccessController_p.cpp.o +0 -0
  63. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamReader_p.cpp.o +0 -0
  64. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamStandardIndex_p.cpp.o +0 -0
  65. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamToolsIndex_p.cpp.o +0 -0
  66. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamWriter_p.cpp.o +0 -0
  67. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BgzfStream_p.cpp.o +0 -0
  68. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/SamFormatParser_p.cpp.o +0 -0
  69. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/SamFormatPrinter_p.cpp.o +0 -0
  70. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/SamHeaderValidator_p.cpp.o +0 -0
  71. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/link.txt +2 -0
  72. data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/progress.make +24 -0
  73. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamAlignment.cpp.o +0 -0
  74. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamMultiReader.cpp.o +0 -0
  75. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamReader.cpp.o +0 -0
  76. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamWriter.cpp.o +0 -0
  77. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/CXX.includecache +596 -0
  78. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/DependInfo.cmake +47 -0
  79. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamHeader.cpp.o +0 -0
  80. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamProgram.cpp.o +0 -0
  81. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamProgramChain.cpp.o +0 -0
  82. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamReadGroup.cpp.o +0 -0
  83. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamReadGroupDictionary.cpp.o +0 -0
  84. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamSequence.cpp.o +0 -0
  85. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamSequenceDictionary.cpp.o +0 -0
  86. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/build.make +677 -0
  87. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/cmake_clean.cmake +33 -0
  88. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/depend.internal +295 -0
  89. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/depend.make +295 -0
  90. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/flags.make +8 -0
  91. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamHeader_p.cpp.o +0 -0
  92. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamIndexFactory_p.cpp.o +0 -0
  93. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamMultiReader_p.cpp.o +0 -0
  94. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamRandomAccessController_p.cpp.o +0 -0
  95. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamReader_p.cpp.o +0 -0
  96. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamStandardIndex_p.cpp.o +0 -0
  97. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamToolsIndex_p.cpp.o +0 -0
  98. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamWriter_p.cpp.o +0 -0
  99. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BgzfStream_p.cpp.o +0 -0
  100. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/SamFormatParser_p.cpp.o +0 -0
  101. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/SamFormatPrinter_p.cpp.o +0 -0
  102. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/SamHeaderValidator_p.cpp.o +0 -0
  103. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/link.txt +1 -0
  104. data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/progress.make +24 -0
  105. data/ext/bamtools/src/api/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
  106. data/ext/bamtools/src/api/CMakeFiles/progress.marks +1 -0
  107. data/ext/bamtools/src/api/CMakeLists.txt +78 -0
  108. data/ext/bamtools/src/api/Makefile +902 -0
  109. data/ext/bamtools/src/api/SamConstants.h +95 -0
  110. data/ext/bamtools/src/api/SamHeader.cpp +184 -0
  111. data/ext/bamtools/src/api/SamHeader.h +68 -0
  112. data/ext/bamtools/src/api/SamProgram.cpp +139 -0
  113. data/ext/bamtools/src/api/SamProgram.h +61 -0
  114. data/ext/bamtools/src/api/SamProgramChain.cpp +351 -0
  115. data/ext/bamtools/src/api/SamProgramChain.h +85 -0
  116. data/ext/bamtools/src/api/SamReadGroup.cpp +221 -0
  117. data/ext/bamtools/src/api/SamReadGroup.h +68 -0
  118. data/ext/bamtools/src/api/SamReadGroupDictionary.cpp +289 -0
  119. data/ext/bamtools/src/api/SamReadGroupDictionary.h +86 -0
  120. data/ext/bamtools/src/api/SamSequence.cpp +161 -0
  121. data/ext/bamtools/src/api/SamSequence.h +60 -0
  122. data/ext/bamtools/src/api/SamSequenceDictionary.cpp +292 -0
  123. data/ext/bamtools/src/api/SamSequenceDictionary.h +88 -0
  124. data/ext/bamtools/src/api/api_global.h +21 -0
  125. data/ext/bamtools/src/api/cmake_install.cmake +122 -0
  126. data/ext/bamtools/src/api/internal/BamHeader_p.cpp +132 -0
  127. data/ext/bamtools/src/api/internal/BamHeader_p.h +71 -0
  128. data/ext/bamtools/src/api/internal/BamIndexFactory_p.cpp +112 -0
  129. data/ext/bamtools/src/api/internal/BamIndexFactory_p.h +49 -0
  130. data/ext/bamtools/src/api/internal/BamMultiMerger_p.h +297 -0
  131. data/ext/bamtools/src/api/internal/BamMultiReader_p.cpp +805 -0
  132. data/ext/bamtools/src/api/internal/BamMultiReader_p.h +103 -0
  133. data/ext/bamtools/src/api/internal/BamRandomAccessController_p.cpp +272 -0
  134. data/ext/bamtools/src/api/internal/BamRandomAccessController_p.h +93 -0
  135. data/ext/bamtools/src/api/internal/BamReader_p.cpp +380 -0
  136. data/ext/bamtools/src/api/internal/BamReader_p.h +112 -0
  137. data/ext/bamtools/src/api/internal/BamStandardIndex_p.cpp +986 -0
  138. data/ext/bamtools/src/api/internal/BamStandardIndex_p.h +236 -0
  139. data/ext/bamtools/src/api/internal/BamToolsIndex_p.cpp +641 -0
  140. data/ext/bamtools/src/api/internal/BamToolsIndex_p.h +187 -0
  141. data/ext/bamtools/src/api/internal/BamWriter_p.cpp +424 -0
  142. data/ext/bamtools/src/api/internal/BamWriter_p.h +66 -0
  143. data/ext/bamtools/src/api/internal/BgzfStream_p.cpp +438 -0
  144. data/ext/bamtools/src/api/internal/BgzfStream_p.h +108 -0
  145. data/ext/bamtools/src/api/internal/SamFormatParser_p.cpp +230 -0
  146. data/ext/bamtools/src/api/internal/SamFormatParser_p.h +61 -0
  147. data/ext/bamtools/src/api/internal/SamFormatPrinter_p.cpp +210 -0
  148. data/ext/bamtools/src/api/internal/SamFormatPrinter_p.h +60 -0
  149. data/ext/bamtools/src/api/internal/SamHeaderValidator_p.cpp +510 -0
  150. data/ext/bamtools/src/api/internal/SamHeaderValidator_p.h +101 -0
  151. data/ext/bamtools/src/api/internal/SamHeaderVersion_p.h +134 -0
  152. data/ext/bamtools/src/cmake_install.cmake +42 -0
  153. data/ext/bamtools/src/shared/bamtools_global.h +78 -0
  154. data/ext/bamtools/src/third_party/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
  155. data/ext/bamtools/src/third_party/CMakeFiles/progress.marks +1 -0
  156. data/ext/bamtools/src/third_party/CMakeLists.txt +10 -0
  157. data/ext/bamtools/src/third_party/Makefile +167 -0
  158. data/ext/bamtools/src/third_party/cmake_install.cmake +35 -0
  159. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
  160. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/CXX.includecache +144 -0
  161. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/DependInfo.cmake +27 -0
  162. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/build.make +157 -0
  163. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/cmake_clean.cmake +13 -0
  164. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/depend.internal +31 -0
  165. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/depend.make +31 -0
  166. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/flags.make +8 -0
  167. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/json_reader.cpp.o +0 -0
  168. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/json_value.cpp.o +0 -0
  169. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/json_writer.cpp.o +0 -0
  170. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/link.txt +1 -0
  171. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/progress.make +4 -0
  172. data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/progress.marks +1 -0
  173. data/ext/bamtools/src/third_party/jsoncpp/CMakeLists.txt +23 -0
  174. data/ext/bamtools/src/third_party/jsoncpp/LICENSE +55 -0
  175. data/ext/bamtools/src/third_party/jsoncpp/Makefile +263 -0
  176. data/ext/bamtools/src/third_party/jsoncpp/cmake_install.cmake +29 -0
  177. data/ext/bamtools/src/third_party/jsoncpp/json.h +15 -0
  178. data/ext/bamtools/src/third_party/jsoncpp/json_batchallocator.h +130 -0
  179. data/ext/bamtools/src/third_party/jsoncpp/json_config.h +42 -0
  180. data/ext/bamtools/src/third_party/jsoncpp/json_features.h +47 -0
  181. data/ext/bamtools/src/third_party/jsoncpp/json_forwards.h +42 -0
  182. data/ext/bamtools/src/third_party/jsoncpp/json_internalarray.inl +453 -0
  183. data/ext/bamtools/src/third_party/jsoncpp/json_internalmap.inl +612 -0
  184. data/ext/bamtools/src/third_party/jsoncpp/json_reader.cpp +870 -0
  185. data/ext/bamtools/src/third_party/jsoncpp/json_reader.h +201 -0
  186. data/ext/bamtools/src/third_party/jsoncpp/json_tool.h +93 -0
  187. data/ext/bamtools/src/third_party/jsoncpp/json_value.cpp +1701 -0
  188. data/ext/bamtools/src/third_party/jsoncpp/json_value.h +1059 -0
  189. data/ext/bamtools/src/third_party/jsoncpp/json_valueiterator.inl +297 -0
  190. data/ext/bamtools/src/third_party/jsoncpp/json_writer.cpp +819 -0
  191. data/ext/bamtools/src/third_party/jsoncpp/json_writer.h +179 -0
  192. data/ext/bamtools/src/toolkit/CMakeFiles/CMakeDirectoryInformation.cmake +25 -0
  193. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/CXX.includecache +698 -0
  194. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/DependInfo.cmake +34 -0
  195. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools.cpp.o +0 -0
  196. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_convert.cpp.o +0 -0
  197. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_count.cpp.o +0 -0
  198. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_coverage.cpp.o +0 -0
  199. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_filter.cpp.o +0 -0
  200. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_header.cpp.o +0 -0
  201. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_index.cpp.o +0 -0
  202. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_merge.cpp.o +0 -0
  203. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_random.cpp.o +0 -0
  204. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_resolve.cpp.o +0 -0
  205. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_revert.cpp.o +0 -0
  206. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_sort.cpp.o +0 -0
  207. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_split.cpp.o +0 -0
  208. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_stats.cpp.o +0 -0
  209. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/build.make +447 -0
  210. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/cmake_clean.cmake +24 -0
  211. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/depend.internal +319 -0
  212. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/depend.make +319 -0
  213. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/flags.make +8 -0
  214. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/link.txt +1 -0
  215. data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/progress.make +15 -0
  216. data/ext/bamtools/src/toolkit/CMakeFiles/progress.marks +1 -0
  217. data/ext/bamtools/src/toolkit/CMakeLists.txt +44 -0
  218. data/ext/bamtools/src/toolkit/Makefile +560 -0
  219. data/ext/bamtools/src/toolkit/bamtools.cpp +163 -0
  220. data/ext/bamtools/src/toolkit/bamtools_convert.cpp +888 -0
  221. data/ext/bamtools/src/toolkit/bamtools_convert.h +37 -0
  222. data/ext/bamtools/src/toolkit/bamtools_count.cpp +187 -0
  223. data/ext/bamtools/src/toolkit/bamtools_count.h +37 -0
  224. data/ext/bamtools/src/toolkit/bamtools_coverage.cpp +196 -0
  225. data/ext/bamtools/src/toolkit/bamtools_coverage.h +37 -0
  226. data/ext/bamtools/src/toolkit/bamtools_filter.cpp +911 -0
  227. data/ext/bamtools/src/toolkit/bamtools_filter.h +37 -0
  228. data/ext/bamtools/src/toolkit/bamtools_header.cpp +122 -0
  229. data/ext/bamtools/src/toolkit/bamtools_header.h +38 -0
  230. data/ext/bamtools/src/toolkit/bamtools_index.cpp +126 -0
  231. data/ext/bamtools/src/toolkit/bamtools_index.h +37 -0
  232. data/ext/bamtools/src/toolkit/bamtools_merge.cpp +221 -0
  233. data/ext/bamtools/src/toolkit/bamtools_merge.h +37 -0
  234. data/ext/bamtools/src/toolkit/bamtools_random.cpp +255 -0
  235. data/ext/bamtools/src/toolkit/bamtools_random.h +37 -0
  236. data/ext/bamtools/src/toolkit/bamtools_resolve.cpp +1396 -0
  237. data/ext/bamtools/src/toolkit/bamtools_resolve.h +42 -0
  238. data/ext/bamtools/src/toolkit/bamtools_revert.cpp +194 -0
  239. data/ext/bamtools/src/toolkit/bamtools_revert.h +37 -0
  240. data/ext/bamtools/src/toolkit/bamtools_sort.cpp +410 -0
  241. data/ext/bamtools/src/toolkit/bamtools_sort.h +37 -0
  242. data/ext/bamtools/src/toolkit/bamtools_split.cpp +551 -0
  243. data/ext/bamtools/src/toolkit/bamtools_split.h +38 -0
  244. data/ext/bamtools/src/toolkit/bamtools_stats.cpp +286 -0
  245. data/ext/bamtools/src/toolkit/bamtools_stats.h +37 -0
  246. data/ext/bamtools/src/toolkit/bamtools_tool.h +35 -0
  247. data/ext/bamtools/src/toolkit/bamtools_version.h +20 -0
  248. data/ext/bamtools/src/toolkit/bamtools_version.h.in +20 -0
  249. data/ext/bamtools/src/toolkit/cmake_install.cmake +52 -0
  250. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/CXX.includecache +250 -0
  251. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/DependInfo.cmake +29 -0
  252. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_fasta.cpp.o +0 -0
  253. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_options.cpp.o +0 -0
  254. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_pileup_engine.cpp.o +0 -0
  255. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_utilities.cpp.o +0 -0
  256. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/build.make +184 -0
  257. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/cmake_clean.cmake +14 -0
  258. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/depend.internal +40 -0
  259. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/depend.make +40 -0
  260. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/flags.make +8 -0
  261. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/link.txt +1 -0
  262. data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/progress.make +5 -0
  263. data/ext/bamtools/src/utils/CMakeFiles/CMakeDirectoryInformation.cmake +23 -0
  264. data/ext/bamtools/src/utils/CMakeFiles/progress.marks +1 -0
  265. data/ext/bamtools/src/utils/CMakeLists.txt +30 -0
  266. data/ext/bamtools/src/utils/Makefile +290 -0
  267. data/ext/bamtools/src/utils/bamtools_fasta.cpp +632 -0
  268. data/ext/bamtools/src/utils/bamtools_fasta.h +47 -0
  269. data/ext/bamtools/src/utils/bamtools_filter_engine.h +552 -0
  270. data/ext/bamtools/src/utils/bamtools_filter_properties.h +195 -0
  271. data/ext/bamtools/src/utils/bamtools_filter_ruleparser.h +319 -0
  272. data/ext/bamtools/src/utils/bamtools_options.cpp +287 -0
  273. data/ext/bamtools/src/utils/bamtools_options.h +213 -0
  274. data/ext/bamtools/src/utils/bamtools_pileup_engine.cpp +327 -0
  275. data/ext/bamtools/src/utils/bamtools_pileup_engine.h +94 -0
  276. data/ext/bamtools/src/utils/bamtools_utilities.cpp +333 -0
  277. data/ext/bamtools/src/utils/bamtools_utilities.h +67 -0
  278. data/ext/bamtools/src/utils/bamtools_variant.h +128 -0
  279. data/ext/bamtools/src/utils/cmake_install.cmake +29 -0
  280. data/ext/bamtools/src/utils/utils_global.h +21 -0
  281. data/lib/ngs_server/version.rb +3 -0
  282. data/lib/ngs_server.rb +3 -0
  283. data/ngs_server.gemspec +23 -0
  284. metadata +339 -0
@@ -0,0 +1,911 @@
1
+ // ***************************************************************************
2
+ // bamtools_filter.cpp (c) 2010 Derek Barnett, Erik Garrison
3
+ // Marth Lab, Department of Biology, Boston College
4
+ // ---------------------------------------------------------------------------
5
+ // Last modified: 7 April 2011
6
+ // ---------------------------------------------------------------------------
7
+ // Filters BAM file(s) according to some user-specified criteria
8
+ // ***************************************************************************
9
+
10
+ #include "bamtools_filter.h"
11
+
12
+ #include <api/BamMultiReader.h>
13
+ #include <api/BamWriter.h>
14
+ #include <utils/bamtools_filter_engine.h>
15
+ #include <utils/bamtools_options.h>
16
+ #include <utils/bamtools_utilities.h>
17
+ using namespace BamTools;
18
+
19
+ #include <jsoncpp/json.h>
20
+ using namespace Json;
21
+
22
+ #include <cstdio>
23
+ #include <iostream>
24
+ #include <sstream>
25
+ #include <string>
26
+ #include <vector>
27
+ using namespace std;
28
+
29
+ namespace BamTools {
30
+
31
+ // -------------------------------
32
+ // string literal constants
33
+
34
+ // property names
35
+ const string ALIGNMENTFLAG_PROPERTY = "alignmentFlag";
36
+ const string CIGAR_PROPERTY = "cigar";
37
+ const string INSERTSIZE_PROPERTY = "insertSize";
38
+ const string ISDUPLICATE_PROPERTY = "isDuplicate";
39
+ const string ISFAILEDQC_PROPERTY = "isFailedQC";
40
+ const string ISFIRSTMATE_PROPERTY = "isFirstMate";
41
+ const string ISMAPPED_PROPERTY = "isMapped";
42
+ const string ISMATEMAPPED_PROPERTY = "isMateMapped";
43
+ const string ISMATEREVERSESTRAND_PROPERTY = "isMateReverseStrand";
44
+ const string ISPAIRED_PROPERTY = "isPaired";
45
+ const string ISPRIMARYALIGNMENT_PROPERTY = "isPrimaryAlignment";
46
+ const string ISPROPERPAIR_PROPERTY = "isProperPair";
47
+ const string ISREVERSESTRAND_PROPERTY = "isReverseStrand";
48
+ const string ISSECONDMATE_PROPERTY = "isSecondMate";
49
+ const string ISSINGLETON_PROPERTY = "isSingleton";
50
+ const string MAPQUALITY_PROPERTY = "mapQuality";
51
+ const string MATEPOSITION_PROPERTY = "matePosition";
52
+ const string MATEREFERENCE_PROPERTY = "mateReference";
53
+ const string NAME_PROPERTY = "name";
54
+ const string POSITION_PROPERTY = "position";
55
+ const string QUERYBASES_PROPERTY = "queryBases";
56
+ const string REFERENCE_PROPERTY = "reference";
57
+ const string TAG_PROPERTY = "tag";
58
+
59
+ // boolalpha
60
+ const string TRUE_STR = "true";
61
+ const string FALSE_STR = "false";
62
+
63
+ RefVector filterToolReferences;
64
+
65
+ struct BamAlignmentChecker {
66
+ bool check(const PropertyFilter& filter, const BamAlignment& al) {
67
+
68
+ bool keepAlignment = true;
69
+ const PropertyMap& properties = filter.Properties;
70
+ PropertyMap::const_iterator propertyIter = properties.begin();
71
+ PropertyMap::const_iterator propertyEnd = properties.end();
72
+ for ( ; propertyIter != propertyEnd; ++propertyIter ) {
73
+
74
+ // check alignment data field depending on propertyName
75
+ const string& propertyName = (*propertyIter).first;
76
+ const PropertyFilterValue& valueFilter = (*propertyIter).second;
77
+
78
+ if ( propertyName == ALIGNMENTFLAG_PROPERTY ) keepAlignment &= valueFilter.check(al.AlignmentFlag);
79
+ else if ( propertyName == CIGAR_PROPERTY ) {
80
+ stringstream cigarSs;
81
+ const vector<CigarOp>& cigarData = al.CigarData;
82
+ if ( !cigarData.empty() ) {
83
+ vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
84
+ vector<CigarOp>::const_iterator cigarIter = cigarBegin;
85
+ vector<CigarOp>::const_iterator cigarEnd = cigarData.end();
86
+ for ( ; cigarIter != cigarEnd; ++cigarIter ) {
87
+ const CigarOp& op = (*cigarIter);
88
+ cigarSs << op.Length << op.Type;
89
+ }
90
+ keepAlignment &= valueFilter.check(cigarSs.str());
91
+ }
92
+ }
93
+ else if ( propertyName == INSERTSIZE_PROPERTY ) keepAlignment &= valueFilter.check(al.InsertSize);
94
+ else if ( propertyName == ISDUPLICATE_PROPERTY ) keepAlignment &= valueFilter.check(al.IsDuplicate());
95
+ else if ( propertyName == ISFAILEDQC_PROPERTY ) keepAlignment &= valueFilter.check(al.IsFailedQC());
96
+ else if ( propertyName == ISFIRSTMATE_PROPERTY ) keepAlignment &= valueFilter.check(al.IsFirstMate());
97
+ else if ( propertyName == ISMAPPED_PROPERTY ) keepAlignment &= valueFilter.check(al.IsMapped());
98
+ else if ( propertyName == ISMATEMAPPED_PROPERTY ) keepAlignment &= valueFilter.check(al.IsMateMapped());
99
+ else if ( propertyName == ISMATEREVERSESTRAND_PROPERTY ) keepAlignment &= valueFilter.check(al.IsMateReverseStrand());
100
+ else if ( propertyName == ISPAIRED_PROPERTY ) keepAlignment &= valueFilter.check(al.IsPaired());
101
+ else if ( propertyName == ISPRIMARYALIGNMENT_PROPERTY ) keepAlignment &= valueFilter.check(al.IsPrimaryAlignment());
102
+ else if ( propertyName == ISPROPERPAIR_PROPERTY ) keepAlignment &= valueFilter.check(al.IsProperPair());
103
+ else if ( propertyName == ISREVERSESTRAND_PROPERTY ) keepAlignment &= valueFilter.check(al.IsReverseStrand());
104
+ else if ( propertyName == ISSECONDMATE_PROPERTY ) keepAlignment &= valueFilter.check(al.IsSecondMate());
105
+ else if ( propertyName == ISSINGLETON_PROPERTY ) {
106
+ const bool isSingleton = al.IsPaired() && al.IsMapped() && !al.IsMateMapped();
107
+ keepAlignment &= valueFilter.check(isSingleton);
108
+ }
109
+ else if ( propertyName == MAPQUALITY_PROPERTY ) keepAlignment &= valueFilter.check(al.MapQuality);
110
+ else if ( propertyName == MATEPOSITION_PROPERTY ) keepAlignment &= ( al.IsPaired() && al.IsMateMapped() && valueFilter.check(al.MateRefID) );
111
+ else if ( propertyName == MATEREFERENCE_PROPERTY ) {
112
+ if ( !al.IsPaired() || !al.IsMateMapped() ) return false;
113
+ BAMTOOLS_ASSERT_MESSAGE( (al.MateRefID>=0 && (al.MateRefID<(int)filterToolReferences.size())), "Invalid MateRefID");
114
+ const string& refName = filterToolReferences.at(al.MateRefID).RefName;
115
+ keepAlignment &= valueFilter.check(refName);
116
+ }
117
+ else if ( propertyName == NAME_PROPERTY ) keepAlignment &= valueFilter.check(al.Name);
118
+ else if ( propertyName == POSITION_PROPERTY ) keepAlignment &= valueFilter.check(al.Position);
119
+ else if ( propertyName == QUERYBASES_PROPERTY ) keepAlignment &= valueFilter.check(al.QueryBases);
120
+ else if ( propertyName == REFERENCE_PROPERTY ) {
121
+ BAMTOOLS_ASSERT_MESSAGE( (al.RefID>=0 && (al.RefID<(int)filterToolReferences.size())), "Invalid RefID");
122
+ const string& refName = filterToolReferences.at(al.RefID).RefName;
123
+ keepAlignment &= valueFilter.check(refName);
124
+ }
125
+ else if ( propertyName == TAG_PROPERTY ) keepAlignment &= checkAlignmentTag(valueFilter, al);
126
+ else BAMTOOLS_ASSERT_UNREACHABLE;
127
+
128
+ // if alignment fails at ANY point, just quit and return false
129
+ if ( !keepAlignment ) return false;
130
+ }
131
+
132
+ BAMTOOLS_ASSERT_MESSAGE( keepAlignment, "Error in BamAlignmentChecker... keepAlignment should be true here");
133
+ return keepAlignment;
134
+ }
135
+
136
+ bool checkAlignmentTag(const PropertyFilterValue& valueFilter, const BamAlignment& al) {
137
+
138
+ // ensure filter contains string data
139
+ Variant entireTagFilter = valueFilter.Value;
140
+ if ( !entireTagFilter.is_type<string>() ) return false;
141
+
142
+ // localize string from variant
143
+ const string& entireTagFilterString = entireTagFilter.get<string>();
144
+
145
+ // ensure we have at least "XX:x"
146
+ if ( entireTagFilterString.length() < 4 ) return false;
147
+
148
+ // get tagName & lookup in alignment
149
+ // if found, set tagType to tag type character
150
+ // if not found, return false
151
+ const string& tagName = entireTagFilterString.substr(0,2);
152
+ char tagType = '\0';
153
+ if ( !al.GetTagType(tagName, tagType) ) return false;
154
+
155
+ // remove tagName & ":" from beginning tagFilter
156
+ string tagFilterString = entireTagFilterString.substr(3);
157
+
158
+ // switch on tag type to set tag query value & parse filter token
159
+ int32_t intFilterValue, intQueryValue;
160
+ uint32_t uintFilterValue, uintQueryValue;
161
+ float realFilterValue, realQueryValue;
162
+ string stringFilterValue, stringQueryValue;
163
+
164
+ PropertyFilterValue tagFilter;
165
+ PropertyFilterValue::ValueCompareType compareType;
166
+ bool keepAlignment = false;
167
+ switch (tagType) {
168
+
169
+ // signed int tag type
170
+ case 'c' :
171
+ case 's' :
172
+ case 'i' :
173
+ if ( al.GetTag(tagName, intQueryValue) ) {
174
+ if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, intFilterValue, compareType) ) {
175
+ tagFilter.Value = intFilterValue;
176
+ tagFilter.Type = compareType;
177
+ keepAlignment = tagFilter.check(intQueryValue);
178
+ }
179
+ }
180
+ break;
181
+
182
+ // unsigned int tag type
183
+ case 'C' :
184
+ case 'S' :
185
+ case 'I' :
186
+ if ( al.GetTag(tagName, uintQueryValue) ) {
187
+ if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, uintFilterValue, compareType) ) {
188
+ tagFilter.Value = uintFilterValue;
189
+ tagFilter.Type = compareType;
190
+ keepAlignment = tagFilter.check(uintQueryValue);
191
+ }
192
+ }
193
+ break;
194
+
195
+ // 'real' tag type
196
+ case 'f' :
197
+ if ( al.GetTag(tagName, realQueryValue) ) {
198
+ if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, realFilterValue, compareType) ) {
199
+ tagFilter.Value = realFilterValue;
200
+ tagFilter.Type = compareType;
201
+ keepAlignment = tagFilter.check(realQueryValue);
202
+ }
203
+ }
204
+ break;
205
+
206
+ // string tag type
207
+ case 'A':
208
+ case 'Z':
209
+ case 'H':
210
+ if ( al.GetTag(tagName, stringQueryValue) ) {
211
+ if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, stringFilterValue, compareType) ) {
212
+ tagFilter.Value = stringFilterValue;
213
+ tagFilter.Type = compareType;
214
+ keepAlignment = tagFilter.check(stringQueryValue);
215
+ }
216
+ }
217
+ break;
218
+
219
+ // unknown tag type
220
+ default :
221
+ keepAlignment = false;
222
+ }
223
+
224
+ return keepAlignment;
225
+ }
226
+ };
227
+
228
+ } // namespace BamTools
229
+
230
+ // ---------------------------------------------
231
+ // FilterSettings implementation
232
+
233
+ struct FilterTool::FilterSettings {
234
+
235
+ // ----------------------------------
236
+ // IO opts
237
+
238
+ // flags
239
+ bool HasInputBamFilename;
240
+ bool HasOutputBamFilename;
241
+ bool HasRegion;
242
+ bool HasScriptFilename;
243
+ bool IsForceCompression;
244
+
245
+ // filenames
246
+ vector<string> InputFiles;
247
+ string OutputFilename;
248
+ string Region;
249
+ string ScriptFilename;
250
+
251
+ // -----------------------------------
252
+ // General filter opts
253
+
254
+ // flags
255
+ bool HasAlignmentFlagFilter;
256
+ bool HasInsertSizeFilter;
257
+ bool HasMapQualityFilter;
258
+ bool HasNameFilter;
259
+ bool HasQueryBasesFilter;
260
+ bool HasTagFilter; //(s)
261
+
262
+ // filters
263
+ string AlignmentFlagFilter;
264
+ string InsertSizeFilter;
265
+ string NameFilter;
266
+ string MapQualityFilter;
267
+ string QueryBasesFilter;
268
+ string TagFilter; // support multiple ?
269
+
270
+ // -----------------------------------
271
+ // AlignmentFlag filter opts
272
+
273
+ // flags
274
+ bool HasIsDuplicateFilter;
275
+ bool HasIsFailedQCFilter;
276
+ bool HasIsFirstMateFilter;
277
+ bool HasIsMappedFilter;
278
+ bool HasIsMateMappedFilter;
279
+ bool HasIsMateReverseStrandFilter;
280
+ bool HasIsPairedFilter;
281
+ bool HasIsPrimaryAlignmentFilter;
282
+ bool HasIsProperPairFilter;
283
+ bool HasIsReverseStrandFilter;
284
+ bool HasIsSecondMateFilter;
285
+ bool HasIsSingletonFilter;
286
+
287
+ // filters
288
+ string IsDuplicateFilter;
289
+ string IsFailedQCFilter;
290
+ string IsFirstMateFilter;
291
+ string IsMappedFilter;
292
+ string IsMateMappedFilter;
293
+ string IsMateReverseStrandFilter;
294
+ string IsPairedFilter;
295
+ string IsPrimaryAlignmentFilter;
296
+ string IsProperPairFilter;
297
+ string IsReverseStrandFilter;
298
+ string IsSecondMateFilter;
299
+ string IsSingletonFilter;
300
+
301
+ // ---------------------------------
302
+ // constructor
303
+
304
+ FilterSettings(void)
305
+ : HasInputBamFilename(false)
306
+ , HasOutputBamFilename(false)
307
+ , HasRegion(false)
308
+ , HasScriptFilename(false)
309
+ , IsForceCompression(false)
310
+ , OutputFilename(Options::StandardOut())
311
+ , HasAlignmentFlagFilter(false)
312
+ , HasInsertSizeFilter(false)
313
+ , HasMapQualityFilter(false)
314
+ , HasNameFilter(false)
315
+ , HasQueryBasesFilter(false)
316
+ , HasTagFilter(false)
317
+ , HasIsDuplicateFilter(false)
318
+ , HasIsFailedQCFilter(false)
319
+ , HasIsFirstMateFilter(false)
320
+ , HasIsMappedFilter(false)
321
+ , HasIsMateMappedFilter(false)
322
+ , HasIsMateReverseStrandFilter(false)
323
+ , HasIsPairedFilter(false)
324
+ , HasIsPrimaryAlignmentFilter(false)
325
+ , HasIsProperPairFilter(false)
326
+ , HasIsReverseStrandFilter(false)
327
+ , HasIsSecondMateFilter(false)
328
+ , HasIsSingletonFilter(false)
329
+ , IsDuplicateFilter(TRUE_STR)
330
+ , IsFailedQCFilter(TRUE_STR)
331
+ , IsFirstMateFilter(TRUE_STR)
332
+ , IsMappedFilter(TRUE_STR)
333
+ , IsMateMappedFilter(TRUE_STR)
334
+ , IsMateReverseStrandFilter(TRUE_STR)
335
+ , IsPairedFilter(TRUE_STR)
336
+ , IsPrimaryAlignmentFilter(TRUE_STR)
337
+ , IsProperPairFilter(TRUE_STR)
338
+ , IsReverseStrandFilter(TRUE_STR)
339
+ , IsSecondMateFilter(TRUE_STR)
340
+ , IsSingletonFilter(TRUE_STR)
341
+ { }
342
+ };
343
+
344
+ // ---------------------------------------------
345
+ // FilterToolPrivate declaration
346
+
347
+ class FilterTool::FilterToolPrivate {
348
+
349
+ // ctor & dtor
350
+ public:
351
+ FilterToolPrivate(FilterTool::FilterSettings* settings);
352
+ ~FilterToolPrivate(void);
353
+
354
+ // 'public' interface
355
+ public:
356
+ bool Run(void);
357
+
358
+ // internal methods
359
+ private:
360
+ bool AddPropertyTokensToFilter(const string& filterName, const map<string, string>& propertyTokens);
361
+ bool CheckAlignment(const BamAlignment& al);
362
+ const string GetScriptContents(void);
363
+ void InitProperties(void);
364
+ bool ParseCommandLine(void);
365
+ bool ParseFilterObject(const string& filterName, const Json::Value& filterObject);
366
+ bool ParseScript(void);
367
+ bool SetupFilters(void);
368
+
369
+ // data members
370
+ private:
371
+ vector<string> m_propertyNames;
372
+ FilterTool::FilterSettings* m_settings;
373
+ FilterEngine<BamAlignmentChecker> m_filterEngine;
374
+ };
375
+
376
+ // ---------------------------------------------
377
+ // FilterToolPrivate implementation
378
+
379
+ // constructor
380
+ FilterTool::FilterToolPrivate::FilterToolPrivate(FilterTool::FilterSettings* settings)
381
+ : m_settings(settings)
382
+ { }
383
+
384
+ // destructor
385
+ FilterTool::FilterToolPrivate::~FilterToolPrivate(void) { }
386
+
387
+ bool FilterTool::FilterToolPrivate::AddPropertyTokensToFilter(const string& filterName,
388
+ const map<string,
389
+ string>& propertyTokens)
390
+ {
391
+ // dummy temp values for token parsing
392
+ bool boolValue;
393
+ int32_t int32Value;
394
+ uint16_t uint16Value;
395
+ uint32_t uint32Value;
396
+ string stringValue;
397
+ PropertyFilterValue::ValueCompareType type;
398
+
399
+ // iterate over property token map
400
+ map<string, string>::const_iterator mapIter = propertyTokens.begin();
401
+ map<string, string>::const_iterator mapEnd = propertyTokens.end();
402
+ for ( ; mapIter != mapEnd; ++mapIter ) {
403
+
404
+ const string& propertyName = (*mapIter).first;
405
+ const string& token = (*mapIter).second;
406
+
407
+ // ------------------------------
408
+ // convert token to value & compare type
409
+ // then add to filter engine
410
+
411
+ // bool conversion
412
+ if ( propertyName == ISDUPLICATE_PROPERTY ||
413
+ propertyName == ISFAILEDQC_PROPERTY ||
414
+ propertyName == ISFIRSTMATE_PROPERTY ||
415
+ propertyName == ISMAPPED_PROPERTY ||
416
+ propertyName == ISMATEMAPPED_PROPERTY ||
417
+ propertyName == ISMATEREVERSESTRAND_PROPERTY ||
418
+ propertyName == ISPAIRED_PROPERTY ||
419
+ propertyName == ISPRIMARYALIGNMENT_PROPERTY ||
420
+ propertyName == ISPROPERPAIR_PROPERTY ||
421
+ propertyName == ISREVERSESTRAND_PROPERTY ||
422
+ propertyName == ISSECONDMATE_PROPERTY ||
423
+ propertyName == ISSINGLETON_PROPERTY
424
+ )
425
+ {
426
+ FilterEngine<BamAlignmentChecker>::parseToken(token, boolValue, type);
427
+ m_filterEngine.setProperty(filterName, propertyName, boolValue, type);
428
+ }
429
+
430
+ // int32_t conversion
431
+ else if ( propertyName == INSERTSIZE_PROPERTY ||
432
+ propertyName == MATEPOSITION_PROPERTY ||
433
+ propertyName == POSITION_PROPERTY
434
+ )
435
+ {
436
+ FilterEngine<BamAlignmentChecker>::parseToken(token, int32Value, type);
437
+ m_filterEngine.setProperty(filterName, propertyName, int32Value, type);
438
+ }
439
+
440
+ // uint16_t conversion
441
+ else if ( propertyName == MAPQUALITY_PROPERTY )
442
+ {
443
+ FilterEngine<BamAlignmentChecker>::parseToken(token, uint16Value, type);
444
+ m_filterEngine.setProperty(filterName, propertyName, uint16Value, type);
445
+ }
446
+
447
+ // uint32_t conversion
448
+ else if ( propertyName == ALIGNMENTFLAG_PROPERTY )
449
+ {
450
+ FilterEngine<BamAlignmentChecker>::parseToken(token, uint32Value, type);
451
+ m_filterEngine.setProperty(filterName, propertyName, uint32Value, type);
452
+ }
453
+
454
+ // string conversion
455
+ else if ( propertyName == CIGAR_PROPERTY ||
456
+ propertyName == MATEREFERENCE_PROPERTY ||
457
+ propertyName == NAME_PROPERTY ||
458
+ propertyName == QUERYBASES_PROPERTY ||
459
+ propertyName == REFERENCE_PROPERTY
460
+ )
461
+ {
462
+ FilterEngine<BamAlignmentChecker>::parseToken(token, stringValue, type);
463
+ m_filterEngine.setProperty(filterName, propertyName, stringValue, type);
464
+ }
465
+
466
+ else if ( propertyName == TAG_PROPERTY ) {
467
+ // this will be stored directly as the TAG:VALUE token
468
+ // (VALUE may contain compare ops, will be parsed out later)
469
+ m_filterEngine.setProperty(filterName, propertyName, token, PropertyFilterValue::EXACT);
470
+ }
471
+
472
+ // else unknown property
473
+ else {
474
+ cerr << "bamtools filter ERROR: unknown property - " << propertyName << endl;
475
+ return false;
476
+ }
477
+ }
478
+ return true;
479
+ }
480
+
481
+ bool FilterTool::FilterToolPrivate::CheckAlignment(const BamAlignment& al) {
482
+ return m_filterEngine.check(al);
483
+ }
484
+
485
+ const string FilterTool::FilterToolPrivate::GetScriptContents(void) {
486
+
487
+ // open script for reading
488
+ FILE* inFile = fopen(m_settings->ScriptFilename.c_str(), "rb");
489
+ if ( !inFile ) {
490
+ cerr << "bamtools filter ERROR: could not open script: "
491
+ << m_settings->ScriptFilename << " for reading" << endl;
492
+ return false;
493
+ }
494
+
495
+ // read in entire script contents
496
+ char buffer[1024];
497
+ ostringstream docStream("");
498
+ while ( true ) {
499
+
500
+ // peek ahead, make sure there is data available
501
+ char ch = fgetc(inFile);
502
+ ungetc(ch, inFile);
503
+ if( feof(inFile) ) break;
504
+
505
+ // read next block of data
506
+ if ( fgets(buffer, 1024, inFile) == 0 ) {
507
+ cerr << "bamtools filter ERROR: could not read script contents" << endl;
508
+ return false;
509
+ }
510
+
511
+ docStream << buffer;
512
+ }
513
+
514
+ // close script file
515
+ fclose(inFile);
516
+
517
+ // import buffer contents to document, return
518
+ string document = docStream.str();
519
+ return document;
520
+ }
521
+
522
+ void FilterTool::FilterToolPrivate::InitProperties(void) {
523
+
524
+ // store property names in vector
525
+ m_propertyNames.push_back(ALIGNMENTFLAG_PROPERTY);
526
+ m_propertyNames.push_back(CIGAR_PROPERTY);
527
+ m_propertyNames.push_back(INSERTSIZE_PROPERTY);
528
+ m_propertyNames.push_back(ISDUPLICATE_PROPERTY);
529
+ m_propertyNames.push_back(ISFAILEDQC_PROPERTY);
530
+ m_propertyNames.push_back(ISFIRSTMATE_PROPERTY);
531
+ m_propertyNames.push_back(ISMAPPED_PROPERTY);
532
+ m_propertyNames.push_back(ISMATEMAPPED_PROPERTY);
533
+ m_propertyNames.push_back(ISMATEREVERSESTRAND_PROPERTY);
534
+ m_propertyNames.push_back(ISPAIRED_PROPERTY);
535
+ m_propertyNames.push_back(ISPRIMARYALIGNMENT_PROPERTY);
536
+ m_propertyNames.push_back(ISPROPERPAIR_PROPERTY);
537
+ m_propertyNames.push_back(ISREVERSESTRAND_PROPERTY);
538
+ m_propertyNames.push_back(ISSECONDMATE_PROPERTY);
539
+ m_propertyNames.push_back(ISSINGLETON_PROPERTY);
540
+ m_propertyNames.push_back(MAPQUALITY_PROPERTY);
541
+ m_propertyNames.push_back(MATEPOSITION_PROPERTY);
542
+ m_propertyNames.push_back(MATEREFERENCE_PROPERTY);
543
+ m_propertyNames.push_back(NAME_PROPERTY);
544
+ m_propertyNames.push_back(POSITION_PROPERTY);
545
+ m_propertyNames.push_back(QUERYBASES_PROPERTY);
546
+ m_propertyNames.push_back(REFERENCE_PROPERTY);
547
+ m_propertyNames.push_back(TAG_PROPERTY);
548
+
549
+ // add vector contents to FilterEngine<BamAlignmentChecker>
550
+ vector<string>::const_iterator propertyNameIter = m_propertyNames.begin();
551
+ vector<string>::const_iterator propertyNameEnd = m_propertyNames.end();
552
+ for ( ; propertyNameIter != propertyNameEnd; ++propertyNameIter )
553
+ m_filterEngine.addProperty((*propertyNameIter));
554
+ }
555
+
556
+ bool FilterTool::FilterToolPrivate::ParseCommandLine(void) {
557
+
558
+ // add a rule set to filter engine
559
+ const string CMD = "COMMAND_LINE";
560
+ m_filterEngine.addFilter(CMD);
561
+
562
+ // map property names to command line args
563
+ map<string, string> propertyTokens;
564
+ if ( m_settings->HasAlignmentFlagFilter ) propertyTokens.insert( make_pair(ALIGNMENTFLAG_PROPERTY, m_settings->AlignmentFlagFilter) );
565
+ if ( m_settings->HasInsertSizeFilter ) propertyTokens.insert( make_pair(INSERTSIZE_PROPERTY, m_settings->InsertSizeFilter) );
566
+ if ( m_settings->HasIsDuplicateFilter ) propertyTokens.insert( make_pair(ISDUPLICATE_PROPERTY, m_settings->IsDuplicateFilter) );
567
+ if ( m_settings->HasIsFailedQCFilter ) propertyTokens.insert( make_pair(ISFAILEDQC_PROPERTY, m_settings->IsFailedQCFilter) );
568
+ if ( m_settings->HasIsFirstMateFilter ) propertyTokens.insert( make_pair(ISFIRSTMATE_PROPERTY, m_settings->IsFirstMateFilter) );
569
+ if ( m_settings->HasIsMappedFilter ) propertyTokens.insert( make_pair(ISMAPPED_PROPERTY, m_settings->IsMappedFilter) );
570
+ if ( m_settings->HasIsMateMappedFilter ) propertyTokens.insert( make_pair(ISMATEMAPPED_PROPERTY, m_settings->IsMateMappedFilter) );
571
+ if ( m_settings->HasIsMateReverseStrandFilter ) propertyTokens.insert( make_pair(ISMATEREVERSESTRAND_PROPERTY, m_settings->IsMateReverseStrandFilter) );
572
+ if ( m_settings->HasIsPairedFilter ) propertyTokens.insert( make_pair(ISPAIRED_PROPERTY, m_settings->IsPairedFilter) );
573
+ if ( m_settings->HasIsPrimaryAlignmentFilter ) propertyTokens.insert( make_pair(ISPRIMARYALIGNMENT_PROPERTY, m_settings->IsPrimaryAlignmentFilter) );
574
+ if ( m_settings->HasIsProperPairFilter ) propertyTokens.insert( make_pair(ISPROPERPAIR_PROPERTY, m_settings->IsProperPairFilter) );
575
+ if ( m_settings->HasIsReverseStrandFilter ) propertyTokens.insert( make_pair(ISREVERSESTRAND_PROPERTY, m_settings->IsReverseStrandFilter) );
576
+ if ( m_settings->HasIsSecondMateFilter ) propertyTokens.insert( make_pair(ISSECONDMATE_PROPERTY, m_settings->IsSecondMateFilter) );
577
+ if ( m_settings->HasIsSingletonFilter ) propertyTokens.insert( make_pair(ISSINGLETON_PROPERTY, m_settings->IsSingletonFilter) );
578
+ if ( m_settings->HasMapQualityFilter ) propertyTokens.insert( make_pair(MAPQUALITY_PROPERTY, m_settings->MapQualityFilter) );
579
+ if ( m_settings->HasNameFilter ) propertyTokens.insert( make_pair(NAME_PROPERTY, m_settings->NameFilter) );
580
+ if ( m_settings->HasQueryBasesFilter ) propertyTokens.insert( make_pair(QUERYBASES_PROPERTY, m_settings->QueryBasesFilter) );
581
+ if ( m_settings->HasTagFilter ) propertyTokens.insert( make_pair(TAG_PROPERTY, m_settings->TagFilter) );
582
+
583
+ // send add these properties to filter set "COMMAND_LINE"
584
+ return AddPropertyTokensToFilter(CMD, propertyTokens);
585
+ }
586
+
587
+ bool FilterTool::FilterToolPrivate::ParseFilterObject(const string& filterName, const Json::Value& filterObject) {
588
+
589
+ // filter object parsing variables
590
+ Json::Value null(Json::nullValue);
591
+ Json::Value propertyValue;
592
+
593
+ // store results
594
+ map<string, string> propertyTokens;
595
+
596
+ // iterate over known properties
597
+ vector<string>::const_iterator propertyNameIter = m_propertyNames.begin();
598
+ vector<string>::const_iterator propertyNameEnd = m_propertyNames.end();
599
+ for ( ; propertyNameIter != propertyNameEnd; ++propertyNameIter ) {
600
+ const string& propertyName = (*propertyNameIter);
601
+
602
+ // if property defined in filter, add to token list
603
+ propertyValue = filterObject.get(propertyName, null);
604
+ if ( propertyValue != null )
605
+ propertyTokens.insert( make_pair(propertyName, propertyValue.asString()) );
606
+ }
607
+
608
+ // add this filter to engin
609
+ m_filterEngine.addFilter(filterName);
610
+
611
+ // add token list to this filter
612
+ return AddPropertyTokensToFilter(filterName, propertyTokens);
613
+ }
614
+
615
+ bool FilterTool::FilterToolPrivate::ParseScript(void) {
616
+
617
+ // read in script contents from file
618
+ const string document = GetScriptContents();
619
+
620
+ // set up JsonCPP reader and attempt to parse script
621
+ Json::Value root;
622
+ Json::Reader reader;
623
+ if ( !reader.parse(document, root) ) {
624
+ // use built-in error reporting mechanism to alert user what was wrong with the script
625
+ cerr << "bamtools filter ERROR: failed to parse script - see error message(s) below" << endl
626
+ << reader.getFormatedErrorMessages();
627
+ return false;
628
+ }
629
+
630
+ // initialize return status
631
+ bool success = true;
632
+
633
+ // see if root object contains multiple filters
634
+ const Json::Value filters = root["filters"];
635
+ if ( !filters.isNull() ) {
636
+
637
+ // iterate over any filters found
638
+ int filterIndex = 0;
639
+ Json::Value::const_iterator filtersIter = filters.begin();
640
+ Json::Value::const_iterator filtersEnd = filters.end();
641
+ for ( ; filtersIter != filtersEnd; ++filtersIter, ++filterIndex ) {
642
+ Json::Value filter = (*filtersIter);
643
+
644
+ // convert filter index to string
645
+ string filterName;
646
+
647
+ // if id tag supplied
648
+ const Json::Value id = filter["id"];
649
+ if ( !id.isNull() )
650
+ filterName = id.asString();
651
+
652
+ // use array index
653
+ else {
654
+ stringstream convert;
655
+ convert << filterIndex;
656
+ filterName = convert.str();
657
+ }
658
+
659
+ // create & parse filter
660
+ success &= ParseFilterObject(filterName, filter);
661
+ }
662
+
663
+ // see if user defined a "rule" for these filters
664
+ // otherwise, use filter engine's default rule behavior
665
+ string ruleString("");
666
+ const Json::Value rule = root["rule"];
667
+ if ( rule.isString() )
668
+ ruleString = rule.asString();
669
+ m_filterEngine.setRule(ruleString);
670
+
671
+ // return success/fail
672
+ return success;
673
+ }
674
+
675
+ // otherwise, root is the only filter (just contains properties)
676
+ // create & parse filter named "ROOT"
677
+ else success = ParseFilterObject("ROOT", root);
678
+
679
+ // return success/failure
680
+ return success;
681
+ }
682
+
683
+ bool FilterTool::FilterToolPrivate::Run(void) {
684
+
685
+ // set to default input if none provided
686
+ if ( !m_settings->HasInputBamFilename )
687
+ m_settings->InputFiles.push_back(Options::StandardIn());
688
+
689
+ // initialize defined properties & user-specified filters
690
+ // quit if failed
691
+ if ( !SetupFilters() ) return false;
692
+
693
+ // open reader without index
694
+ BamMultiReader reader;
695
+ if ( !reader.Open(m_settings->InputFiles) ) {
696
+ cerr << "bamtools filter ERROR: could not open input files for reading." << endl;
697
+ return false;
698
+ }
699
+
700
+ // retrieve reader header & reference data
701
+ const string headerText = reader.GetHeaderText();
702
+ filterToolReferences = reader.GetReferenceData();
703
+
704
+ // determine compression mode for BamWriter
705
+ bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
706
+ !m_settings->IsForceCompression );
707
+ BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
708
+ if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
709
+
710
+ // open BamWriter
711
+ BamWriter writer;
712
+ writer.SetCompressionMode(compressionMode);
713
+ if ( !writer.Open(m_settings->OutputFilename, headerText, filterToolReferences) ) {
714
+ cerr << "bamtools filter ERROR: could not open " << m_settings->OutputFilename << " for writing." << endl;
715
+ reader.Close();
716
+ return false;
717
+ }
718
+
719
+ // if no region specified, filter entire file
720
+ BamAlignment al;
721
+ if ( !m_settings->HasRegion ) {
722
+ while ( reader.GetNextAlignment(al) ) {
723
+ if ( CheckAlignment(al) )
724
+ writer.SaveAlignment(al);
725
+ }
726
+ }
727
+
728
+ // otherwise attempt to use region as constraint
729
+ else {
730
+
731
+ // if region string parses OK
732
+ BamRegion region;
733
+ if ( Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
734
+
735
+ // attempt to find index files
736
+ reader.LocateIndexes();
737
+
738
+ // if index data available for all BAM files, we can use SetRegion
739
+ if ( reader.HasIndexes() ) {
740
+
741
+ // attempt to use SetRegion(), if failed report error
742
+ if ( !reader.SetRegion(region.LeftRefID, region.LeftPosition, region.RightRefID, region.RightPosition) ) {
743
+ cerr << "bamtools filter ERROR: set region failed. Check that REGION describes a valid range" << endl;
744
+ reader.Close();
745
+ return false;
746
+ }
747
+
748
+ // everything checks out, just iterate through specified region, filtering alignments
749
+ while ( reader.GetNextAlignment(al) )
750
+ if ( CheckAlignment(al) )
751
+ writer.SaveAlignment(al);
752
+ }
753
+
754
+ // no index data available, we have to iterate through until we
755
+ // find overlapping alignments
756
+ else {
757
+ while ( reader.GetNextAlignment(al) ) {
758
+ if ( (al.RefID >= region.LeftRefID) && ((al.Position + al.Length) >= region.LeftPosition) &&
759
+ (al.RefID <= region.RightRefID) && ( al.Position <= region.RightPosition) )
760
+ {
761
+ if ( CheckAlignment(al) )
762
+ writer.SaveAlignment(al);
763
+ }
764
+ }
765
+ }
766
+ }
767
+
768
+ // error parsing REGION string
769
+ else {
770
+ cerr << "bamtools filter ERROR: could not parse REGION: " << m_settings->Region << endl;
771
+ cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
772
+ << endl;
773
+ reader.Close();
774
+ return false;
775
+ }
776
+ }
777
+
778
+ // clean up & exit
779
+ reader.Close();
780
+ writer.Close();
781
+ return true;
782
+ }
783
+
784
+ bool FilterTool::FilterToolPrivate::SetupFilters(void) {
785
+
786
+ // set up filter engine with supported properties
787
+ InitProperties();
788
+
789
+ // parse script for filter rules, if given
790
+ if ( m_settings->HasScriptFilename )
791
+ return ParseScript();
792
+
793
+ // otherwise check command line for filters
794
+ else return ParseCommandLine();
795
+ }
796
+
797
+ // ---------------------------------------------
798
+ // FilterTool implementation
799
+
800
+ FilterTool::FilterTool(void)
801
+ : AbstractTool()
802
+ , m_settings(new FilterSettings)
803
+ , m_impl(0)
804
+ {
805
+ // ----------------------------------
806
+ // set program details
807
+
808
+ const string usage = "[-in <filename> -in <filename> ...] "
809
+ "[-out <filename> | [-forceCompression]] [-region <REGION>] "
810
+ "[ [-script <filename] | [filterOptions] ]";
811
+ Options::SetProgramInfo("bamtools filter", "filters BAM file(s)", usage );
812
+
813
+ // ----------------------------------
814
+ // I/O options
815
+
816
+ OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
817
+
818
+ const string inDesc = "the input BAM file(s)";
819
+ const string outDesc = "the output BAM file";
820
+ const string regionDesc = "only read data from this genomic region (see documentation for more details)";
821
+ const string scriptDesc = "the filter script file (see documentation for more details)";
822
+ const string forceDesc = "if results are sent to stdout (like when piping to another tool), "
823
+ "default behavior is to leave output uncompressed. Use this flag to "
824
+ "override and force compression";
825
+
826
+ Options::AddValueOption("-in", "BAM filename", inDesc, "", m_settings->HasInputBamFilename, m_settings->InputFiles, IO_Opts, Options::StandardIn());
827
+ Options::AddValueOption("-out", "BAM filename", outDesc, "", m_settings->HasOutputBamFilename, m_settings->OutputFilename, IO_Opts, Options::StandardOut());
828
+ Options::AddValueOption("-region", "REGION", regionDesc, "", m_settings->HasRegion, m_settings->Region, IO_Opts);
829
+ Options::AddValueOption("-script", "filename", scriptDesc, "", m_settings->HasScriptFilename, m_settings->ScriptFilename, IO_Opts);
830
+ Options::AddOption("-forceCompression",forceDesc, m_settings->IsForceCompression, IO_Opts);
831
+
832
+ // ----------------------------------
833
+ // general filter options
834
+
835
+ OptionGroup* FilterOpts = Options::CreateOptionGroup("General Filters");
836
+
837
+ const string flagDesc = "keep reads with this *exact* alignment flag (for more detailed queries, see below)";
838
+ const string insertDesc = "keep reads with insert size that matches pattern";
839
+ const string mapQualDesc = "keep reads with map quality that matches pattern";
840
+ const string nameDesc = "keep reads with name that matches pattern";
841
+ const string queryDesc = "keep reads with motif that matches pattern";
842
+ const string tagDesc = "keep reads with this key=>value pair";
843
+
844
+ Options::AddValueOption("-alignmentFlag", "int", flagDesc, "", m_settings->HasAlignmentFlagFilter, m_settings->AlignmentFlagFilter, FilterOpts);
845
+ Options::AddValueOption("-insertSize", "int", insertDesc, "", m_settings->HasInsertSizeFilter, m_settings->InsertSizeFilter, FilterOpts);
846
+ Options::AddValueOption("-mapQuality", "[0-255]", mapQualDesc, "", m_settings->HasMapQualityFilter, m_settings->MapQualityFilter, FilterOpts);
847
+ Options::AddValueOption("-name", "string", nameDesc, "", m_settings->HasNameFilter, m_settings->NameFilter, FilterOpts);
848
+ Options::AddValueOption("-queryBases", "string", queryDesc, "", m_settings->HasQueryBasesFilter, m_settings->QueryBasesFilter, FilterOpts);
849
+ Options::AddValueOption("-tag", "TAG:VALUE", tagDesc, "", m_settings->HasTagFilter, m_settings->TagFilter, FilterOpts);
850
+
851
+ // ----------------------------------
852
+ // alignment flag filter options
853
+
854
+ OptionGroup* AlignmentFlagOpts = Options::CreateOptionGroup("Alignment Flag Filters");
855
+
856
+ const string boolArg = "true/false";
857
+ const string isDupDesc = "keep only alignments that are marked as duplicate?";
858
+ const string isFailQcDesc = "keep only alignments that failed QC?";
859
+ const string isFirstMateDesc = "keep only alignments marked as first mate?";
860
+ const string isMappedDesc = "keep only alignments that were mapped?";
861
+ const string isMateMappedDesc = "keep only alignments with mates that mapped";
862
+ const string isMateReverseDesc = "keep only alignments with mate on reverese strand?";
863
+ const string isPairedDesc = "keep only alignments that were sequenced as paired?";
864
+ const string isPrimaryDesc = "keep only alignments marked as primary?";
865
+ const string isProperPairDesc = "keep only alignments that passed PE resolution?";
866
+ const string isReverseDesc = "keep only alignments on reverse strand?";
867
+ const string isSecondMateDesc = "keep only alignments marked as second mate?";
868
+ const string isSingletonDesc = "keep only singletons";
869
+
870
+ Options::AddValueOption("-isDuplicate", boolArg, isDupDesc, "", m_settings->HasIsDuplicateFilter, m_settings->IsDuplicateFilter, AlignmentFlagOpts, TRUE_STR);
871
+ Options::AddValueOption("-isFailedQC", boolArg, isFailQcDesc, "", m_settings->HasIsFailedQCFilter, m_settings->IsFailedQCFilter, AlignmentFlagOpts, TRUE_STR);
872
+ Options::AddValueOption("-isFirstMate", boolArg, isFirstMateDesc, "", m_settings->HasIsFirstMateFilter, m_settings->IsFirstMateFilter, AlignmentFlagOpts, TRUE_STR);
873
+ Options::AddValueOption("-isMapped", boolArg, isMappedDesc, "", m_settings->HasIsMappedFilter, m_settings->IsMappedFilter, AlignmentFlagOpts, TRUE_STR);
874
+ Options::AddValueOption("-isMateMapped", boolArg, isMateMappedDesc, "", m_settings->HasIsMateMappedFilter, m_settings->IsMateMappedFilter, AlignmentFlagOpts, TRUE_STR);
875
+ Options::AddValueOption("-isMateReverseStrand", boolArg, isMateReverseDesc, "", m_settings->HasIsMateReverseStrandFilter, m_settings->IsMateReverseStrandFilter, AlignmentFlagOpts, TRUE_STR);
876
+ Options::AddValueOption("-isPaired", boolArg, isPairedDesc, "", m_settings->HasIsPairedFilter, m_settings->IsPairedFilter, AlignmentFlagOpts, TRUE_STR);
877
+ Options::AddValueOption("-isPrimaryAlignment", boolArg, isPrimaryDesc, "", m_settings->HasIsPrimaryAlignmentFilter, m_settings->IsPrimaryAlignmentFilter, AlignmentFlagOpts, TRUE_STR);
878
+ Options::AddValueOption("-isProperPair", boolArg, isProperPairDesc, "", m_settings->HasIsProperPairFilter, m_settings->IsProperPairFilter, AlignmentFlagOpts, TRUE_STR);
879
+ Options::AddValueOption("-isReverseStrand", boolArg, isReverseDesc, "", m_settings->HasIsReverseStrandFilter, m_settings->IsReverseStrandFilter, AlignmentFlagOpts, TRUE_STR);
880
+ Options::AddValueOption("-isSecondMate", boolArg, isSecondMateDesc, "", m_settings->HasIsSecondMateFilter, m_settings->IsSecondMateFilter, AlignmentFlagOpts, TRUE_STR);
881
+ Options::AddValueOption("-isSingleton", boolArg, isSingletonDesc, "", m_settings->HasIsSingletonFilter, m_settings->IsSingletonFilter, AlignmentFlagOpts, TRUE_STR);
882
+ }
883
+
884
+ FilterTool::~FilterTool(void) {
885
+
886
+ delete m_settings;
887
+ m_settings = 0;
888
+
889
+ delete m_impl;
890
+ m_impl = 0;
891
+ }
892
+
893
+ int FilterTool::Help(void) {
894
+ Options::DisplayHelp();
895
+ return 0;
896
+ }
897
+
898
+ int FilterTool::Run(int argc, char* argv[]) {
899
+
900
+ // parse command line arguments
901
+ Options::Parse(argc, argv, 1);
902
+
903
+ // initialize FilterTool with settings
904
+ m_impl = new FilterToolPrivate(m_settings);
905
+
906
+ // run FilterTool, return success/fail
907
+ if ( m_impl->Run() )
908
+ return 0;
909
+ else
910
+ return 1;
911
+ }