ngs_server 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,187 @@
|
|
|
1
|
+
// ***************************************************************************
|
|
2
|
+
// BamToolsIndex.h (c) 2010 Derek Barnett
|
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Last modified: 5 April 2011 (DB)
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Provides index operations for the BamTools index format (".bti")
|
|
8
|
+
// ***************************************************************************
|
|
9
|
+
|
|
10
|
+
#ifndef BAMTOOLS_INDEX_FORMAT_H
|
|
11
|
+
#define BAMTOOLS_INDEX_FORMAT_H
|
|
12
|
+
|
|
13
|
+
// -------------
|
|
14
|
+
// W A R N I N G
|
|
15
|
+
// -------------
|
|
16
|
+
//
|
|
17
|
+
// This file is not part of the BamTools API. It exists purely as an
|
|
18
|
+
// implementation detail. This header file may change from version to
|
|
19
|
+
// version without notice, or even be removed.
|
|
20
|
+
//
|
|
21
|
+
// We mean it.
|
|
22
|
+
|
|
23
|
+
#include <api/BamAux.h>
|
|
24
|
+
#include <api/BamIndex.h>
|
|
25
|
+
#include <map>
|
|
26
|
+
#include <string>
|
|
27
|
+
#include <vector>
|
|
28
|
+
|
|
29
|
+
namespace BamTools {
|
|
30
|
+
namespace Internal {
|
|
31
|
+
|
|
32
|
+
// contains data for each 'block' in a BTI index
|
|
33
|
+
struct BtiBlock {
|
|
34
|
+
|
|
35
|
+
// data members
|
|
36
|
+
int32_t MaxEndPosition;
|
|
37
|
+
int64_t StartOffset;
|
|
38
|
+
int32_t StartPosition;
|
|
39
|
+
|
|
40
|
+
// ctor
|
|
41
|
+
BtiBlock(const int32_t& maxEndPosition = 0,
|
|
42
|
+
const int64_t& startOffset = 0,
|
|
43
|
+
const int32_t& startPosition = 0)
|
|
44
|
+
: MaxEndPosition(maxEndPosition)
|
|
45
|
+
, StartOffset(startOffset)
|
|
46
|
+
, StartPosition(startPosition)
|
|
47
|
+
{ }
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// convenience typedef for describing a a list of BTI blocks on a reference
|
|
51
|
+
typedef std::vector<BtiBlock> BtiBlockVector;
|
|
52
|
+
|
|
53
|
+
// contains all fields necessary for building, loading, & writing
|
|
54
|
+
// full BTI index data for a single reference
|
|
55
|
+
struct BtiReferenceEntry {
|
|
56
|
+
|
|
57
|
+
// data members
|
|
58
|
+
int32_t ID;
|
|
59
|
+
BtiBlockVector Blocks;
|
|
60
|
+
|
|
61
|
+
// ctor
|
|
62
|
+
BtiReferenceEntry(const int& id = -1)
|
|
63
|
+
: ID(id)
|
|
64
|
+
{ }
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// provides (persistent) summary of BtiReferenceEntry's index data
|
|
68
|
+
struct BtiReferenceSummary {
|
|
69
|
+
|
|
70
|
+
// data members
|
|
71
|
+
int NumBlocks;
|
|
72
|
+
uint64_t FirstBlockFilePosition;
|
|
73
|
+
|
|
74
|
+
// ctor
|
|
75
|
+
BtiReferenceSummary(void)
|
|
76
|
+
: NumBlocks(0)
|
|
77
|
+
, FirstBlockFilePosition(0)
|
|
78
|
+
{ }
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// convenience typedef for describing a full BTI index file summary
|
|
82
|
+
typedef std::vector<BtiReferenceSummary> BtiFileSummary;
|
|
83
|
+
|
|
84
|
+
class BamToolsIndex : public BamIndex {
|
|
85
|
+
|
|
86
|
+
// keep a list of any supported versions here
|
|
87
|
+
// (might be useful later to handle any 'legacy' versions if the format changes)
|
|
88
|
+
// listed for example like: BTI_1_0 = 1, BTI_1_1 = 2, BTI_1_2 = 3, BTI_2_0 = 4, and so on
|
|
89
|
+
//
|
|
90
|
+
// so a change introduced in (hypothetical) BTI_1_2 would be handled from then on by:
|
|
91
|
+
//
|
|
92
|
+
// if ( indexVersion >= BTI_1_2 )
|
|
93
|
+
// do something new
|
|
94
|
+
// else
|
|
95
|
+
// do the old thing
|
|
96
|
+
enum Version { BTI_1_0 = 1
|
|
97
|
+
, BTI_1_1
|
|
98
|
+
, BTI_1_2
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// ctor & dtor
|
|
102
|
+
public:
|
|
103
|
+
BamToolsIndex(Internal::BamReaderPrivate* reader);
|
|
104
|
+
~BamToolsIndex(void);
|
|
105
|
+
|
|
106
|
+
// BamIndex implementation
|
|
107
|
+
public:
|
|
108
|
+
// builds index from associated BAM file & writes out to index file
|
|
109
|
+
bool Create(void);
|
|
110
|
+
// returns whether reference has alignments or no
|
|
111
|
+
bool HasAlignments(const int& referenceID) const;
|
|
112
|
+
// attempts to use index data to jump to @region, returns success/fail
|
|
113
|
+
// a "successful" jump indicates no error, but not whether this region has data
|
|
114
|
+
// * thus, the method sets a flag to indicate whether there are alignments
|
|
115
|
+
// available after the jump position
|
|
116
|
+
bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
|
|
117
|
+
// loads existing data from file into memory
|
|
118
|
+
bool Load(const std::string& filename);
|
|
119
|
+
// change the index caching behavior
|
|
120
|
+
void SetCacheMode(const BamIndex::IndexCacheMode& mode);
|
|
121
|
+
public:
|
|
122
|
+
// returns format's file extension
|
|
123
|
+
static const std::string Extension(void);
|
|
124
|
+
|
|
125
|
+
// internal file ops
|
|
126
|
+
private:
|
|
127
|
+
bool CheckMagicNumber(void);
|
|
128
|
+
bool CheckVersion(void);
|
|
129
|
+
void CloseFile(void);
|
|
130
|
+
bool IsFileOpen(void) const;
|
|
131
|
+
bool OpenFile(const std::string& filename, const char* mode);
|
|
132
|
+
bool Seek(const int64_t& position, const int& origin);
|
|
133
|
+
int64_t Tell(void) const;
|
|
134
|
+
|
|
135
|
+
// internal BTI index building methods
|
|
136
|
+
private:
|
|
137
|
+
void ClearReferenceEntry(BtiReferenceEntry& refEntry);
|
|
138
|
+
|
|
139
|
+
// internal random-access methods
|
|
140
|
+
private:
|
|
141
|
+
bool GetOffset(const BamRegion& region, int64_t& offset, bool* hasAlignmentsInRegion);
|
|
142
|
+
|
|
143
|
+
// internal BTI summary data methods
|
|
144
|
+
private:
|
|
145
|
+
void InitializeFileSummary(const int& numReferences);
|
|
146
|
+
bool LoadFileSummary(void);
|
|
147
|
+
bool LoadHeader(void);
|
|
148
|
+
bool LoadNumBlocks(int& numBlocks);
|
|
149
|
+
bool LoadNumReferences(int& numReferences);
|
|
150
|
+
bool LoadReferenceSummary(BtiReferenceSummary& refSummary);
|
|
151
|
+
bool SkipBlocks(const int& numBlocks);
|
|
152
|
+
|
|
153
|
+
// internal BTI full index input methods
|
|
154
|
+
private:
|
|
155
|
+
bool ReadBlock(BtiBlock& block);
|
|
156
|
+
bool ReadBlocks(const BtiReferenceSummary& refSummary, BtiBlockVector& blocks);
|
|
157
|
+
bool ReadReferenceEntry(BtiReferenceEntry& refEntry);
|
|
158
|
+
|
|
159
|
+
// internal BTI full index output methods
|
|
160
|
+
private:
|
|
161
|
+
bool WriteBlock(const BtiBlock& block);
|
|
162
|
+
bool WriteBlocks(const BtiBlockVector& blocks);
|
|
163
|
+
bool WriteHeader(void);
|
|
164
|
+
bool WriteReferenceEntry(const BtiReferenceEntry& refEntry);
|
|
165
|
+
|
|
166
|
+
// data members
|
|
167
|
+
private:
|
|
168
|
+
FILE* m_indexStream;
|
|
169
|
+
bool m_isBigEndian;
|
|
170
|
+
BamIndex::IndexCacheMode m_cacheMode;
|
|
171
|
+
BtiFileSummary m_indexFileSummary;
|
|
172
|
+
int m_blockSize;
|
|
173
|
+
int32_t m_inputVersion; // Version is serialized as int
|
|
174
|
+
Version m_outputVersion;
|
|
175
|
+
|
|
176
|
+
// static constants
|
|
177
|
+
private:
|
|
178
|
+
static const int DEFAULT_BLOCK_LENGTH;
|
|
179
|
+
static const std::string BTI_EXTENSION;
|
|
180
|
+
static const char* const BTI_MAGIC;
|
|
181
|
+
static const int SIZEOF_BLOCK;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
} // namespace Internal
|
|
185
|
+
} // namespace BamTools
|
|
186
|
+
|
|
187
|
+
#endif // BAMTOOLS_INDEX_FORMAT_H
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
// ***************************************************************************
|
|
2
|
+
// BamWriter_p.cpp (c) 2010 Derek Barnett
|
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Last modified: 16 June 2011 (DB)
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Provides the basic functionality for producing BAM files
|
|
8
|
+
// ***************************************************************************
|
|
9
|
+
|
|
10
|
+
#include <api/BamAlignment.h>
|
|
11
|
+
#include <api/BamConstants.h>
|
|
12
|
+
#include <api/internal/BamWriter_p.h>
|
|
13
|
+
using namespace BamTools;
|
|
14
|
+
using namespace BamTools::Internal;
|
|
15
|
+
|
|
16
|
+
#include <cstdio>
|
|
17
|
+
#include <cstdlib>
|
|
18
|
+
#include <cstring>
|
|
19
|
+
using namespace std;
|
|
20
|
+
|
|
21
|
+
// ctor
|
|
22
|
+
BamWriterPrivate::BamWriterPrivate(void)
|
|
23
|
+
: m_isBigEndian( BamTools::SystemIsBigEndian() )
|
|
24
|
+
{ }
|
|
25
|
+
|
|
26
|
+
// dtor
|
|
27
|
+
BamWriterPrivate::~BamWriterPrivate(void) {
|
|
28
|
+
m_stream.Close();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// calculates minimum bin for a BAM alignment interval
|
|
32
|
+
unsigned int BamWriterPrivate::CalculateMinimumBin(const int begin, int end) const {
|
|
33
|
+
--end;
|
|
34
|
+
if ( (begin >> 14) == (end >> 14) ) return 4681 + (begin >> 14);
|
|
35
|
+
if ( (begin >> 17) == (end >> 17) ) return 585 + (begin >> 17);
|
|
36
|
+
if ( (begin >> 20) == (end >> 20) ) return 73 + (begin >> 20);
|
|
37
|
+
if ( (begin >> 23) == (end >> 23) ) return 9 + (begin >> 23);
|
|
38
|
+
if ( (begin >> 26) == (end >> 26) ) return 1 + (begin >> 26);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// closes the alignment archive
|
|
43
|
+
void BamWriterPrivate::Close(void) {
|
|
44
|
+
m_stream.Close();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// creates a cigar string from the supplied alignment
|
|
48
|
+
void BamWriterPrivate::CreatePackedCigar(const vector<CigarOp>& cigarOperations, string& packedCigar) {
|
|
49
|
+
|
|
50
|
+
// initialize
|
|
51
|
+
const unsigned int numCigarOperations = cigarOperations.size();
|
|
52
|
+
packedCigar.resize(numCigarOperations * Constants::BAM_SIZEOF_INT);
|
|
53
|
+
|
|
54
|
+
// pack the cigar data into the string
|
|
55
|
+
unsigned int* pPackedCigar = (unsigned int*)packedCigar.data();
|
|
56
|
+
|
|
57
|
+
// iterate over cigar operations
|
|
58
|
+
vector<CigarOp>::const_iterator coIter = cigarOperations.begin();
|
|
59
|
+
vector<CigarOp>::const_iterator coEnd = cigarOperations.end();
|
|
60
|
+
for ( ; coIter != coEnd; ++coIter ) {
|
|
61
|
+
|
|
62
|
+
// store op in packedCigar
|
|
63
|
+
unsigned int cigarOp;
|
|
64
|
+
switch ( coIter->Type ) {
|
|
65
|
+
case (Constants::BAM_CIGAR_MATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_MATCH; break;
|
|
66
|
+
case (Constants::BAM_CIGAR_INS_CHAR) : cigarOp = Constants::BAM_CIGAR_INS; break;
|
|
67
|
+
case (Constants::BAM_CIGAR_DEL_CHAR) : cigarOp = Constants::BAM_CIGAR_DEL; break;
|
|
68
|
+
case (Constants::BAM_CIGAR_REFSKIP_CHAR) : cigarOp = Constants::BAM_CIGAR_REFSKIP; break;
|
|
69
|
+
case (Constants::BAM_CIGAR_SOFTCLIP_CHAR) : cigarOp = Constants::BAM_CIGAR_SOFTCLIP; break;
|
|
70
|
+
case (Constants::BAM_CIGAR_HARDCLIP_CHAR) : cigarOp = Constants::BAM_CIGAR_HARDCLIP; break;
|
|
71
|
+
case (Constants::BAM_CIGAR_PAD_CHAR) : cigarOp = Constants::BAM_CIGAR_PAD; break;
|
|
72
|
+
case (Constants::BAM_CIGAR_SEQMATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_SEQMATCH; break;
|
|
73
|
+
case (Constants::BAM_CIGAR_MISMATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_MISMATCH; break;
|
|
74
|
+
default:
|
|
75
|
+
fprintf(stderr, "BamWriter ERROR: unknown cigar operation found: %c\n", coIter->Type);
|
|
76
|
+
exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
*pPackedCigar = coIter->Length << Constants::BAM_CIGAR_SHIFT | cigarOp;
|
|
80
|
+
pPackedCigar++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// encodes the supplied query sequence into 4-bit notation
|
|
85
|
+
void BamWriterPrivate::EncodeQuerySequence(const string& query, string& encodedQuery) {
|
|
86
|
+
|
|
87
|
+
// prepare the encoded query string
|
|
88
|
+
const unsigned int queryLen = query.size();
|
|
89
|
+
const unsigned int encodedQueryLen = (unsigned int)((queryLen / 2.0) + 0.5);
|
|
90
|
+
encodedQuery.resize(encodedQueryLen);
|
|
91
|
+
char* pEncodedQuery = (char*)encodedQuery.data();
|
|
92
|
+
const char* pQuery = (const char*)query.data();
|
|
93
|
+
|
|
94
|
+
unsigned char nucleotideCode;
|
|
95
|
+
bool useHighWord = true;
|
|
96
|
+
|
|
97
|
+
while ( *pQuery ) {
|
|
98
|
+
switch ( *pQuery ) {
|
|
99
|
+
case (Constants::BAM_DNA_EQUAL) : nucleotideCode = Constants::BAM_BASECODE_EQUAL; break;
|
|
100
|
+
case (Constants::BAM_DNA_A) : nucleotideCode = Constants::BAM_BASECODE_A; break;
|
|
101
|
+
case (Constants::BAM_DNA_C) : nucleotideCode = Constants::BAM_BASECODE_C; break;
|
|
102
|
+
case (Constants::BAM_DNA_G) : nucleotideCode = Constants::BAM_BASECODE_G; break;
|
|
103
|
+
case (Constants::BAM_DNA_T) : nucleotideCode = Constants::BAM_BASECODE_T; break;
|
|
104
|
+
case (Constants::BAM_DNA_N) : nucleotideCode = Constants::BAM_BASECODE_N; break;
|
|
105
|
+
default:
|
|
106
|
+
fprintf(stderr, "BamWriter ERROR: only the following bases are supported in the BAM format: {=, A, C, G, T, N}. Found [%c]\n", *pQuery);
|
|
107
|
+
exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// pack the nucleotide code
|
|
111
|
+
if ( useHighWord ) {
|
|
112
|
+
*pEncodedQuery = nucleotideCode << 4;
|
|
113
|
+
useHighWord = false;
|
|
114
|
+
} else {
|
|
115
|
+
*pEncodedQuery |= nucleotideCode;
|
|
116
|
+
++pEncodedQuery;
|
|
117
|
+
useHighWord = true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// increment the query position
|
|
121
|
+
++pQuery;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// returns whether BAM file is open for writing or not
|
|
126
|
+
bool BamWriterPrivate::IsOpen(void) const {
|
|
127
|
+
return m_stream.IsOpen;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// opens the alignment archive
|
|
131
|
+
bool BamWriterPrivate::Open(const string& filename,
|
|
132
|
+
const string& samHeaderText,
|
|
133
|
+
const RefVector& referenceSequences)
|
|
134
|
+
{
|
|
135
|
+
// open the BGZF file for writing, return failure if error
|
|
136
|
+
if ( !m_stream.Open(filename, "wb") )
|
|
137
|
+
return false;
|
|
138
|
+
|
|
139
|
+
// write BAM file 'metadata' components
|
|
140
|
+
WriteMagicNumber();
|
|
141
|
+
WriteSamHeaderText(samHeaderText);
|
|
142
|
+
WriteReferences(referenceSequences);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// saves the alignment to the alignment archive
|
|
147
|
+
void BamWriterPrivate::SaveAlignment(const BamAlignment& al) {
|
|
148
|
+
|
|
149
|
+
// if BamAlignment contains only the core data and a raw char data buffer
|
|
150
|
+
// (as a result of BamReader::GetNextAlignmentCore())
|
|
151
|
+
if ( al.SupportData.HasCoreOnly ) {
|
|
152
|
+
|
|
153
|
+
// write the block size
|
|
154
|
+
unsigned int blockSize = al.SupportData.BlockLength;
|
|
155
|
+
if ( m_isBigEndian ) BamTools::SwapEndian_32(blockSize);
|
|
156
|
+
m_stream.Write((char*)&blockSize, Constants::BAM_SIZEOF_INT);
|
|
157
|
+
|
|
158
|
+
// re-calculate bin (in case BamAlignment's position has been previously modified)
|
|
159
|
+
const uint32_t alignmentBin = CalculateMinimumBin(al.Position, al.GetEndPosition());
|
|
160
|
+
|
|
161
|
+
// assign the BAM core data
|
|
162
|
+
uint32_t buffer[Constants::BAM_CORE_BUFFER_SIZE];
|
|
163
|
+
buffer[0] = al.RefID;
|
|
164
|
+
buffer[1] = al.Position;
|
|
165
|
+
buffer[2] = (alignmentBin << 16) | (al.MapQuality << 8) | al.SupportData.QueryNameLength;
|
|
166
|
+
buffer[3] = (al.AlignmentFlag << 16) | al.SupportData.NumCigarOperations;
|
|
167
|
+
buffer[4] = al.SupportData.QuerySequenceLength;
|
|
168
|
+
buffer[5] = al.MateRefID;
|
|
169
|
+
buffer[6] = al.MatePosition;
|
|
170
|
+
buffer[7] = al.InsertSize;
|
|
171
|
+
|
|
172
|
+
// swap BAM core endian-ness, if necessary
|
|
173
|
+
if ( m_isBigEndian ) {
|
|
174
|
+
for ( int i = 0; i < 8; ++i )
|
|
175
|
+
BamTools::SwapEndian_32(buffer[i]);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// write the BAM core
|
|
179
|
+
m_stream.Write((char*)&buffer, Constants::BAM_CORE_SIZE);
|
|
180
|
+
|
|
181
|
+
// write the raw char data
|
|
182
|
+
m_stream.Write((char*)al.SupportData.AllCharData.data(),
|
|
183
|
+
al.SupportData.BlockLength-Constants::BAM_CORE_SIZE);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// otherwise, BamAlignment should contain character in the standard fields: Name, QueryBases, etc
|
|
187
|
+
// ( resulting from BamReader::GetNextAlignment() *OR* being generated directly by client code )
|
|
188
|
+
else {
|
|
189
|
+
|
|
190
|
+
// calculate char lengths
|
|
191
|
+
const unsigned int nameLength = al.Name.size() + 1;
|
|
192
|
+
const unsigned int numCigarOperations = al.CigarData.size();
|
|
193
|
+
const unsigned int queryLength = al.QueryBases.size();
|
|
194
|
+
const unsigned int tagDataLength = al.TagData.size();
|
|
195
|
+
|
|
196
|
+
// no way to tell if BamAlignment.Bin is already defined (no default, invalid value)
|
|
197
|
+
// force calculation of Bin before storing
|
|
198
|
+
const int endPosition = al.GetEndPosition();
|
|
199
|
+
const unsigned int alignmentBin = CalculateMinimumBin(al.Position, endPosition);
|
|
200
|
+
|
|
201
|
+
// create our packed cigar string
|
|
202
|
+
string packedCigar;
|
|
203
|
+
CreatePackedCigar(al.CigarData, packedCigar);
|
|
204
|
+
const unsigned int packedCigarLength = packedCigar.size();
|
|
205
|
+
|
|
206
|
+
// encode the query
|
|
207
|
+
string encodedQuery;
|
|
208
|
+
EncodeQuerySequence(al.QueryBases, encodedQuery);
|
|
209
|
+
const unsigned int encodedQueryLength = encodedQuery.size();
|
|
210
|
+
|
|
211
|
+
// write the block size
|
|
212
|
+
const unsigned int dataBlockSize = nameLength +
|
|
213
|
+
packedCigarLength +
|
|
214
|
+
encodedQueryLength +
|
|
215
|
+
queryLength +
|
|
216
|
+
tagDataLength;
|
|
217
|
+
unsigned int blockSize = Constants::BAM_CORE_SIZE + dataBlockSize;
|
|
218
|
+
if ( m_isBigEndian ) BamTools::SwapEndian_32(blockSize);
|
|
219
|
+
m_stream.Write((char*)&blockSize, Constants::BAM_SIZEOF_INT);
|
|
220
|
+
|
|
221
|
+
// assign the BAM core data
|
|
222
|
+
uint32_t buffer[Constants::BAM_CORE_BUFFER_SIZE];
|
|
223
|
+
buffer[0] = al.RefID;
|
|
224
|
+
buffer[1] = al.Position;
|
|
225
|
+
buffer[2] = (alignmentBin << 16) | (al.MapQuality << 8) | nameLength;
|
|
226
|
+
buffer[3] = (al.AlignmentFlag << 16) | numCigarOperations;
|
|
227
|
+
buffer[4] = queryLength;
|
|
228
|
+
buffer[5] = al.MateRefID;
|
|
229
|
+
buffer[6] = al.MatePosition;
|
|
230
|
+
buffer[7] = al.InsertSize;
|
|
231
|
+
|
|
232
|
+
// swap BAM core endian-ness, if necessary
|
|
233
|
+
if ( m_isBigEndian ) {
|
|
234
|
+
for ( int i = 0; i < 8; ++i )
|
|
235
|
+
BamTools::SwapEndian_32(buffer[i]);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// write the BAM core
|
|
239
|
+
m_stream.Write((char*)&buffer, Constants::BAM_CORE_SIZE);
|
|
240
|
+
|
|
241
|
+
// write the query name
|
|
242
|
+
m_stream.Write(al.Name.c_str(), nameLength);
|
|
243
|
+
|
|
244
|
+
// write the packed cigar
|
|
245
|
+
if ( m_isBigEndian ) {
|
|
246
|
+
char* cigarData = (char*)calloc(sizeof(char), packedCigarLength);
|
|
247
|
+
memcpy(cigarData, packedCigar.data(), packedCigarLength);
|
|
248
|
+
if ( m_isBigEndian ) {
|
|
249
|
+
for ( unsigned int i = 0; i < packedCigarLength; ++i )
|
|
250
|
+
BamTools::SwapEndian_32p(&cigarData[i]);
|
|
251
|
+
}
|
|
252
|
+
m_stream.Write(cigarData, packedCigarLength);
|
|
253
|
+
free(cigarData);
|
|
254
|
+
}
|
|
255
|
+
else
|
|
256
|
+
m_stream.Write(packedCigar.data(), packedCigarLength);
|
|
257
|
+
|
|
258
|
+
// write the encoded query sequence
|
|
259
|
+
m_stream.Write(encodedQuery.data(), encodedQueryLength);
|
|
260
|
+
|
|
261
|
+
// write the base qualities
|
|
262
|
+
char* pBaseQualities = (char*)al.Qualities.data();
|
|
263
|
+
for ( unsigned int i = 0; i < queryLength; ++i )
|
|
264
|
+
pBaseQualities[i] -= 33; // FASTQ conversion
|
|
265
|
+
m_stream.Write(pBaseQualities, queryLength);
|
|
266
|
+
|
|
267
|
+
// write the read group tag
|
|
268
|
+
if ( m_isBigEndian ) {
|
|
269
|
+
|
|
270
|
+
char* tagData = (char*)calloc(sizeof(char), tagDataLength);
|
|
271
|
+
memcpy(tagData, al.TagData.data(), tagDataLength);
|
|
272
|
+
|
|
273
|
+
int i = 0;
|
|
274
|
+
while ( (unsigned int)i < tagDataLength ) {
|
|
275
|
+
|
|
276
|
+
i += Constants::BAM_TAG_TAGSIZE; // skip tag chars (e.g. "RG", "NM", etc.)
|
|
277
|
+
const char type = tagData[i]; // get tag type at position i
|
|
278
|
+
++i;
|
|
279
|
+
|
|
280
|
+
switch ( type ) {
|
|
281
|
+
|
|
282
|
+
case(Constants::BAM_TAG_TYPE_ASCII) :
|
|
283
|
+
case(Constants::BAM_TAG_TYPE_INT8) :
|
|
284
|
+
case(Constants::BAM_TAG_TYPE_UINT8) :
|
|
285
|
+
++i;
|
|
286
|
+
break;
|
|
287
|
+
|
|
288
|
+
case(Constants::BAM_TAG_TYPE_INT16) :
|
|
289
|
+
case(Constants::BAM_TAG_TYPE_UINT16) :
|
|
290
|
+
BamTools::SwapEndian_16p(&tagData[i]);
|
|
291
|
+
i += sizeof(uint16_t);
|
|
292
|
+
break;
|
|
293
|
+
|
|
294
|
+
case(Constants::BAM_TAG_TYPE_FLOAT) :
|
|
295
|
+
case(Constants::BAM_TAG_TYPE_INT32) :
|
|
296
|
+
case(Constants::BAM_TAG_TYPE_UINT32) :
|
|
297
|
+
BamTools::SwapEndian_32p(&tagData[i]);
|
|
298
|
+
i += sizeof(uint32_t);
|
|
299
|
+
break;
|
|
300
|
+
|
|
301
|
+
case(Constants::BAM_TAG_TYPE_HEX) :
|
|
302
|
+
case(Constants::BAM_TAG_TYPE_STRING) :
|
|
303
|
+
// no endian swapping necessary for hex-string/string data
|
|
304
|
+
while ( tagData[i] )
|
|
305
|
+
++i;
|
|
306
|
+
// increment one more for null terminator
|
|
307
|
+
++i;
|
|
308
|
+
break;
|
|
309
|
+
|
|
310
|
+
case(Constants::BAM_TAG_TYPE_ARRAY) :
|
|
311
|
+
|
|
312
|
+
{
|
|
313
|
+
// read array type
|
|
314
|
+
const char arrayType = tagData[i];
|
|
315
|
+
++i;
|
|
316
|
+
|
|
317
|
+
// swap endian-ness of number of elements in place, then retrieve for loop
|
|
318
|
+
BamTools::SwapEndian_32p(&tagData[i]);
|
|
319
|
+
int32_t numElements;
|
|
320
|
+
memcpy(&numElements, &tagData[i], sizeof(uint32_t));
|
|
321
|
+
i += sizeof(uint32_t);
|
|
322
|
+
|
|
323
|
+
// swap endian-ness of array elements
|
|
324
|
+
for ( int j = 0; j < numElements; ++j ) {
|
|
325
|
+
switch (arrayType) {
|
|
326
|
+
case (Constants::BAM_TAG_TYPE_INT8) :
|
|
327
|
+
case (Constants::BAM_TAG_TYPE_UINT8) :
|
|
328
|
+
// no endian-swapping necessary
|
|
329
|
+
++i;
|
|
330
|
+
break;
|
|
331
|
+
case (Constants::BAM_TAG_TYPE_INT16) :
|
|
332
|
+
case (Constants::BAM_TAG_TYPE_UINT16) :
|
|
333
|
+
BamTools::SwapEndian_16p(&tagData[i]);
|
|
334
|
+
i += sizeof(uint16_t);
|
|
335
|
+
break;
|
|
336
|
+
case (Constants::BAM_TAG_TYPE_FLOAT) :
|
|
337
|
+
case (Constants::BAM_TAG_TYPE_INT32) :
|
|
338
|
+
case (Constants::BAM_TAG_TYPE_UINT32) :
|
|
339
|
+
BamTools::SwapEndian_32p(&tagData[i]);
|
|
340
|
+
i += sizeof(uint32_t);
|
|
341
|
+
break;
|
|
342
|
+
default:
|
|
343
|
+
// error case
|
|
344
|
+
fprintf(stderr,
|
|
345
|
+
"BamWriter ERROR: unknown binary array type encountered: [%c]\n",
|
|
346
|
+
arrayType);
|
|
347
|
+
exit(1);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
default :
|
|
355
|
+
fprintf(stderr, "BamWriter ERROR: invalid tag value type\n"); // shouldn't get here
|
|
356
|
+
free(tagData);
|
|
357
|
+
exit(1);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
m_stream.Write(tagData, tagDataLength);
|
|
361
|
+
free(tagData);
|
|
362
|
+
}
|
|
363
|
+
else
|
|
364
|
+
m_stream.Write(al.TagData.data(), tagDataLength);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
void BamWriterPrivate::SetWriteCompressed(bool ok) {
|
|
369
|
+
|
|
370
|
+
// warn if BAM file is already open
|
|
371
|
+
// modifying compression is not allowed in this case
|
|
372
|
+
if ( IsOpen() ) {
|
|
373
|
+
cerr << "BamWriter WARNING: attempting to change compression mode on an open BAM file is not allowed. "
|
|
374
|
+
<< "Ignoring request." << endl;
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// set BgzfStream compression mode
|
|
379
|
+
m_stream.SetWriteCompressed(ok);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
void BamWriterPrivate::WriteMagicNumber(void) {
|
|
383
|
+
// write BAM file 'magic number'
|
|
384
|
+
m_stream.Write(Constants::BAM_HEADER_MAGIC, Constants::BAM_HEADER_MAGIC_LENGTH);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
void BamWriterPrivate::WriteReferences(const BamTools::RefVector& referenceSequences) {
|
|
388
|
+
|
|
389
|
+
// write the number of reference sequences
|
|
390
|
+
uint32_t numReferenceSequences = referenceSequences.size();
|
|
391
|
+
if ( m_isBigEndian ) BamTools::SwapEndian_32(numReferenceSequences);
|
|
392
|
+
m_stream.Write((char*)&numReferenceSequences, Constants::BAM_SIZEOF_INT);
|
|
393
|
+
|
|
394
|
+
// foreach reference sequence
|
|
395
|
+
RefVector::const_iterator rsIter = referenceSequences.begin();
|
|
396
|
+
RefVector::const_iterator rsEnd = referenceSequences.end();
|
|
397
|
+
for ( ; rsIter != rsEnd; ++rsIter ) {
|
|
398
|
+
|
|
399
|
+
// write the reference sequence name length
|
|
400
|
+
uint32_t referenceSequenceNameLen = rsIter->RefName.size() + 1;
|
|
401
|
+
if ( m_isBigEndian ) BamTools::SwapEndian_32(referenceSequenceNameLen);
|
|
402
|
+
m_stream.Write((char*)&referenceSequenceNameLen, Constants::BAM_SIZEOF_INT);
|
|
403
|
+
|
|
404
|
+
// write the reference sequence name
|
|
405
|
+
m_stream.Write(rsIter->RefName.c_str(), referenceSequenceNameLen);
|
|
406
|
+
|
|
407
|
+
// write the reference sequence length
|
|
408
|
+
int32_t referenceLength = rsIter->RefLength;
|
|
409
|
+
if ( m_isBigEndian ) BamTools::SwapEndian_32(referenceLength);
|
|
410
|
+
m_stream.Write((char*)&referenceLength, Constants::BAM_SIZEOF_INT);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
void BamWriterPrivate::WriteSamHeaderText(const std::string& samHeaderText) {
|
|
415
|
+
|
|
416
|
+
// write the SAM header text length
|
|
417
|
+
uint32_t samHeaderLen = samHeaderText.size();
|
|
418
|
+
if ( m_isBigEndian ) BamTools::SwapEndian_32(samHeaderLen);
|
|
419
|
+
m_stream.Write((char*)&samHeaderLen, Constants::BAM_SIZEOF_INT);
|
|
420
|
+
|
|
421
|
+
// write the SAM header text
|
|
422
|
+
if ( samHeaderLen > 0 )
|
|
423
|
+
m_stream.Write(samHeaderText.data(), samHeaderLen);
|
|
424
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// ***************************************************************************
|
|
2
|
+
// BamWriter_p.h (c) 2010 Derek Barnett
|
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Last modified: 24 February 2011 (DB)
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Provides the basic functionality for producing BAM files
|
|
8
|
+
// ***************************************************************************
|
|
9
|
+
|
|
10
|
+
#ifndef BAMWRITER_P_H
|
|
11
|
+
#define BAMWRITER_P_H
|
|
12
|
+
|
|
13
|
+
// -------------
|
|
14
|
+
// W A R N I N G
|
|
15
|
+
// -------------
|
|
16
|
+
//
|
|
17
|
+
// This file is not part of the BamTools API. It exists purely as an
|
|
18
|
+
// implementation detail. This header file may change from version to
|
|
19
|
+
// version without notice, or even be removed.
|
|
20
|
+
//
|
|
21
|
+
// We mean it.
|
|
22
|
+
|
|
23
|
+
#include <api/BamAux.h>
|
|
24
|
+
#include <api/internal/BgzfStream_p.h>
|
|
25
|
+
#include <string>
|
|
26
|
+
#include <vector>
|
|
27
|
+
|
|
28
|
+
namespace BamTools {
|
|
29
|
+
namespace Internal {
|
|
30
|
+
|
|
31
|
+
class BamWriterPrivate {
|
|
32
|
+
|
|
33
|
+
// ctor & dtor
|
|
34
|
+
public:
|
|
35
|
+
BamWriterPrivate(void);
|
|
36
|
+
~BamWriterPrivate(void);
|
|
37
|
+
|
|
38
|
+
// interface methods
|
|
39
|
+
public:
|
|
40
|
+
void Close(void);
|
|
41
|
+
bool IsOpen(void) const;
|
|
42
|
+
bool Open(const std::string& filename,
|
|
43
|
+
const std::string& samHeaderText,
|
|
44
|
+
const BamTools::RefVector& referenceSequences);
|
|
45
|
+
void SaveAlignment(const BamAlignment& al);
|
|
46
|
+
void SetWriteCompressed(bool ok);
|
|
47
|
+
|
|
48
|
+
// 'internal' methods
|
|
49
|
+
public:
|
|
50
|
+
unsigned int CalculateMinimumBin(const int begin, int end) const;
|
|
51
|
+
void CreatePackedCigar(const std::vector<BamTools::CigarOp>& cigarOperations, std::string& packedCigar);
|
|
52
|
+
void EncodeQuerySequence(const std::string& query, std::string& encodedQuery);
|
|
53
|
+
void WriteMagicNumber(void);
|
|
54
|
+
void WriteReferences(const BamTools::RefVector& referenceSequences);
|
|
55
|
+
void WriteSamHeaderText(const std::string& samHeaderText);
|
|
56
|
+
|
|
57
|
+
// data members
|
|
58
|
+
private:
|
|
59
|
+
BgzfStream m_stream;
|
|
60
|
+
bool m_isBigEndian;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
} // namespace Internal
|
|
64
|
+
} // namespace BamTools
|
|
65
|
+
|
|
66
|
+
#endif // BAMWRITER_P_H
|