ngs_server 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/ngs_server +58 -0
- data/data/holder.txt +0 -0
- data/ext/bamtools/CMakeLists.txt +49 -0
- data/ext/bamtools/LICENSE +22 -0
- data/ext/bamtools/README +60 -0
- data/ext/bamtools/Tutorial_Toolkit_BamTools-1.0.pdf +0 -0
- data/ext/bamtools/docs/Doxyfile +1601 -0
- data/ext/bamtools/extconf.rb +9 -0
- data/ext/bamtools/src/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
- data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/DependInfo.cmake +13 -0
- data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/build.make +65 -0
- data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/cmake_clean.cmake +8 -0
- data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/depend.internal +3 -0
- data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/depend.make +3 -0
- data/ext/bamtools/src/CMakeFiles/SharedHeaders.dir/progress.make +2 -0
- data/ext/bamtools/src/CMakeFiles/progress.marks +1 -0
- data/ext/bamtools/src/CMakeLists.txt +18 -0
- data/ext/bamtools/src/ExportHeader.cmake +31 -0
- data/ext/bamtools/src/Makefile +182 -0
- data/ext/bamtools/src/api/BamAlignment.cpp +2432 -0
- data/ext/bamtools/src/api/BamAlignment.h +206 -0
- data/ext/bamtools/src/api/BamAux.h +456 -0
- data/ext/bamtools/src/api/BamConstants.h +127 -0
- data/ext/bamtools/src/api/BamIndex.h +79 -0
- data/ext/bamtools/src/api/BamMultiReader.cpp +395 -0
- data/ext/bamtools/src/api/BamMultiReader.h +126 -0
- data/ext/bamtools/src/api/BamReader.cpp +369 -0
- data/ext/bamtools/src/api/BamReader.h +117 -0
- data/ext/bamtools/src/api/BamWriter.cpp +142 -0
- data/ext/bamtools/src/api/BamWriter.h +63 -0
- data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/DependInfo.cmake +14 -0
- data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/build.make +80 -0
- data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/cmake_clean.cmake +8 -0
- data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/depend.internal +3 -0
- data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/depend.make +3 -0
- data/ext/bamtools/src/api/CMakeFiles/APIHeaders.dir/progress.make +2 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamAlignment.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamMultiReader.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamReader.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/BamWriter.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/CXX.includecache +596 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/DependInfo.cmake +41 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamHeader.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamProgram.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamProgramChain.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamReadGroup.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamReadGroupDictionary.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamSequence.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/SamSequenceDictionary.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/build.make +675 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/cmake_clean.cmake +32 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/cmake_clean_target.cmake +3 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/depend.internal +295 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/depend.make +295 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/flags.make +8 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamHeader_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamIndexFactory_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamMultiReader_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamRandomAccessController_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamReader_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamStandardIndex_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamToolsIndex_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BamWriter_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/BgzfStream_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/SamFormatParser_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/SamFormatPrinter_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/internal/SamHeaderValidator_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/link.txt +2 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools-static.dir/progress.make +24 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamAlignment.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamMultiReader.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamReader.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/BamWriter.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/CXX.includecache +596 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/DependInfo.cmake +47 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamHeader.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamProgram.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamProgramChain.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamReadGroup.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamReadGroupDictionary.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamSequence.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/SamSequenceDictionary.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/build.make +677 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/cmake_clean.cmake +33 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/depend.internal +295 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/depend.make +295 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/flags.make +8 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamHeader_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamIndexFactory_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamMultiReader_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamRandomAccessController_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamReader_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamStandardIndex_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamToolsIndex_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BamWriter_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/BgzfStream_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/SamFormatParser_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/SamFormatPrinter_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/internal/SamHeaderValidator_p.cpp.o +0 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/link.txt +1 -0
- data/ext/bamtools/src/api/CMakeFiles/BamTools.dir/progress.make +24 -0
- data/ext/bamtools/src/api/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
- data/ext/bamtools/src/api/CMakeFiles/progress.marks +1 -0
- data/ext/bamtools/src/api/CMakeLists.txt +78 -0
- data/ext/bamtools/src/api/Makefile +902 -0
- data/ext/bamtools/src/api/SamConstants.h +95 -0
- data/ext/bamtools/src/api/SamHeader.cpp +184 -0
- data/ext/bamtools/src/api/SamHeader.h +68 -0
- data/ext/bamtools/src/api/SamProgram.cpp +139 -0
- data/ext/bamtools/src/api/SamProgram.h +61 -0
- data/ext/bamtools/src/api/SamProgramChain.cpp +351 -0
- data/ext/bamtools/src/api/SamProgramChain.h +85 -0
- data/ext/bamtools/src/api/SamReadGroup.cpp +221 -0
- data/ext/bamtools/src/api/SamReadGroup.h +68 -0
- data/ext/bamtools/src/api/SamReadGroupDictionary.cpp +289 -0
- data/ext/bamtools/src/api/SamReadGroupDictionary.h +86 -0
- data/ext/bamtools/src/api/SamSequence.cpp +161 -0
- data/ext/bamtools/src/api/SamSequence.h +60 -0
- data/ext/bamtools/src/api/SamSequenceDictionary.cpp +292 -0
- data/ext/bamtools/src/api/SamSequenceDictionary.h +88 -0
- data/ext/bamtools/src/api/api_global.h +21 -0
- data/ext/bamtools/src/api/cmake_install.cmake +122 -0
- data/ext/bamtools/src/api/internal/BamHeader_p.cpp +132 -0
- data/ext/bamtools/src/api/internal/BamHeader_p.h +71 -0
- data/ext/bamtools/src/api/internal/BamIndexFactory_p.cpp +112 -0
- data/ext/bamtools/src/api/internal/BamIndexFactory_p.h +49 -0
- data/ext/bamtools/src/api/internal/BamMultiMerger_p.h +297 -0
- data/ext/bamtools/src/api/internal/BamMultiReader_p.cpp +805 -0
- data/ext/bamtools/src/api/internal/BamMultiReader_p.h +103 -0
- data/ext/bamtools/src/api/internal/BamRandomAccessController_p.cpp +272 -0
- data/ext/bamtools/src/api/internal/BamRandomAccessController_p.h +93 -0
- data/ext/bamtools/src/api/internal/BamReader_p.cpp +380 -0
- data/ext/bamtools/src/api/internal/BamReader_p.h +112 -0
- data/ext/bamtools/src/api/internal/BamStandardIndex_p.cpp +986 -0
- data/ext/bamtools/src/api/internal/BamStandardIndex_p.h +236 -0
- data/ext/bamtools/src/api/internal/BamToolsIndex_p.cpp +641 -0
- data/ext/bamtools/src/api/internal/BamToolsIndex_p.h +187 -0
- data/ext/bamtools/src/api/internal/BamWriter_p.cpp +424 -0
- data/ext/bamtools/src/api/internal/BamWriter_p.h +66 -0
- data/ext/bamtools/src/api/internal/BgzfStream_p.cpp +438 -0
- data/ext/bamtools/src/api/internal/BgzfStream_p.h +108 -0
- data/ext/bamtools/src/api/internal/SamFormatParser_p.cpp +230 -0
- data/ext/bamtools/src/api/internal/SamFormatParser_p.h +61 -0
- data/ext/bamtools/src/api/internal/SamFormatPrinter_p.cpp +210 -0
- data/ext/bamtools/src/api/internal/SamFormatPrinter_p.h +60 -0
- data/ext/bamtools/src/api/internal/SamHeaderValidator_p.cpp +510 -0
- data/ext/bamtools/src/api/internal/SamHeaderValidator_p.h +101 -0
- data/ext/bamtools/src/api/internal/SamHeaderVersion_p.h +134 -0
- data/ext/bamtools/src/cmake_install.cmake +42 -0
- data/ext/bamtools/src/shared/bamtools_global.h +78 -0
- data/ext/bamtools/src/third_party/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
- data/ext/bamtools/src/third_party/CMakeFiles/progress.marks +1 -0
- data/ext/bamtools/src/third_party/CMakeLists.txt +10 -0
- data/ext/bamtools/src/third_party/Makefile +167 -0
- data/ext/bamtools/src/third_party/cmake_install.cmake +35 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/CMakeDirectoryInformation.cmake +22 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/CXX.includecache +144 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/DependInfo.cmake +27 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/build.make +157 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/cmake_clean.cmake +13 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/depend.internal +31 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/depend.make +31 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/flags.make +8 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/json_reader.cpp.o +0 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/json_value.cpp.o +0 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/json_writer.cpp.o +0 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/link.txt +1 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/jsoncpp.dir/progress.make +4 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeFiles/progress.marks +1 -0
- data/ext/bamtools/src/third_party/jsoncpp/CMakeLists.txt +23 -0
- data/ext/bamtools/src/third_party/jsoncpp/LICENSE +55 -0
- data/ext/bamtools/src/third_party/jsoncpp/Makefile +263 -0
- data/ext/bamtools/src/third_party/jsoncpp/cmake_install.cmake +29 -0
- data/ext/bamtools/src/third_party/jsoncpp/json.h +15 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_batchallocator.h +130 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_config.h +42 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_features.h +47 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_forwards.h +42 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_internalarray.inl +453 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_internalmap.inl +612 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_reader.cpp +870 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_reader.h +201 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_tool.h +93 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_value.cpp +1701 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_value.h +1059 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_valueiterator.inl +297 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_writer.cpp +819 -0
- data/ext/bamtools/src/third_party/jsoncpp/json_writer.h +179 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/CMakeDirectoryInformation.cmake +25 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/CXX.includecache +698 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/DependInfo.cmake +34 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_convert.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_count.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_coverage.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_filter.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_header.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_index.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_merge.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_random.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_resolve.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_revert.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_sort.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_split.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/bamtools_stats.cpp.o +0 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/build.make +447 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/cmake_clean.cmake +24 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/depend.internal +319 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/depend.make +319 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/flags.make +8 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/link.txt +1 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/bamtools_cmd.dir/progress.make +15 -0
- data/ext/bamtools/src/toolkit/CMakeFiles/progress.marks +1 -0
- data/ext/bamtools/src/toolkit/CMakeLists.txt +44 -0
- data/ext/bamtools/src/toolkit/Makefile +560 -0
- data/ext/bamtools/src/toolkit/bamtools.cpp +163 -0
- data/ext/bamtools/src/toolkit/bamtools_convert.cpp +888 -0
- data/ext/bamtools/src/toolkit/bamtools_convert.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_count.cpp +187 -0
- data/ext/bamtools/src/toolkit/bamtools_count.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_coverage.cpp +196 -0
- data/ext/bamtools/src/toolkit/bamtools_coverage.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_filter.cpp +911 -0
- data/ext/bamtools/src/toolkit/bamtools_filter.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_header.cpp +122 -0
- data/ext/bamtools/src/toolkit/bamtools_header.h +38 -0
- data/ext/bamtools/src/toolkit/bamtools_index.cpp +126 -0
- data/ext/bamtools/src/toolkit/bamtools_index.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_merge.cpp +221 -0
- data/ext/bamtools/src/toolkit/bamtools_merge.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_random.cpp +255 -0
- data/ext/bamtools/src/toolkit/bamtools_random.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_resolve.cpp +1396 -0
- data/ext/bamtools/src/toolkit/bamtools_resolve.h +42 -0
- data/ext/bamtools/src/toolkit/bamtools_revert.cpp +194 -0
- data/ext/bamtools/src/toolkit/bamtools_revert.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_sort.cpp +410 -0
- data/ext/bamtools/src/toolkit/bamtools_sort.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_split.cpp +551 -0
- data/ext/bamtools/src/toolkit/bamtools_split.h +38 -0
- data/ext/bamtools/src/toolkit/bamtools_stats.cpp +286 -0
- data/ext/bamtools/src/toolkit/bamtools_stats.h +37 -0
- data/ext/bamtools/src/toolkit/bamtools_tool.h +35 -0
- data/ext/bamtools/src/toolkit/bamtools_version.h +20 -0
- data/ext/bamtools/src/toolkit/bamtools_version.h.in +20 -0
- data/ext/bamtools/src/toolkit/cmake_install.cmake +52 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/CXX.includecache +250 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/DependInfo.cmake +29 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_fasta.cpp.o +0 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_options.cpp.o +0 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_pileup_engine.cpp.o +0 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/bamtools_utilities.cpp.o +0 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/build.make +184 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/cmake_clean.cmake +14 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/depend.internal +40 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/depend.make +40 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/flags.make +8 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/link.txt +1 -0
- data/ext/bamtools/src/utils/CMakeFiles/BamTools-utils.dir/progress.make +5 -0
- data/ext/bamtools/src/utils/CMakeFiles/CMakeDirectoryInformation.cmake +23 -0
- data/ext/bamtools/src/utils/CMakeFiles/progress.marks +1 -0
- data/ext/bamtools/src/utils/CMakeLists.txt +30 -0
- data/ext/bamtools/src/utils/Makefile +290 -0
- data/ext/bamtools/src/utils/bamtools_fasta.cpp +632 -0
- data/ext/bamtools/src/utils/bamtools_fasta.h +47 -0
- data/ext/bamtools/src/utils/bamtools_filter_engine.h +552 -0
- data/ext/bamtools/src/utils/bamtools_filter_properties.h +195 -0
- data/ext/bamtools/src/utils/bamtools_filter_ruleparser.h +319 -0
- data/ext/bamtools/src/utils/bamtools_options.cpp +287 -0
- data/ext/bamtools/src/utils/bamtools_options.h +213 -0
- data/ext/bamtools/src/utils/bamtools_pileup_engine.cpp +327 -0
- data/ext/bamtools/src/utils/bamtools_pileup_engine.h +94 -0
- data/ext/bamtools/src/utils/bamtools_utilities.cpp +333 -0
- data/ext/bamtools/src/utils/bamtools_utilities.h +67 -0
- data/ext/bamtools/src/utils/bamtools_variant.h +128 -0
- data/ext/bamtools/src/utils/cmake_install.cmake +29 -0
- data/ext/bamtools/src/utils/utils_global.h +21 -0
- data/lib/ngs_server/version.rb +3 -0
- data/lib/ngs_server.rb +3 -0
- data/ngs_server.gemspec +23 -0
- metadata +339 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
// ***************************************************************************
|
2
|
+
// bamtools_resolve.h (c) 2011 Derek Barnett
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
4
|
+
// ---------------------------------------------------------------------------
|
5
|
+
// Last modified: 23 June 2011
|
6
|
+
// ---------------------------------------------------------------------------
|
7
|
+
// Resolves paired-end reads (marking the IsProperPair flag as needed).
|
8
|
+
// ***************************************************************************
|
9
|
+
|
10
|
+
#ifndef BAMTOOLS_RESOLVE_H
|
11
|
+
#define BAMTOOLS_RESOLVE_H
|
12
|
+
|
13
|
+
#include "bamtools_tool.h"
|
14
|
+
|
15
|
+
namespace BamTools {
|
16
|
+
|
17
|
+
class ResolveTool : public AbstractTool {
|
18
|
+
|
19
|
+
public:
|
20
|
+
ResolveTool(void);
|
21
|
+
~ResolveTool(void);
|
22
|
+
|
23
|
+
public:
|
24
|
+
int Help(void);
|
25
|
+
int Run(int argc, char* argv[]);
|
26
|
+
|
27
|
+
private:
|
28
|
+
struct ResolveSettings;
|
29
|
+
ResolveSettings* m_settings;
|
30
|
+
|
31
|
+
struct ResolveToolPrivate;
|
32
|
+
ResolveToolPrivate* m_impl;
|
33
|
+
|
34
|
+
struct ReadNamesFileReader;
|
35
|
+
struct ReadNamesFileWriter;
|
36
|
+
struct StatsFileReader;
|
37
|
+
struct StatsFileWriter;
|
38
|
+
};
|
39
|
+
|
40
|
+
} // namespace BamTools
|
41
|
+
|
42
|
+
#endif // BAMTOOLS_RESOLVE_H
|
@@ -0,0 +1,194 @@
|
|
1
|
+
// ***************************************************************************
|
2
|
+
// bamtools_revert.cpp (c) 2010 Derek Barnett, Alistair Ward
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
4
|
+
// ---------------------------------------------------------------------------
|
5
|
+
// Last modified: 7 April 2011
|
6
|
+
// ---------------------------------------------------------------------------
|
7
|
+
// Removes duplicate marks and restores original base qualities
|
8
|
+
// ***************************************************************************
|
9
|
+
|
10
|
+
#include "bamtools_revert.h"
|
11
|
+
|
12
|
+
#include <api/BamReader.h>
|
13
|
+
#include <api/BamWriter.h>
|
14
|
+
#include <utils/bamtools_options.h>
|
15
|
+
#include <utils/bamtools_utilities.h>
|
16
|
+
using namespace BamTools;
|
17
|
+
|
18
|
+
#include <iostream>
|
19
|
+
#include <string>
|
20
|
+
using namespace std;
|
21
|
+
|
22
|
+
namespace BamTools {
|
23
|
+
|
24
|
+
static const string OQ_TAG = "OQ";
|
25
|
+
|
26
|
+
} // namespace BamTools;
|
27
|
+
|
28
|
+
// ---------------------------------------------
|
29
|
+
// RevertSettings implementation
|
30
|
+
|
31
|
+
struct RevertTool::RevertSettings {
|
32
|
+
|
33
|
+
// flags
|
34
|
+
bool HasInput;
|
35
|
+
bool HasOutput;
|
36
|
+
bool IsForceCompression;
|
37
|
+
bool IsKeepDuplicateFlag;
|
38
|
+
bool IsKeepQualities;
|
39
|
+
|
40
|
+
// filenames
|
41
|
+
string InputFilename;
|
42
|
+
string OutputFilename;
|
43
|
+
|
44
|
+
// constructor
|
45
|
+
RevertSettings(void)
|
46
|
+
: HasInput(false)
|
47
|
+
, HasOutput(false)
|
48
|
+
, IsForceCompression(false)
|
49
|
+
, IsKeepDuplicateFlag(false)
|
50
|
+
, IsKeepQualities(false)
|
51
|
+
, InputFilename(Options::StandardIn())
|
52
|
+
, OutputFilename(Options::StandardOut())
|
53
|
+
{ }
|
54
|
+
};
|
55
|
+
|
56
|
+
// ---------------------------------------------
|
57
|
+
// RevertToolPrivate implementation
|
58
|
+
|
59
|
+
struct RevertTool::RevertToolPrivate {
|
60
|
+
|
61
|
+
// ctor & dtor
|
62
|
+
public:
|
63
|
+
RevertToolPrivate(RevertTool::RevertSettings* settings)
|
64
|
+
: m_settings(settings)
|
65
|
+
{ }
|
66
|
+
~RevertToolPrivate(void) { }
|
67
|
+
|
68
|
+
// 'public' interface
|
69
|
+
public:
|
70
|
+
bool Run(void);
|
71
|
+
|
72
|
+
// internal methods
|
73
|
+
private:
|
74
|
+
void RevertAlignment(BamAlignment& al);
|
75
|
+
|
76
|
+
// data members
|
77
|
+
private:
|
78
|
+
RevertTool::RevertSettings* m_settings;
|
79
|
+
};
|
80
|
+
|
81
|
+
// 'reverts' a BAM alignment
|
82
|
+
// default behavior (for now) is:
|
83
|
+
// 1 - replace Qualities with OQ contents
|
84
|
+
// 2 - clear IsDuplicate flag
|
85
|
+
// can override default behavior using command line options
|
86
|
+
void RevertTool::RevertToolPrivate::RevertAlignment(BamAlignment& al) {
|
87
|
+
|
88
|
+
// replace Qualities with OQ contents, if requested
|
89
|
+
if ( !m_settings->IsKeepQualities ) {
|
90
|
+
string originalQualities;
|
91
|
+
if ( al.GetTag(OQ_TAG, originalQualities) ) {
|
92
|
+
al.Qualities = originalQualities;
|
93
|
+
al.RemoveTag(OQ_TAG);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
// clear duplicate flag, if requested
|
98
|
+
if ( !m_settings->IsKeepDuplicateFlag )
|
99
|
+
al.SetIsDuplicate(false);
|
100
|
+
}
|
101
|
+
|
102
|
+
bool RevertTool::RevertToolPrivate::Run(void) {
|
103
|
+
|
104
|
+
// opens the BAM file without checking for indexes
|
105
|
+
BamReader reader;
|
106
|
+
if ( !reader.Open(m_settings->InputFilename) ) {
|
107
|
+
cerr << "bamtools revert ERROR: could not open " << m_settings->InputFilename
|
108
|
+
<< " for reading... Aborting." << endl;
|
109
|
+
return false;
|
110
|
+
}
|
111
|
+
|
112
|
+
// get BAM file metadata
|
113
|
+
const string& headerText = reader.GetHeaderText();
|
114
|
+
const RefVector& references = reader.GetReferenceData();
|
115
|
+
|
116
|
+
// determine compression mode for BamWriter
|
117
|
+
bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
|
118
|
+
!m_settings->IsForceCompression );
|
119
|
+
BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
|
120
|
+
if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
|
121
|
+
|
122
|
+
// open BamWriter
|
123
|
+
BamWriter writer;
|
124
|
+
writer.SetCompressionMode(compressionMode);
|
125
|
+
if ( !writer.Open(m_settings->OutputFilename, headerText, references) ) {
|
126
|
+
cerr << "bamtools revert ERROR: could not open " << m_settings->OutputFilename
|
127
|
+
<< " for writing... Aborting." << endl;
|
128
|
+
reader.Close();
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
|
132
|
+
// plow through file, reverting alignments
|
133
|
+
BamAlignment al;
|
134
|
+
while ( reader.GetNextAlignment(al) ) {
|
135
|
+
RevertAlignment(al);
|
136
|
+
writer.SaveAlignment(al);
|
137
|
+
}
|
138
|
+
|
139
|
+
// clean and exit
|
140
|
+
reader.Close();
|
141
|
+
writer.Close();
|
142
|
+
return true;
|
143
|
+
}
|
144
|
+
|
145
|
+
// ---------------------------------------------
|
146
|
+
// RevertTool implementation
|
147
|
+
|
148
|
+
RevertTool::RevertTool(void)
|
149
|
+
: AbstractTool()
|
150
|
+
, m_settings(new RevertSettings)
|
151
|
+
, m_impl(0)
|
152
|
+
{
|
153
|
+
// set program details
|
154
|
+
Options::SetProgramInfo("bamtools revert", "removes duplicate marks and restores original (non-recalibrated) base qualities", "[-in <filename> -in <filename> ...] [-out <filename> | [-forceCompression]] [revertOptions]");
|
155
|
+
|
156
|
+
// set up options
|
157
|
+
OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
|
158
|
+
Options::AddValueOption("-in", "BAM filename", "the input BAM file", "", m_settings->HasInput, m_settings->InputFilename, IO_Opts, Options::StandardIn());
|
159
|
+
Options::AddValueOption("-out", "BAM filename", "the output BAM file", "", m_settings->HasOutput, m_settings->OutputFilename, IO_Opts, Options::StandardOut());
|
160
|
+
Options::AddOption("-forceCompression", "if results are sent to stdout (like when piping to another tool), default behavior is to leave output uncompressed. Use this flag to override and force compression", m_settings->IsForceCompression, IO_Opts);
|
161
|
+
|
162
|
+
OptionGroup* RevertOpts = Options::CreateOptionGroup("Revert Options");
|
163
|
+
Options::AddOption("-keepDuplicate", "keep duplicates marked", m_settings->IsKeepDuplicateFlag, RevertOpts);
|
164
|
+
Options::AddOption("-keepQualities", "keep base qualities (do not replace with OQ contents)", m_settings->IsKeepQualities, RevertOpts);
|
165
|
+
}
|
166
|
+
|
167
|
+
RevertTool::~RevertTool(void) {
|
168
|
+
|
169
|
+
delete m_settings;
|
170
|
+
m_settings = 0;
|
171
|
+
|
172
|
+
delete m_impl;
|
173
|
+
m_impl = 0;
|
174
|
+
}
|
175
|
+
|
176
|
+
int RevertTool::Help(void) {
|
177
|
+
Options::DisplayHelp();
|
178
|
+
return 0;
|
179
|
+
}
|
180
|
+
|
181
|
+
int RevertTool::Run(int argc, char* argv[]) {
|
182
|
+
|
183
|
+
// parse command line arguments
|
184
|
+
Options::Parse(argc, argv, 1);
|
185
|
+
|
186
|
+
// intialize RevertTool with settings
|
187
|
+
m_impl = new RevertToolPrivate(m_settings);
|
188
|
+
|
189
|
+
// run RevertTool, return success/fail
|
190
|
+
if ( m_impl->Run() )
|
191
|
+
return 0;
|
192
|
+
else
|
193
|
+
return 1;
|
194
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// ***************************************************************************
|
2
|
+
// bamtools_revert.h (c) 2010 Derek Barnett, Alistair Ward
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
4
|
+
// ---------------------------------------------------------------------------
|
5
|
+
// Last modified: 7 April 2011
|
6
|
+
// ---------------------------------------------------------------------------
|
7
|
+
// Removes duplicate marks and restores original base qualities
|
8
|
+
// ***************************************************************************
|
9
|
+
|
10
|
+
#ifndef BAMTOOLS_REVERT_H
|
11
|
+
#define BAMTOOLS_REVERT_H
|
12
|
+
|
13
|
+
#include "bamtools_tool.h"
|
14
|
+
|
15
|
+
namespace BamTools {
|
16
|
+
|
17
|
+
class RevertTool : public AbstractTool {
|
18
|
+
|
19
|
+
public:
|
20
|
+
RevertTool(void);
|
21
|
+
~RevertTool(void);
|
22
|
+
|
23
|
+
public:
|
24
|
+
int Help(void);
|
25
|
+
int Run(int argc, char* argv[]);
|
26
|
+
|
27
|
+
private:
|
28
|
+
struct RevertSettings;
|
29
|
+
RevertSettings* m_settings;
|
30
|
+
|
31
|
+
struct RevertToolPrivate;
|
32
|
+
RevertToolPrivate* m_impl;
|
33
|
+
};
|
34
|
+
|
35
|
+
} // namespace BamTools
|
36
|
+
|
37
|
+
#endif // BAMTOOLS_REVERT_H
|
@@ -0,0 +1,410 @@
|
|
1
|
+
// ***************************************************************************
|
2
|
+
// bamtools_sort.cpp (c) 2010 Derek Barnett, Erik Garrison
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
4
|
+
// ---------------------------------------------------------------------------
|
5
|
+
// Last modified: 14 June 2011 (DB)
|
6
|
+
// ---------------------------------------------------------------------------
|
7
|
+
// Sorts an input BAM file
|
8
|
+
// ***************************************************************************
|
9
|
+
|
10
|
+
#include "bamtools_sort.h"
|
11
|
+
|
12
|
+
#include <api/SamConstants.h>
|
13
|
+
#include <api/BamMultiReader.h>
|
14
|
+
#include <api/BamWriter.h>
|
15
|
+
#include <utils/bamtools_options.h>
|
16
|
+
using namespace BamTools;
|
17
|
+
|
18
|
+
#include <cstdio>
|
19
|
+
#include <algorithm>
|
20
|
+
#include <iostream>
|
21
|
+
#include <sstream>
|
22
|
+
#include <string>
|
23
|
+
#include <vector>
|
24
|
+
using namespace std;
|
25
|
+
|
26
|
+
namespace BamTools {
|
27
|
+
|
28
|
+
// defaults
|
29
|
+
//
|
30
|
+
// ** These defaults should be tweaked & 'optimized' per testing ** //
|
31
|
+
//
|
32
|
+
// I say 'optimized' because each system will naturally perform
|
33
|
+
// differently. We will attempt to determine a sensible
|
34
|
+
// compromise that should perform well on average.
|
35
|
+
const unsigned int SORT_DEFAULT_MAX_BUFFER_COUNT = 500000; // max numberOfAlignments for buffer
|
36
|
+
const unsigned int SORT_DEFAULT_MAX_BUFFER_MEMORY = 1024; // Mb
|
37
|
+
|
38
|
+
// -----------------------------------
|
39
|
+
// comparison objects (for sorting)
|
40
|
+
|
41
|
+
struct SortLessThanPosition {
|
42
|
+
bool operator() (const BamAlignment& lhs, const BamAlignment& rhs) {
|
43
|
+
if ( lhs.RefID != rhs.RefID )
|
44
|
+
return lhs.RefID < rhs.RefID;
|
45
|
+
else
|
46
|
+
return lhs.Position < rhs.Position;
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
struct SortLessThanName {
|
51
|
+
bool operator() (const BamAlignment& lhs, const BamAlignment& rhs) {
|
52
|
+
return lhs.Name < rhs.Name;
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
} // namespace BamTools
|
57
|
+
|
58
|
+
// ---------------------------------------------
|
59
|
+
// SortSettings implementation
|
60
|
+
|
61
|
+
struct SortTool::SortSettings {
|
62
|
+
|
63
|
+
// flags
|
64
|
+
bool HasInputBamFilename;
|
65
|
+
bool HasMaxBufferCount;
|
66
|
+
bool HasMaxBufferMemory;
|
67
|
+
bool HasOutputBamFilename;
|
68
|
+
bool IsSortingByName;
|
69
|
+
|
70
|
+
// filenames
|
71
|
+
string InputBamFilename;
|
72
|
+
string OutputBamFilename;
|
73
|
+
|
74
|
+
// parameters
|
75
|
+
unsigned int MaxBufferCount;
|
76
|
+
unsigned int MaxBufferMemory;
|
77
|
+
|
78
|
+
// constructor
|
79
|
+
SortSettings(void)
|
80
|
+
: HasInputBamFilename(false)
|
81
|
+
, HasMaxBufferCount(false)
|
82
|
+
, HasMaxBufferMemory(false)
|
83
|
+
, HasOutputBamFilename(false)
|
84
|
+
, IsSortingByName(false)
|
85
|
+
, InputBamFilename(Options::StandardIn())
|
86
|
+
, OutputBamFilename(Options::StandardOut())
|
87
|
+
, MaxBufferCount(SORT_DEFAULT_MAX_BUFFER_COUNT)
|
88
|
+
, MaxBufferMemory(SORT_DEFAULT_MAX_BUFFER_MEMORY)
|
89
|
+
{ }
|
90
|
+
};
|
91
|
+
|
92
|
+
// ---------------------------------------------
|
93
|
+
// SortToolPrivate implementation
|
94
|
+
|
95
|
+
class SortTool::SortToolPrivate {
|
96
|
+
|
97
|
+
// ctor & dtor
|
98
|
+
public:
|
99
|
+
SortToolPrivate(SortTool::SortSettings* settings);
|
100
|
+
~SortToolPrivate(void) { }
|
101
|
+
|
102
|
+
// 'public' interface
|
103
|
+
public:
|
104
|
+
bool Run(void);
|
105
|
+
|
106
|
+
// internal methods
|
107
|
+
private:
|
108
|
+
bool CreateSortedTempFile(vector<BamAlignment>& buffer);
|
109
|
+
bool GenerateSortedRuns(void);
|
110
|
+
bool MergeSortedRuns(void);
|
111
|
+
bool WriteTempFile(const vector<BamAlignment>& buffer, const string& tempFilename);
|
112
|
+
void SortBuffer(vector<BamAlignment>& buffer);
|
113
|
+
|
114
|
+
// data members
|
115
|
+
private:
|
116
|
+
SortTool::SortSettings* m_settings;
|
117
|
+
string m_tempFilenameStub;
|
118
|
+
int m_numberOfRuns;
|
119
|
+
string m_headerText;
|
120
|
+
RefVector m_references;
|
121
|
+
vector<string> m_tempFilenames;
|
122
|
+
};
|
123
|
+
|
124
|
+
// constructor
|
125
|
+
SortTool::SortToolPrivate::SortToolPrivate(SortTool::SortSettings* settings)
|
126
|
+
: m_settings(settings)
|
127
|
+
, m_numberOfRuns(0)
|
128
|
+
{
|
129
|
+
// set filename stub depending on inputfile path
|
130
|
+
// that way multiple sort runs don't trip on each other's temp files
|
131
|
+
if ( m_settings) {
|
132
|
+
size_t extensionFound = m_settings->InputBamFilename.find(".bam");
|
133
|
+
if (extensionFound != string::npos )
|
134
|
+
m_tempFilenameStub = m_settings->InputBamFilename.substr(0,extensionFound);
|
135
|
+
m_tempFilenameStub.append(".sort.temp.");
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
// generates mutiple sorted temp BAM files from single unsorted BAM file
|
140
|
+
bool SortTool::SortToolPrivate::GenerateSortedRuns(void) {
|
141
|
+
|
142
|
+
// open input BAM file
|
143
|
+
BamReader reader;
|
144
|
+
if ( !reader.Open(m_settings->InputBamFilename) ) {
|
145
|
+
cerr << "bamtools sort ERROR: could not open " << m_settings->InputBamFilename
|
146
|
+
<< " for reading... Aborting." << endl;
|
147
|
+
return false;
|
148
|
+
}
|
149
|
+
|
150
|
+
// get basic data that will be shared by all temp/output files
|
151
|
+
SamHeader header = reader.GetHeader();
|
152
|
+
header.SortOrder = ( m_settings->IsSortingByName
|
153
|
+
? Constants::SAM_HD_SORTORDER_QUERYNAME
|
154
|
+
: Constants::SAM_HD_SORTORDER_COORDINATE );
|
155
|
+
m_headerText = header.ToString();
|
156
|
+
m_references = reader.GetReferenceData();
|
157
|
+
|
158
|
+
// set up alignments buffer
|
159
|
+
BamAlignment al;
|
160
|
+
vector<BamAlignment> buffer;
|
161
|
+
buffer.reserve( (size_t)(m_settings->MaxBufferCount*1.1) );
|
162
|
+
bool bufferFull = false;
|
163
|
+
|
164
|
+
// if sorting by name, we need to generate full char data
|
165
|
+
// so can't use GetNextAlignmentCore()
|
166
|
+
if ( m_settings->IsSortingByName ) {
|
167
|
+
|
168
|
+
// iterate through file
|
169
|
+
while ( reader.GetNextAlignment(al)) {
|
170
|
+
|
171
|
+
// check buffer's usage
|
172
|
+
bufferFull = ( buffer.size() >= m_settings->MaxBufferCount );
|
173
|
+
|
174
|
+
// store alignments until buffer is "full"
|
175
|
+
if ( !bufferFull )
|
176
|
+
buffer.push_back(al);
|
177
|
+
|
178
|
+
// if buffer is "full"
|
179
|
+
else {
|
180
|
+
|
181
|
+
// push any unmapped reads into buffer,
|
182
|
+
// don't want to split these into a separate temp file
|
183
|
+
if ( !al.IsMapped() )
|
184
|
+
buffer.push_back(al);
|
185
|
+
|
186
|
+
// "al" is mapped, so create a sorted temp file with current buffer contents
|
187
|
+
// then push "al" into fresh buffer
|
188
|
+
else {
|
189
|
+
CreateSortedTempFile(buffer);
|
190
|
+
buffer.push_back(al);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
// sorting by position, can take advantage of GNACore() speedup
|
197
|
+
else {
|
198
|
+
|
199
|
+
// iterate through file
|
200
|
+
while ( reader.GetNextAlignmentCore(al) ) {
|
201
|
+
|
202
|
+
// check buffer's usage
|
203
|
+
bufferFull = ( buffer.size() >= m_settings->MaxBufferCount );
|
204
|
+
|
205
|
+
// store alignments until buffer is "full"
|
206
|
+
if ( !bufferFull )
|
207
|
+
buffer.push_back(al);
|
208
|
+
|
209
|
+
// if buffer is "full"
|
210
|
+
else {
|
211
|
+
|
212
|
+
// push any unmapped reads into buffer,
|
213
|
+
// don't want to split these into a separate temp file
|
214
|
+
if ( !al.IsMapped() )
|
215
|
+
buffer.push_back(al);
|
216
|
+
|
217
|
+
// "al" is mapped, so create a sorted temp file with current buffer contents
|
218
|
+
// then push "al" into fresh buffer
|
219
|
+
else {
|
220
|
+
CreateSortedTempFile(buffer);
|
221
|
+
buffer.push_back(al);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
// handle any leftover buffer contents
|
228
|
+
if ( !buffer.empty() )
|
229
|
+
CreateSortedTempFile(buffer);
|
230
|
+
|
231
|
+
// close reader & return success
|
232
|
+
reader.Close();
|
233
|
+
return true;
|
234
|
+
}
|
235
|
+
|
236
|
+
bool SortTool::SortToolPrivate::CreateSortedTempFile(vector<BamAlignment>& buffer) {
|
237
|
+
|
238
|
+
// do sorting
|
239
|
+
SortBuffer(buffer);
|
240
|
+
|
241
|
+
// write sorted contents to temp file, store success/fail
|
242
|
+
stringstream tempStr;
|
243
|
+
tempStr << m_tempFilenameStub << m_numberOfRuns;
|
244
|
+
bool success = WriteTempFile( buffer, tempStr.str() );
|
245
|
+
|
246
|
+
// save temp filename for merging later
|
247
|
+
m_tempFilenames.push_back(tempStr.str());
|
248
|
+
|
249
|
+
// clear buffer contents & update run counter
|
250
|
+
buffer.clear();
|
251
|
+
++m_numberOfRuns;
|
252
|
+
|
253
|
+
// return success/fail of writing to temp file
|
254
|
+
// TODO: a failure returned here is not actually caught and handled anywhere
|
255
|
+
return success;
|
256
|
+
}
|
257
|
+
|
258
|
+
// merges sorted temp BAM files into single sorted output BAM file
|
259
|
+
bool SortTool::SortToolPrivate::MergeSortedRuns(void) {
|
260
|
+
|
261
|
+
// open up multi reader for all of our temp files
|
262
|
+
// this might get broken up if we do a multi-pass system later ??
|
263
|
+
BamMultiReader multiReader;
|
264
|
+
if ( !multiReader.Open(m_tempFilenames) ) {
|
265
|
+
cerr << "bamtools sort ERROR: could not open BamMultiReader for merging temp files... Aborting."
|
266
|
+
<< endl;
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
|
270
|
+
// set sort order for merge
|
271
|
+
if ( m_settings->IsSortingByName )
|
272
|
+
multiReader.SetSortOrder(BamMultiReader::SortedByReadName);
|
273
|
+
else
|
274
|
+
multiReader.SetSortOrder(BamMultiReader::SortedByPosition);
|
275
|
+
|
276
|
+
// open writer for our completely sorted output BAM file
|
277
|
+
BamWriter mergedWriter;
|
278
|
+
if ( !mergedWriter.Open(m_settings->OutputBamFilename, m_headerText, m_references) ) {
|
279
|
+
cerr << "bamtools sort ERROR: could not open " << m_settings->OutputBamFilename
|
280
|
+
<< " for writing... Aborting." << endl;
|
281
|
+
multiReader.Close();
|
282
|
+
return false;
|
283
|
+
}
|
284
|
+
|
285
|
+
// while data available in temp files
|
286
|
+
BamAlignment al;
|
287
|
+
while ( multiReader.GetNextAlignmentCore(al) )
|
288
|
+
mergedWriter.SaveAlignment(al);
|
289
|
+
|
290
|
+
// close readers
|
291
|
+
multiReader.Close();
|
292
|
+
mergedWriter.Close();
|
293
|
+
|
294
|
+
// delete all temp files
|
295
|
+
vector<string>::const_iterator tempIter = m_tempFilenames.begin();
|
296
|
+
vector<string>::const_iterator tempEnd = m_tempFilenames.end();
|
297
|
+
for ( ; tempIter != tempEnd; ++tempIter ) {
|
298
|
+
const string& tempFilename = (*tempIter);
|
299
|
+
remove(tempFilename.c_str());
|
300
|
+
}
|
301
|
+
|
302
|
+
return true;
|
303
|
+
}
|
304
|
+
|
305
|
+
bool SortTool::SortToolPrivate::Run(void) {
|
306
|
+
|
307
|
+
// this does a single pass, chunking up the input file into smaller sorted temp files,
|
308
|
+
// then write out using BamMultiReader to handle merging
|
309
|
+
|
310
|
+
if ( GenerateSortedRuns() )
|
311
|
+
return MergeSortedRuns();
|
312
|
+
else
|
313
|
+
return false;
|
314
|
+
}
|
315
|
+
|
316
|
+
void SortTool::SortToolPrivate::SortBuffer(vector<BamAlignment>& buffer) {
|
317
|
+
|
318
|
+
// ** add further custom sort options later ?? **
|
319
|
+
|
320
|
+
// sort buffer by desired method
|
321
|
+
if ( m_settings->IsSortingByName )
|
322
|
+
std::stable_sort ( buffer.begin(), buffer.end(), SortLessThanName() );
|
323
|
+
else
|
324
|
+
std::stable_sort ( buffer.begin(), buffer.end(), SortLessThanPosition() );
|
325
|
+
}
|
326
|
+
|
327
|
+
bool SortTool::SortToolPrivate::WriteTempFile(const vector<BamAlignment>& buffer,
|
328
|
+
const string& tempFilename)
|
329
|
+
{
|
330
|
+
// open temp file for writing
|
331
|
+
BamWriter tempWriter;
|
332
|
+
if ( !tempWriter.Open(tempFilename, m_headerText, m_references) ) {
|
333
|
+
cerr << "bamtools sort ERROR: could not open " << tempFilename
|
334
|
+
<< " for writing." << endl;
|
335
|
+
return false;
|
336
|
+
}
|
337
|
+
|
338
|
+
// write data
|
339
|
+
vector<BamAlignment>::const_iterator buffIter = buffer.begin();
|
340
|
+
vector<BamAlignment>::const_iterator buffEnd = buffer.end();
|
341
|
+
for ( ; buffIter != buffEnd; ++buffIter ) {
|
342
|
+
const BamAlignment& al = (*buffIter);
|
343
|
+
tempWriter.SaveAlignment(al);
|
344
|
+
}
|
345
|
+
|
346
|
+
// close temp file & return success
|
347
|
+
tempWriter.Close();
|
348
|
+
return true;
|
349
|
+
}
|
350
|
+
|
351
|
+
// ---------------------------------------------
|
352
|
+
// SortTool implementation
|
353
|
+
|
354
|
+
SortTool::SortTool(void)
|
355
|
+
: AbstractTool()
|
356
|
+
, m_settings(new SortSettings)
|
357
|
+
, m_impl(0)
|
358
|
+
{
|
359
|
+
// set program details
|
360
|
+
Options::SetProgramInfo("bamtools sort", "sorts a BAM file", "[-in <filename>] [-out <filename>] [sortOptions]");
|
361
|
+
|
362
|
+
// set up options
|
363
|
+
OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
|
364
|
+
Options::AddValueOption("-in", "BAM filename", "the input BAM file", "",
|
365
|
+
m_settings->HasInputBamFilename, m_settings->InputBamFilename,
|
366
|
+
IO_Opts, Options::StandardIn());
|
367
|
+
Options::AddValueOption("-out", "BAM filename", "the output BAM file", "",
|
368
|
+
m_settings->HasOutputBamFilename, m_settings->OutputBamFilename,
|
369
|
+
IO_Opts, Options::StandardOut());
|
370
|
+
|
371
|
+
OptionGroup* SortOpts = Options::CreateOptionGroup("Sorting Methods");
|
372
|
+
Options::AddOption("-byname", "sort by alignment name", m_settings->IsSortingByName, SortOpts);
|
373
|
+
|
374
|
+
OptionGroup* MemOpts = Options::CreateOptionGroup("Memory Settings");
|
375
|
+
Options::AddValueOption("-n", "count", "max number of alignments per tempfile", "",
|
376
|
+
m_settings->HasMaxBufferCount, m_settings->MaxBufferCount,
|
377
|
+
MemOpts, SORT_DEFAULT_MAX_BUFFER_COUNT);
|
378
|
+
Options::AddValueOption("-mem", "Mb", "max memory to use", "",
|
379
|
+
m_settings->HasMaxBufferMemory, m_settings->MaxBufferMemory,
|
380
|
+
MemOpts, SORT_DEFAULT_MAX_BUFFER_MEMORY);
|
381
|
+
}
|
382
|
+
|
383
|
+
SortTool::~SortTool(void) {
|
384
|
+
|
385
|
+
delete m_settings;
|
386
|
+
m_settings = 0;
|
387
|
+
|
388
|
+
delete m_impl;
|
389
|
+
m_impl = 0;
|
390
|
+
}
|
391
|
+
|
392
|
+
int SortTool::Help(void) {
|
393
|
+
Options::DisplayHelp();
|
394
|
+
return 0;
|
395
|
+
}
|
396
|
+
|
397
|
+
int SortTool::Run(int argc, char* argv[]) {
|
398
|
+
|
399
|
+
// parse command line arguments
|
400
|
+
Options::Parse(argc, argv, 1);
|
401
|
+
|
402
|
+
// initialize SortTool with settings
|
403
|
+
m_impl = new SortToolPrivate(m_settings);
|
404
|
+
|
405
|
+
// run SortTool, return success/fail
|
406
|
+
if ( m_impl->Run() )
|
407
|
+
return 0;
|
408
|
+
else
|
409
|
+
return 1;
|
410
|
+
}
|