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: 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;