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,888 @@
|
|
|
1
|
+
// ***************************************************************************
|
|
2
|
+
// bamtools_convert.cpp (c) 2010 Derek Barnett, Erik Garrison
|
|
3
|
+
// Marth Lab, Department of Biology, Boston College
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Last modified: 11 June 2011
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Converts between BAM and a number of other formats
|
|
8
|
+
// ***************************************************************************
|
|
9
|
+
|
|
10
|
+
#include "bamtools_convert.h"
|
|
11
|
+
|
|
12
|
+
#include <api/BamConstants.h>
|
|
13
|
+
#include <api/BamMultiReader.h>
|
|
14
|
+
#include <utils/bamtools_fasta.h>
|
|
15
|
+
#include <utils/bamtools_options.h>
|
|
16
|
+
#include <utils/bamtools_pileup_engine.h>
|
|
17
|
+
#include <utils/bamtools_utilities.h>
|
|
18
|
+
using namespace BamTools;
|
|
19
|
+
|
|
20
|
+
#include <fstream>
|
|
21
|
+
#include <iostream>
|
|
22
|
+
#include <sstream>
|
|
23
|
+
#include <string>
|
|
24
|
+
#include <vector>
|
|
25
|
+
using namespace std;
|
|
26
|
+
|
|
27
|
+
namespace BamTools {
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------
|
|
30
|
+
// ConvertTool constants
|
|
31
|
+
|
|
32
|
+
// supported conversion format command-line names
|
|
33
|
+
static const string FORMAT_BED = "bed";
|
|
34
|
+
static const string FORMAT_FASTA = "fasta";
|
|
35
|
+
static const string FORMAT_FASTQ = "fastq";
|
|
36
|
+
static const string FORMAT_JSON = "json";
|
|
37
|
+
static const string FORMAT_SAM = "sam";
|
|
38
|
+
static const string FORMAT_PILEUP = "pileup";
|
|
39
|
+
static const string FORMAT_YAML = "yaml";
|
|
40
|
+
|
|
41
|
+
// other constants
|
|
42
|
+
static const unsigned int FASTA_LINE_MAX = 50;
|
|
43
|
+
|
|
44
|
+
// ---------------------------------------------
|
|
45
|
+
// ConvertPileupFormatVisitor declaration
|
|
46
|
+
|
|
47
|
+
class ConvertPileupFormatVisitor : public PileupVisitor {
|
|
48
|
+
|
|
49
|
+
// ctor & dtor
|
|
50
|
+
public:
|
|
51
|
+
ConvertPileupFormatVisitor(const RefVector& references,
|
|
52
|
+
const string& fastaFilename,
|
|
53
|
+
const bool isPrintingMapQualities,
|
|
54
|
+
ostream* out);
|
|
55
|
+
~ConvertPileupFormatVisitor(void);
|
|
56
|
+
|
|
57
|
+
// PileupVisitor interface implementation
|
|
58
|
+
public:
|
|
59
|
+
void Visit(const PileupPosition& pileupData);
|
|
60
|
+
|
|
61
|
+
// data members
|
|
62
|
+
private:
|
|
63
|
+
Fasta m_fasta;
|
|
64
|
+
bool m_hasFasta;
|
|
65
|
+
bool m_isPrintingMapQualities;
|
|
66
|
+
ostream* m_out;
|
|
67
|
+
RefVector m_references;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace BamTools
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------
|
|
73
|
+
// ConvertSettings implementation
|
|
74
|
+
|
|
75
|
+
struct ConvertTool::ConvertSettings {
|
|
76
|
+
|
|
77
|
+
// flag
|
|
78
|
+
bool HasInput;
|
|
79
|
+
bool HasOutput;
|
|
80
|
+
bool HasFormat;
|
|
81
|
+
bool HasRegion;
|
|
82
|
+
|
|
83
|
+
// pileup flags
|
|
84
|
+
bool HasFastaFilename;
|
|
85
|
+
bool IsOmittingSamHeader;
|
|
86
|
+
bool IsPrintingPileupMapQualities;
|
|
87
|
+
|
|
88
|
+
// options
|
|
89
|
+
vector<string> InputFiles;
|
|
90
|
+
string OutputFilename;
|
|
91
|
+
string Format;
|
|
92
|
+
string Region;
|
|
93
|
+
|
|
94
|
+
// pileup options
|
|
95
|
+
string FastaFilename;
|
|
96
|
+
|
|
97
|
+
// constructor
|
|
98
|
+
ConvertSettings(void)
|
|
99
|
+
: HasInput(false)
|
|
100
|
+
, HasOutput(false)
|
|
101
|
+
, HasFormat(false)
|
|
102
|
+
, HasRegion(false)
|
|
103
|
+
, HasFastaFilename(false)
|
|
104
|
+
, IsOmittingSamHeader(false)
|
|
105
|
+
, IsPrintingPileupMapQualities(false)
|
|
106
|
+
, OutputFilename(Options::StandardOut())
|
|
107
|
+
, FastaFilename("")
|
|
108
|
+
{ }
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// ---------------------------------------------
|
|
112
|
+
// ConvertToolPrivate implementation
|
|
113
|
+
|
|
114
|
+
struct ConvertTool::ConvertToolPrivate {
|
|
115
|
+
|
|
116
|
+
// ctor & dtor
|
|
117
|
+
public:
|
|
118
|
+
ConvertToolPrivate(ConvertTool::ConvertSettings* settings)
|
|
119
|
+
: m_settings(settings)
|
|
120
|
+
, m_out(cout.rdbuf())
|
|
121
|
+
{ }
|
|
122
|
+
|
|
123
|
+
~ConvertToolPrivate(void) { }
|
|
124
|
+
|
|
125
|
+
// interface
|
|
126
|
+
public:
|
|
127
|
+
bool Run(void);
|
|
128
|
+
|
|
129
|
+
// internal methods
|
|
130
|
+
private:
|
|
131
|
+
void PrintBed(const BamAlignment& a);
|
|
132
|
+
void PrintFasta(const BamAlignment& a);
|
|
133
|
+
void PrintFastq(const BamAlignment& a);
|
|
134
|
+
void PrintJson(const BamAlignment& a);
|
|
135
|
+
void PrintSam(const BamAlignment& a);
|
|
136
|
+
void PrintYaml(const BamAlignment& a);
|
|
137
|
+
|
|
138
|
+
// special case - uses the PileupEngine
|
|
139
|
+
bool RunPileupConversion(BamMultiReader* reader);
|
|
140
|
+
|
|
141
|
+
// data members
|
|
142
|
+
private:
|
|
143
|
+
ConvertTool::ConvertSettings* m_settings;
|
|
144
|
+
RefVector m_references;
|
|
145
|
+
ostream m_out;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
bool ConvertTool::ConvertToolPrivate::Run(void) {
|
|
149
|
+
|
|
150
|
+
// ------------------------------------
|
|
151
|
+
// initialize conversion input/output
|
|
152
|
+
|
|
153
|
+
// set to default input if none provided
|
|
154
|
+
if ( !m_settings->HasInput )
|
|
155
|
+
m_settings->InputFiles.push_back(Options::StandardIn());
|
|
156
|
+
|
|
157
|
+
// open input files
|
|
158
|
+
BamMultiReader reader;
|
|
159
|
+
if ( !reader.Open(m_settings->InputFiles) ) {
|
|
160
|
+
cerr << "bamtools convert ERROR: could not open input BAM file(s)... Aborting." << endl;
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// if input is not stdin & a region is provided, look for index files
|
|
165
|
+
if ( m_settings->HasInput && m_settings->HasRegion ) {
|
|
166
|
+
if ( !reader.LocateIndexes() ) {
|
|
167
|
+
cerr << "bamtools convert ERROR: could not locate index file(s)... Aborting." << endl;
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// retrieve reference data
|
|
173
|
+
m_references = reader.GetReferenceData();
|
|
174
|
+
|
|
175
|
+
// set region if specified
|
|
176
|
+
BamRegion region;
|
|
177
|
+
if ( m_settings->HasRegion ) {
|
|
178
|
+
if ( Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
|
|
179
|
+
|
|
180
|
+
if ( reader.HasIndexes() ) {
|
|
181
|
+
if ( !reader.SetRegion(region) ) {
|
|
182
|
+
cerr << "bamtools convert ERROR: set region failed. Check that REGION describes a valid range" << endl;
|
|
183
|
+
reader.Close();
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
} else {
|
|
189
|
+
cerr << "bamtools convert ERROR: could not parse REGION: " << m_settings->Region << endl;
|
|
190
|
+
cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
|
|
191
|
+
<< endl;
|
|
192
|
+
reader.Close();
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// if output file given
|
|
198
|
+
ofstream outFile;
|
|
199
|
+
if ( m_settings->HasOutput ) {
|
|
200
|
+
|
|
201
|
+
// open output file stream
|
|
202
|
+
outFile.open(m_settings->OutputFilename.c_str());
|
|
203
|
+
if ( !outFile ) {
|
|
204
|
+
cerr << "bamtools convert ERROR: could not open " << m_settings->OutputFilename
|
|
205
|
+
<< " for output" << endl;
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// set m_out to file's streambuf
|
|
210
|
+
m_out.rdbuf(outFile.rdbuf());
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// -------------------------------------
|
|
214
|
+
// do conversion based on format
|
|
215
|
+
|
|
216
|
+
bool convertedOk = true;
|
|
217
|
+
|
|
218
|
+
// pileup is special case
|
|
219
|
+
// conversion not done per alignment, like the other formats
|
|
220
|
+
if ( m_settings->Format == FORMAT_PILEUP )
|
|
221
|
+
convertedOk = RunPileupConversion(&reader);
|
|
222
|
+
|
|
223
|
+
// all other formats
|
|
224
|
+
else {
|
|
225
|
+
|
|
226
|
+
bool formatError = false;
|
|
227
|
+
|
|
228
|
+
// set function pointer to proper conversion method
|
|
229
|
+
void (BamTools::ConvertTool::ConvertToolPrivate::*pFunction)(const BamAlignment&) = 0;
|
|
230
|
+
if ( m_settings->Format == FORMAT_BED ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintBed;
|
|
231
|
+
else if ( m_settings->Format == FORMAT_FASTA ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintFasta;
|
|
232
|
+
else if ( m_settings->Format == FORMAT_FASTQ ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintFastq;
|
|
233
|
+
else if ( m_settings->Format == FORMAT_JSON ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintJson;
|
|
234
|
+
else if ( m_settings->Format == FORMAT_SAM ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintSam;
|
|
235
|
+
else if ( m_settings->Format == FORMAT_YAML ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintYaml;
|
|
236
|
+
else {
|
|
237
|
+
cerr << "bamtools convert ERROR: unrecognized format: " << m_settings->Format << endl;
|
|
238
|
+
cerr << "Please see documentation for list of supported formats " << endl;
|
|
239
|
+
formatError = true;
|
|
240
|
+
convertedOk = false;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// if format selected ok
|
|
244
|
+
if ( !formatError ) {
|
|
245
|
+
|
|
246
|
+
// if SAM format & not omitting header, print SAM header first
|
|
247
|
+
if ( (m_settings->Format == FORMAT_SAM) && !m_settings->IsOmittingSamHeader )
|
|
248
|
+
m_out << reader.GetHeaderText();
|
|
249
|
+
|
|
250
|
+
// iterate through file, doing conversion
|
|
251
|
+
BamAlignment a;
|
|
252
|
+
while ( reader.GetNextAlignment(a) )
|
|
253
|
+
(this->*pFunction)(a);
|
|
254
|
+
|
|
255
|
+
// set flag for successful conversion
|
|
256
|
+
convertedOk = true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ------------------------
|
|
261
|
+
// clean up & exit
|
|
262
|
+
reader.Close();
|
|
263
|
+
if ( m_settings->HasOutput )
|
|
264
|
+
outFile.close();
|
|
265
|
+
return convertedOk;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ----------------------------------------------------------
|
|
269
|
+
// Conversion/output methods
|
|
270
|
+
// ----------------------------------------------------------
|
|
271
|
+
|
|
272
|
+
void ConvertTool::ConvertToolPrivate::PrintBed(const BamAlignment& a) {
|
|
273
|
+
|
|
274
|
+
// tab-delimited, 0-based half-open
|
|
275
|
+
// (e.g. a 50-base read aligned to pos 10 could have BED coordinates (10, 60) instead of BAM coordinates (10, 59) )
|
|
276
|
+
// <chromName> <chromStart> <chromEnd> <readName> <score> <strand>
|
|
277
|
+
|
|
278
|
+
m_out << m_references.at(a.RefID).RefName << "\t"
|
|
279
|
+
<< a.Position << "\t"
|
|
280
|
+
<< a.GetEndPosition() + 1 << "\t"
|
|
281
|
+
<< a.Name << "\t"
|
|
282
|
+
<< a.MapQuality << "\t"
|
|
283
|
+
<< (a.IsReverseStrand() ? "-" : "+") << endl;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// print BamAlignment in FASTA format
|
|
287
|
+
// N.B. - uses QueryBases NOT AlignedBases
|
|
288
|
+
void ConvertTool::ConvertToolPrivate::PrintFasta(const BamAlignment& a) {
|
|
289
|
+
|
|
290
|
+
// >BamAlignment.Name
|
|
291
|
+
// BamAlignment.QueryBases (up to FASTA_LINE_MAX bases per line)
|
|
292
|
+
// ...
|
|
293
|
+
//
|
|
294
|
+
// N.B. - QueryBases are reverse-complemented if aligned to reverse strand
|
|
295
|
+
|
|
296
|
+
// print header
|
|
297
|
+
m_out << ">" << a.Name << endl;
|
|
298
|
+
|
|
299
|
+
// handle reverse strand alignment - bases
|
|
300
|
+
string sequence = a.QueryBases;
|
|
301
|
+
if ( a.IsReverseStrand() )
|
|
302
|
+
Utilities::ReverseComplement(sequence);
|
|
303
|
+
|
|
304
|
+
// if sequence fits on single line
|
|
305
|
+
if ( sequence.length() <= FASTA_LINE_MAX )
|
|
306
|
+
m_out << sequence << endl;
|
|
307
|
+
|
|
308
|
+
// else split over multiple lines
|
|
309
|
+
else {
|
|
310
|
+
|
|
311
|
+
size_t position = 0;
|
|
312
|
+
size_t seqLength = sequence.length(); // handle reverse strand alignment - bases & qualitiesth();
|
|
313
|
+
|
|
314
|
+
// write subsequences to each line
|
|
315
|
+
while ( position < (seqLength - FASTA_LINE_MAX) ) {
|
|
316
|
+
m_out << sequence.substr(position, FASTA_LINE_MAX) << endl;
|
|
317
|
+
position += FASTA_LINE_MAX;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// write final subsequence
|
|
321
|
+
m_out << sequence.substr(position) << endl;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// print BamAlignment in FASTQ format
|
|
326
|
+
// N.B. - uses QueryBases NOT AlignedBases
|
|
327
|
+
void ConvertTool::ConvertToolPrivate::PrintFastq(const BamAlignment& a) {
|
|
328
|
+
|
|
329
|
+
// @BamAlignment.Name
|
|
330
|
+
// BamAlignment.QueryBases
|
|
331
|
+
// +
|
|
332
|
+
// BamAlignment.Qualities
|
|
333
|
+
//
|
|
334
|
+
// N.B. - QueryBases are reverse-complemented (& Qualities reversed) if aligned to reverse strand .
|
|
335
|
+
// Name is appended "/1" or "/2" if paired-end, to reflect which mate this entry is.
|
|
336
|
+
|
|
337
|
+
// handle paired-end alignments
|
|
338
|
+
string name = a.Name;
|
|
339
|
+
if ( a.IsPaired() )
|
|
340
|
+
name.append( (a.IsFirstMate() ? "/1" : "/2") );
|
|
341
|
+
|
|
342
|
+
// handle reverse strand alignment - bases & qualities
|
|
343
|
+
string qualities = a.Qualities;
|
|
344
|
+
string sequence = a.QueryBases;
|
|
345
|
+
if ( a.IsReverseStrand() ) {
|
|
346
|
+
Utilities::Reverse(qualities);
|
|
347
|
+
Utilities::ReverseComplement(sequence);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// write to output stream
|
|
351
|
+
m_out << "@" << name << endl
|
|
352
|
+
<< sequence << endl
|
|
353
|
+
<< "+" << endl
|
|
354
|
+
<< qualities << endl;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// print BamAlignment in JSON format
|
|
358
|
+
void ConvertTool::ConvertToolPrivate::PrintJson(const BamAlignment& a) {
|
|
359
|
+
|
|
360
|
+
// write name & alignment flag
|
|
361
|
+
m_out << "{\"name\":\"" << a.Name << "\",\"alignmentFlag\":\"" << a.AlignmentFlag << "\",";
|
|
362
|
+
|
|
363
|
+
// write reference name
|
|
364
|
+
if ( (a.RefID >= 0) && (a.RefID < (int)m_references.size()) )
|
|
365
|
+
m_out << "\"reference\":\"" << m_references[a.RefID].RefName << "\",";
|
|
366
|
+
|
|
367
|
+
// write position & map quality
|
|
368
|
+
m_out << "\"position\":" << a.Position+1 << ",\"mapQuality\":" << a.MapQuality << ",";
|
|
369
|
+
|
|
370
|
+
// write CIGAR
|
|
371
|
+
const vector<CigarOp>& cigarData = a.CigarData;
|
|
372
|
+
if ( !cigarData.empty() ) {
|
|
373
|
+
m_out << "\"cigar\":[";
|
|
374
|
+
vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
|
|
375
|
+
vector<CigarOp>::const_iterator cigarIter = cigarBegin;
|
|
376
|
+
vector<CigarOp>::const_iterator cigarEnd = cigarData.end();
|
|
377
|
+
for ( ; cigarIter != cigarEnd; ++cigarIter ) {
|
|
378
|
+
const CigarOp& op = (*cigarIter);
|
|
379
|
+
if (cigarIter != cigarBegin)
|
|
380
|
+
m_out << ",";
|
|
381
|
+
m_out << "\"" << op.Length << op.Type << "\"";
|
|
382
|
+
}
|
|
383
|
+
m_out << "],";
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// write mate reference name, mate position, & insert size
|
|
387
|
+
if ( a.IsPaired() && (a.MateRefID >= 0) && (a.MateRefID < (int)m_references.size()) ) {
|
|
388
|
+
m_out << "\"mate\":{"
|
|
389
|
+
<< "\"reference\":\"" << m_references[a.MateRefID].RefName << "\","
|
|
390
|
+
<< "\"position\":" << a.MatePosition+1
|
|
391
|
+
<< ",\"insertSize\":" << a.InsertSize << "},";
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// write sequence
|
|
395
|
+
if ( !a.QueryBases.empty() )
|
|
396
|
+
m_out << "\"queryBases\":\"" << a.QueryBases << "\",";
|
|
397
|
+
|
|
398
|
+
// write qualities
|
|
399
|
+
if ( !a.Qualities.empty() ) {
|
|
400
|
+
string::const_iterator s = a.Qualities.begin();
|
|
401
|
+
m_out << "\"qualities\":[" << static_cast<short>(*s) - 33;
|
|
402
|
+
++s;
|
|
403
|
+
for ( ; s != a.Qualities.end(); ++s )
|
|
404
|
+
m_out << "," << static_cast<short>(*s) - 33;
|
|
405
|
+
m_out << "],";
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// write alignment's source BAM file
|
|
409
|
+
m_out << "\"filename\":" << a.Filename << ",";
|
|
410
|
+
|
|
411
|
+
// write tag data
|
|
412
|
+
const char* tagData = a.TagData.c_str();
|
|
413
|
+
const size_t tagDataLength = a.TagData.length();
|
|
414
|
+
size_t index = 0;
|
|
415
|
+
if ( index < tagDataLength ) {
|
|
416
|
+
|
|
417
|
+
m_out << "\"tags\":{";
|
|
418
|
+
|
|
419
|
+
while ( index < tagDataLength ) {
|
|
420
|
+
|
|
421
|
+
if ( index > 0 )
|
|
422
|
+
m_out << ",";
|
|
423
|
+
|
|
424
|
+
// write tag name
|
|
425
|
+
m_out << "\"" << a.TagData.substr(index, 2) << "\":";
|
|
426
|
+
index += 2;
|
|
427
|
+
|
|
428
|
+
// get data type
|
|
429
|
+
char type = a.TagData.at(index);
|
|
430
|
+
++index;
|
|
431
|
+
switch ( type ) {
|
|
432
|
+
case (Constants::BAM_TAG_TYPE_ASCII) :
|
|
433
|
+
m_out << "\"" << tagData[index] << "\"";
|
|
434
|
+
++index;
|
|
435
|
+
break;
|
|
436
|
+
|
|
437
|
+
case (Constants::BAM_TAG_TYPE_INT8) :
|
|
438
|
+
case (Constants::BAM_TAG_TYPE_UINT8) :
|
|
439
|
+
m_out << (int)tagData[index];
|
|
440
|
+
++index;
|
|
441
|
+
break;
|
|
442
|
+
|
|
443
|
+
case (Constants::BAM_TAG_TYPE_INT16) :
|
|
444
|
+
m_out << BamTools::UnpackSignedShort(&tagData[index]);
|
|
445
|
+
index += sizeof(int16_t);
|
|
446
|
+
break;
|
|
447
|
+
|
|
448
|
+
case (Constants::BAM_TAG_TYPE_UINT16) :
|
|
449
|
+
m_out << BamTools::UnpackUnsignedShort(&tagData[index]);
|
|
450
|
+
index += sizeof(uint16_t);
|
|
451
|
+
break;
|
|
452
|
+
|
|
453
|
+
case (Constants::BAM_TAG_TYPE_INT32) :
|
|
454
|
+
m_out << BamTools::UnpackSignedInt(&tagData[index]);
|
|
455
|
+
index += sizeof(int32_t);
|
|
456
|
+
break;
|
|
457
|
+
|
|
458
|
+
case (Constants::BAM_TAG_TYPE_UINT32) :
|
|
459
|
+
m_out << BamTools::UnpackUnsignedInt(&tagData[index]);
|
|
460
|
+
index += sizeof(uint32_t);
|
|
461
|
+
break;
|
|
462
|
+
|
|
463
|
+
case (Constants::BAM_TAG_TYPE_FLOAT) :
|
|
464
|
+
m_out << BamTools::UnpackFloat(&tagData[index]);
|
|
465
|
+
index += sizeof(float);
|
|
466
|
+
break;
|
|
467
|
+
|
|
468
|
+
case (Constants::BAM_TAG_TYPE_HEX) :
|
|
469
|
+
case (Constants::BAM_TAG_TYPE_STRING) :
|
|
470
|
+
m_out << "\"";
|
|
471
|
+
while (tagData[index]) {
|
|
472
|
+
if (tagData[index] == '\"')
|
|
473
|
+
m_out << "\\\""; // escape for json
|
|
474
|
+
else
|
|
475
|
+
m_out << tagData[index];
|
|
476
|
+
++index;
|
|
477
|
+
}
|
|
478
|
+
m_out << "\"";
|
|
479
|
+
++index;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if ( tagData[index] == '\0')
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
m_out << "}";
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
m_out << "}" << endl;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// print BamAlignment in SAM format
|
|
494
|
+
void ConvertTool::ConvertToolPrivate::PrintSam(const BamAlignment& a) {
|
|
495
|
+
|
|
496
|
+
// tab-delimited
|
|
497
|
+
// <QNAME> <FLAG> <RNAME> <POS> <MAPQ> <CIGAR> <MRNM> <MPOS> <ISIZE> <SEQ> <QUAL> [ <TAG>:<VTYPE>:<VALUE> [...] ]
|
|
498
|
+
|
|
499
|
+
// write name & alignment flag
|
|
500
|
+
m_out << a.Name << "\t" << a.AlignmentFlag << "\t";
|
|
501
|
+
|
|
502
|
+
// write reference name
|
|
503
|
+
if ( (a.RefID >= 0) && (a.RefID < (int)m_references.size()) )
|
|
504
|
+
m_out << m_references[a.RefID].RefName << "\t";
|
|
505
|
+
else
|
|
506
|
+
m_out << "*\t";
|
|
507
|
+
|
|
508
|
+
// write position & map quality
|
|
509
|
+
m_out << a.Position+1 << "\t" << a.MapQuality << "\t";
|
|
510
|
+
|
|
511
|
+
// write CIGAR
|
|
512
|
+
const vector<CigarOp>& cigarData = a.CigarData;
|
|
513
|
+
if ( cigarData.empty() ) m_out << "*\t";
|
|
514
|
+
else {
|
|
515
|
+
vector<CigarOp>::const_iterator cigarIter = cigarData.begin();
|
|
516
|
+
vector<CigarOp>::const_iterator cigarEnd = cigarData.end();
|
|
517
|
+
for ( ; cigarIter != cigarEnd; ++cigarIter ) {
|
|
518
|
+
const CigarOp& op = (*cigarIter);
|
|
519
|
+
m_out << op.Length << op.Type;
|
|
520
|
+
}
|
|
521
|
+
m_out << "\t";
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// write mate reference name, mate position, & insert size
|
|
525
|
+
if ( a.IsPaired() && (a.MateRefID >= 0) && (a.MateRefID < (int)m_references.size()) ) {
|
|
526
|
+
if ( a.MateRefID == a.RefID )
|
|
527
|
+
m_out << "=\t";
|
|
528
|
+
else
|
|
529
|
+
m_out << m_references[a.MateRefID].RefName << "\t";
|
|
530
|
+
m_out << a.MatePosition+1 << "\t" << a.InsertSize << "\t";
|
|
531
|
+
}
|
|
532
|
+
else
|
|
533
|
+
m_out << "*\t0\t0\t";
|
|
534
|
+
|
|
535
|
+
// write sequence
|
|
536
|
+
if ( a.QueryBases.empty() )
|
|
537
|
+
m_out << "*\t";
|
|
538
|
+
else
|
|
539
|
+
m_out << a.QueryBases << "\t";
|
|
540
|
+
|
|
541
|
+
// write qualities
|
|
542
|
+
if ( a.Qualities.empty() )
|
|
543
|
+
m_out << "*";
|
|
544
|
+
else
|
|
545
|
+
m_out << a.Qualities;
|
|
546
|
+
|
|
547
|
+
// write tag data
|
|
548
|
+
const char* tagData = a.TagData.c_str();
|
|
549
|
+
const size_t tagDataLength = a.TagData.length();
|
|
550
|
+
|
|
551
|
+
size_t index = 0;
|
|
552
|
+
while ( index < tagDataLength ) {
|
|
553
|
+
|
|
554
|
+
// write tag name
|
|
555
|
+
string tagName = a.TagData.substr(index, 2);
|
|
556
|
+
m_out << "\t" << tagName << ":";
|
|
557
|
+
index += 2;
|
|
558
|
+
|
|
559
|
+
// get data type
|
|
560
|
+
char type = a.TagData.at(index);
|
|
561
|
+
++index;
|
|
562
|
+
switch ( type ) {
|
|
563
|
+
case (Constants::BAM_TAG_TYPE_ASCII) :
|
|
564
|
+
m_out << "A:" << tagData[index];
|
|
565
|
+
++index;
|
|
566
|
+
break;
|
|
567
|
+
|
|
568
|
+
case (Constants::BAM_TAG_TYPE_INT8) :
|
|
569
|
+
case (Constants::BAM_TAG_TYPE_UINT8) :
|
|
570
|
+
m_out << "i:" << (int)tagData[index];
|
|
571
|
+
++index;
|
|
572
|
+
break;
|
|
573
|
+
|
|
574
|
+
case (Constants::BAM_TAG_TYPE_INT16) :
|
|
575
|
+
m_out << "i:" << BamTools::UnpackSignedShort(&tagData[index]);
|
|
576
|
+
index += sizeof(int16_t);
|
|
577
|
+
break;
|
|
578
|
+
|
|
579
|
+
case (Constants::BAM_TAG_TYPE_UINT16) :
|
|
580
|
+
m_out << "i:" << BamTools::UnpackUnsignedShort(&tagData[index]);
|
|
581
|
+
index += sizeof(uint16_t);
|
|
582
|
+
break;
|
|
583
|
+
|
|
584
|
+
case (Constants::BAM_TAG_TYPE_INT32) :
|
|
585
|
+
m_out << "i:" << BamTools::UnpackSignedInt(&tagData[index]);
|
|
586
|
+
index += sizeof(int32_t);
|
|
587
|
+
break;
|
|
588
|
+
|
|
589
|
+
case (Constants::BAM_TAG_TYPE_UINT32) :
|
|
590
|
+
m_out << "i:" << BamTools::UnpackUnsignedInt(&tagData[index]);
|
|
591
|
+
index += sizeof(uint32_t);
|
|
592
|
+
break;
|
|
593
|
+
|
|
594
|
+
case (Constants::BAM_TAG_TYPE_FLOAT) :
|
|
595
|
+
m_out << "f:" << BamTools::UnpackFloat(&tagData[index]);
|
|
596
|
+
index += sizeof(float);
|
|
597
|
+
break;
|
|
598
|
+
|
|
599
|
+
case (Constants::BAM_TAG_TYPE_HEX) :
|
|
600
|
+
case (Constants::BAM_TAG_TYPE_STRING) :
|
|
601
|
+
m_out << type << ":";
|
|
602
|
+
while (tagData[index]) {
|
|
603
|
+
m_out << tagData[index];
|
|
604
|
+
++index;
|
|
605
|
+
}
|
|
606
|
+
++index;
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if ( tagData[index] == '\0')
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
m_out << endl;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// Print BamAlignment in YAML format
|
|
618
|
+
void ConvertTool::ConvertToolPrivate::PrintYaml(const BamAlignment& a) {
|
|
619
|
+
|
|
620
|
+
// write alignment name
|
|
621
|
+
m_out << "---" << endl;
|
|
622
|
+
m_out << a.Name << ":" << endl;
|
|
623
|
+
|
|
624
|
+
// write alignment data
|
|
625
|
+
m_out << " " << "AlndBases: " << a.AlignedBases << endl;
|
|
626
|
+
m_out << " " << "Qualities: " << a.Qualities << endl;
|
|
627
|
+
m_out << " " << "Name: " << a.Name << endl;
|
|
628
|
+
m_out << " " << "Length: " << a.Length << endl;
|
|
629
|
+
m_out << " " << "TagData: " << a.TagData << endl;
|
|
630
|
+
m_out << " " << "RefID: " << a.RefID << endl;
|
|
631
|
+
m_out << " " << "RefName: " << m_references[a.RefID].RefName << endl;
|
|
632
|
+
m_out << " " << "Position: " << a.Position << endl;
|
|
633
|
+
m_out << " " << "Bin: " << a.Bin << endl;
|
|
634
|
+
m_out << " " << "MapQuality: " << a.MapQuality << endl;
|
|
635
|
+
m_out << " " << "AlignmentFlag: " << a.AlignmentFlag << endl;
|
|
636
|
+
m_out << " " << "MateRefID: " << a.MateRefID << endl;
|
|
637
|
+
m_out << " " << "MatePosition: " << a.MatePosition << endl;
|
|
638
|
+
m_out << " " << "InsertSize: " << a.InsertSize << endl;
|
|
639
|
+
m_out << " " << "Filename: " << a.Filename << endl;
|
|
640
|
+
|
|
641
|
+
// write Cigar data
|
|
642
|
+
const vector<CigarOp>& cigarData = a.CigarData;
|
|
643
|
+
if ( !cigarData.empty() ) {
|
|
644
|
+
m_out << " " << "Cigar: ";
|
|
645
|
+
vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
|
|
646
|
+
vector<CigarOp>::const_iterator cigarIter = cigarBegin;
|
|
647
|
+
vector<CigarOp>::const_iterator cigarEnd = cigarData.end();
|
|
648
|
+
for ( ; cigarIter != cigarEnd; ++cigarIter ) {
|
|
649
|
+
const CigarOp& op = (*cigarIter);
|
|
650
|
+
m_out << op.Length << op.Type;
|
|
651
|
+
}
|
|
652
|
+
m_out << endl;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
bool ConvertTool::ConvertToolPrivate::RunPileupConversion(BamMultiReader* reader) {
|
|
657
|
+
|
|
658
|
+
// check for valid BamMultiReader
|
|
659
|
+
if ( reader == 0 ) return false;
|
|
660
|
+
|
|
661
|
+
// set up our pileup format 'visitor'
|
|
662
|
+
ConvertPileupFormatVisitor* v = new ConvertPileupFormatVisitor(m_references,
|
|
663
|
+
m_settings->FastaFilename,
|
|
664
|
+
m_settings->IsPrintingPileupMapQualities,
|
|
665
|
+
&m_out);
|
|
666
|
+
|
|
667
|
+
// set up PileupEngine
|
|
668
|
+
PileupEngine pileup;
|
|
669
|
+
pileup.AddVisitor(v);
|
|
670
|
+
|
|
671
|
+
// iterate through data
|
|
672
|
+
BamAlignment al;
|
|
673
|
+
while ( reader->GetNextAlignment(al) )
|
|
674
|
+
pileup.AddAlignment(al);
|
|
675
|
+
pileup.Flush();
|
|
676
|
+
|
|
677
|
+
// clean up
|
|
678
|
+
delete v;
|
|
679
|
+
v = 0;
|
|
680
|
+
|
|
681
|
+
// return success
|
|
682
|
+
return true;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// ---------------------------------------------
|
|
686
|
+
// ConvertTool implementation
|
|
687
|
+
|
|
688
|
+
ConvertTool::ConvertTool(void)
|
|
689
|
+
: AbstractTool()
|
|
690
|
+
, m_settings(new ConvertSettings)
|
|
691
|
+
, m_impl(0)
|
|
692
|
+
{
|
|
693
|
+
// set program details
|
|
694
|
+
Options::SetProgramInfo("bamtools convert", "converts BAM to a number of other formats", "-format <FORMAT> [-in <filename> -in <filename> ...] [-out <filename>] [-region <REGION>] [format-specific options]");
|
|
695
|
+
|
|
696
|
+
// set up options
|
|
697
|
+
OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
|
|
698
|
+
Options::AddValueOption("-in", "BAM filename", "the input BAM file(s)", "", m_settings->HasInput, m_settings->InputFiles, IO_Opts, Options::StandardIn());
|
|
699
|
+
Options::AddValueOption("-out", "BAM filename", "the output BAM file", "", m_settings->HasOutput, m_settings->OutputFilename, IO_Opts, Options::StandardOut());
|
|
700
|
+
Options::AddValueOption("-format", "FORMAT", "the output file format - see README for recognized formats", "", m_settings->HasFormat, m_settings->Format, IO_Opts);
|
|
701
|
+
Options::AddValueOption("-region", "REGION", "genomic region. Index file is recommended for better performance, and is used automatically if it exists. See \'bamtools help index\' for more details on creating one", "", m_settings->HasRegion, m_settings->Region, IO_Opts);
|
|
702
|
+
|
|
703
|
+
OptionGroup* PileupOpts = Options::CreateOptionGroup("Pileup Options");
|
|
704
|
+
Options::AddValueOption("-fasta", "FASTA filename", "FASTA reference file", "", m_settings->HasFastaFilename, m_settings->FastaFilename, PileupOpts);
|
|
705
|
+
Options::AddOption("-mapqual", "print the mapping qualities", m_settings->IsPrintingPileupMapQualities, PileupOpts);
|
|
706
|
+
|
|
707
|
+
OptionGroup* SamOpts = Options::CreateOptionGroup("SAM Options");
|
|
708
|
+
Options::AddOption("-noheader", "omit the SAM header from output", m_settings->IsOmittingSamHeader, SamOpts);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
ConvertTool::~ConvertTool(void) {
|
|
712
|
+
|
|
713
|
+
delete m_settings;
|
|
714
|
+
m_settings = 0;
|
|
715
|
+
|
|
716
|
+
delete m_impl;
|
|
717
|
+
m_impl = 0;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
int ConvertTool::Help(void) {
|
|
721
|
+
Options::DisplayHelp();
|
|
722
|
+
return 0;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
int ConvertTool::Run(int argc, char* argv[]) {
|
|
726
|
+
|
|
727
|
+
// parse command line arguments
|
|
728
|
+
Options::Parse(argc, argv, 1);
|
|
729
|
+
|
|
730
|
+
// initialize ConvertTool with settings
|
|
731
|
+
m_impl = new ConvertToolPrivate(m_settings);
|
|
732
|
+
|
|
733
|
+
// run ConvertTool, return success/fail
|
|
734
|
+
if ( m_impl->Run() )
|
|
735
|
+
return 0;
|
|
736
|
+
else
|
|
737
|
+
return 1;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// ---------------------------------------------
|
|
741
|
+
// ConvertPileupFormatVisitor implementation
|
|
742
|
+
|
|
743
|
+
ConvertPileupFormatVisitor::ConvertPileupFormatVisitor(const RefVector& references,
|
|
744
|
+
const string& fastaFilename,
|
|
745
|
+
const bool isPrintingMapQualities,
|
|
746
|
+
ostream* out)
|
|
747
|
+
: PileupVisitor()
|
|
748
|
+
, m_hasFasta(false)
|
|
749
|
+
, m_isPrintingMapQualities(isPrintingMapQualities)
|
|
750
|
+
, m_out(out)
|
|
751
|
+
, m_references(references)
|
|
752
|
+
{
|
|
753
|
+
// set up Fasta reader if file is provided
|
|
754
|
+
if ( !fastaFilename.empty() ) {
|
|
755
|
+
|
|
756
|
+
// check for FASTA index
|
|
757
|
+
string indexFilename = "";
|
|
758
|
+
if ( Utilities::FileExists(fastaFilename + ".fai") )
|
|
759
|
+
indexFilename = fastaFilename + ".fai";
|
|
760
|
+
|
|
761
|
+
// open FASTA file
|
|
762
|
+
if ( m_fasta.Open(fastaFilename, indexFilename) )
|
|
763
|
+
m_hasFasta = true;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
ConvertPileupFormatVisitor::~ConvertPileupFormatVisitor(void) {
|
|
768
|
+
// be sure to close Fasta reader
|
|
769
|
+
if ( m_hasFasta ) {
|
|
770
|
+
m_fasta.Close();
|
|
771
|
+
m_hasFasta = false;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
void ConvertPileupFormatVisitor::Visit(const PileupPosition& pileupData ) {
|
|
776
|
+
|
|
777
|
+
// skip if no alignments at this position
|
|
778
|
+
if ( pileupData.PileupAlignments.empty() ) return;
|
|
779
|
+
|
|
780
|
+
// retrieve reference name
|
|
781
|
+
const string& referenceName = m_references[pileupData.RefId].RefName;
|
|
782
|
+
const int& position = pileupData.Position;
|
|
783
|
+
|
|
784
|
+
// retrieve reference base from FASTA file, if one provided; otherwise default to 'N'
|
|
785
|
+
char referenceBase('N');
|
|
786
|
+
if ( m_hasFasta && (pileupData.Position < m_references[pileupData.RefId].RefLength) ) {
|
|
787
|
+
if ( !m_fasta.GetBase(pileupData.RefId, pileupData.Position, referenceBase ) ) {
|
|
788
|
+
cerr << "bamtools convert ERROR: pileup conversion - could not read reference base from FASTA file" << endl;
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// get count of alleles at this position
|
|
794
|
+
const int numberAlleles = pileupData.PileupAlignments.size();
|
|
795
|
+
|
|
796
|
+
// -----------------------------------------------------------
|
|
797
|
+
// build strings based on alleles at this positionInAlignment
|
|
798
|
+
|
|
799
|
+
stringstream bases("");
|
|
800
|
+
stringstream baseQualities("");
|
|
801
|
+
stringstream mapQualities("");
|
|
802
|
+
|
|
803
|
+
// iterate over alignments at this pileup position
|
|
804
|
+
vector<PileupAlignment>::const_iterator pileupIter = pileupData.PileupAlignments.begin();
|
|
805
|
+
vector<PileupAlignment>::const_iterator pileupEnd = pileupData.PileupAlignments.end();
|
|
806
|
+
for ( ; pileupIter != pileupEnd; ++pileupIter ) {
|
|
807
|
+
const PileupAlignment pa = (*pileupIter);
|
|
808
|
+
const BamAlignment& ba = pa.Alignment;
|
|
809
|
+
|
|
810
|
+
// if beginning of read segment
|
|
811
|
+
if ( pa.IsSegmentBegin )
|
|
812
|
+
bases << '^' << ( ((int)ba.MapQuality > 93) ? (char)126 : (char)((int)ba.MapQuality+33) );
|
|
813
|
+
|
|
814
|
+
// if current base is not a DELETION
|
|
815
|
+
if ( !pa.IsCurrentDeletion ) {
|
|
816
|
+
|
|
817
|
+
// get base at current position
|
|
818
|
+
char base = ba.QueryBases.at(pa.PositionInAlignment);
|
|
819
|
+
|
|
820
|
+
// if base matches reference
|
|
821
|
+
if ( base == '=' ||
|
|
822
|
+
toupper(base) == toupper(referenceBase) ||
|
|
823
|
+
tolower(base) == tolower(referenceBase) )
|
|
824
|
+
{
|
|
825
|
+
base = ( ba.IsReverseStrand() ? ',' : '.' );
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// mismatches reference
|
|
829
|
+
else base = ( ba.IsReverseStrand() ? tolower(base) : toupper(base) );
|
|
830
|
+
|
|
831
|
+
// store base
|
|
832
|
+
bases << base;
|
|
833
|
+
|
|
834
|
+
// if next position contains insertion
|
|
835
|
+
if ( pa.IsNextInsertion ) {
|
|
836
|
+
bases << '+' << pa.InsertionLength;
|
|
837
|
+
for (int i = 1; i <= pa.InsertionLength; ++i) {
|
|
838
|
+
char insertedBase = (char)ba.QueryBases.at(pa.PositionInAlignment + i);
|
|
839
|
+
bases << (ba.IsReverseStrand() ? (char)tolower(insertedBase) : (char)toupper(insertedBase) );
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// if next position contains DELETION
|
|
844
|
+
else if ( pa.IsNextDeletion ) {
|
|
845
|
+
bases << '-' << pa.DeletionLength;
|
|
846
|
+
for (int i = 1; i <= pa.DeletionLength; ++i) {
|
|
847
|
+
char deletedBase('N');
|
|
848
|
+
if ( m_hasFasta && (pileupData.Position+i < m_references[pileupData.RefId].RefLength) ) {
|
|
849
|
+
if ( !m_fasta.GetBase(pileupData.RefId, pileupData.Position+i, deletedBase ) ) {
|
|
850
|
+
cerr << "bamtools convert ERROR: pileup conversion - could not read reference base from FASTA file" << endl;
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
bases << (ba.IsReverseStrand() ? (char)tolower(deletedBase) : (char)toupper(deletedBase) );
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// otherwise, DELETION
|
|
860
|
+
else bases << '*';
|
|
861
|
+
|
|
862
|
+
// if end of read segment
|
|
863
|
+
if ( pa.IsSegmentEnd )
|
|
864
|
+
bases << '$';
|
|
865
|
+
|
|
866
|
+
// store current base quality
|
|
867
|
+
baseQualities << ba.Qualities.at(pa.PositionInAlignment);
|
|
868
|
+
|
|
869
|
+
// save alignment map quality if desired
|
|
870
|
+
if ( m_isPrintingMapQualities )
|
|
871
|
+
mapQualities << ( ((int)ba.MapQuality > 93) ? (char)126 : (char)((int)ba.MapQuality+33) );
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// ----------------------
|
|
875
|
+
// print results
|
|
876
|
+
|
|
877
|
+
// tab-delimited
|
|
878
|
+
// <refName> <1-based pos> <refBase> <numberAlleles> <bases> <qualities> [mapQuals]
|
|
879
|
+
|
|
880
|
+
const string TAB = "\t";
|
|
881
|
+
*m_out << referenceName << TAB
|
|
882
|
+
<< position + 1 << TAB
|
|
883
|
+
<< referenceBase << TAB
|
|
884
|
+
<< numberAlleles << TAB
|
|
885
|
+
<< bases.str() << TAB
|
|
886
|
+
<< baseQualities.str() << TAB
|
|
887
|
+
<< mapQualities.str() << endl;
|
|
888
|
+
}
|