From 940ee181e97e4d93d392b3c8b50f6baf840b8937 Mon Sep 17 00:00:00 2001 From: Hao Hou Date: Thu, 12 Dec 2019 11:38:08 -0700 Subject: [PATCH 1/2] Fix issue #803 and add test cases --- src/utils/BamTools/include/SamHeader.hpp | 5 +++-- test/intersect/new_test-intersect.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/utils/BamTools/include/SamHeader.hpp b/src/utils/BamTools/include/SamHeader.hpp index 3a8bd6e9e..a4bdd5ddd 100644 --- a/src/utils/BamTools/include/SamHeader.hpp +++ b/src/utils/BamTools/include/SamHeader.hpp @@ -33,7 +33,7 @@ namespace htslib_future { hts_close(fp); - hdr->l_text = buffer->length(); + hdr->l_text = (uint32_t)buffer->length(); hdr->text = strdup(buffer->c_str()); delete buffer; @@ -104,8 +104,9 @@ namespace BamTools { void ParseHeaderText(const std::string& text) { - _header = sam_hdr_parse(text.length(), text.c_str()); + _header = sam_hdr_parse((int)text.length(), text.c_str()); _header->text = strdup(text.c_str()); + _header->l_text = (uint32_t)text.length(); } void destory() { diff --git a/test/intersect/new_test-intersect.sh b/test/intersect/new_test-intersect.sh index 078b0f178..da9db4fa1 100755 --- a/test/intersect/new_test-intersect.sh +++ b/test/intersect/new_test-intersect.sh @@ -968,3 +968,15 @@ $BT intersect -iobuf 2G -ubam -S -u -sorted -b a.bam -a a.bed >obs check exp obs rm exp obs [[ $FAILURES -eq 0 ]] || exit 1; + + + +########################################################### +# Test intersect preserve the text header in bam +############################################################ +echo -e " intersect.new.t78...\c" +echo -e "@HD VN:1.5 SO:coordinate" > exp +echo "@HD VN:1.5 SO:coordinate" | samtools view -b | $BT intersect -a /dev/stdin -b b.bed | samtools view -H >obs +check exp obs +rm exp obs +[[ $FAILURES -eq 0 ]] || exit 1; From 47a35a1ed945de3db5fdb434f24600bc713ddc54 Mon Sep 17 00:00:00 2001 From: Hao Hou Date: Thu, 12 Dec 2019 11:46:52 -0700 Subject: [PATCH 2/2] Make sure we also check all the PRs --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43f5cac61..2e69c5e61 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: