Skip to content

Commit

Permalink
Fix issue arq5x#803 and add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
38 committed Dec 12, 2019
1 parent 77f2374 commit 940ee18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/BamTools/include/SamHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
{
Expand Down
12 changes: 12 additions & 0 deletions test/intersect/new_test-intersect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 940ee18

Please sign in to comment.