Skip to content

Commit

Permalink
Merge pull request #804 from 38/master
Browse files Browse the repository at this point in the history
Fix issue #803 and add test cases
  • Loading branch information
arq5x authored Dec 13, 2019
2 parents 59bbfbd + 47a35a1 commit 063dd59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push]
on: [push, pull_request]

jobs:
build:
Expand Down
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 063dd59

Please sign in to comment.