Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #788 and add test cases #789

Merged
merged 1 commit into from
Nov 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/utils/BamTools/include/BamAlignment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ namespace BamTools {
bool SyncExtraData() const
{
#define BAM_DATA_OFFSET(what) ((size_t)(((uint8_t*)bam_get_##what(&_bam)) - ((uint8_t*)_bam.data)))
void* qname_buf = _ensure_data_chunk((bam1_t*)&_bam, BAM_DATA_OFFSET(qname), _bam.core.l_qname, Name.size());
void* qname_buf = _ensure_data_chunk((bam1_t*)&_bam, BAM_DATA_OFFSET(qname), _bam.core.l_qname, Name.size() + 1);
if(NULL == qname_buf) return false;
memcpy(qname_buf, Name.c_str(), Name.size());
((bam1_t*)&_bam)->core.l_qname = Name.size();
memcpy(qname_buf, Name.c_str(), Name.size() + 1);
((bam1_t*)&_bam)->core.l_qname = Name.size() + 1;

uint32_t* cigar_buf = (uint32_t*)_ensure_data_chunk((bam1_t*)&_bam, BAM_DATA_OFFSET(cigar), _bam.core.n_cigar * sizeof(uint32_t), sizeof(uint32_t) * CigarData.size());
if(NULL == cigar_buf) return false;
Expand Down
1 change: 1 addition & 0 deletions test/bedtobam/chrsize.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 3000
26 changes: 26 additions & 0 deletions test/bedtobam/test-bedtobam.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set -e;
BT=${BT-../../bin/bedtools}

FAILURES=0;

check()
{
if diff $1 $2; then
echo ok
else
FAILURES=$(expr $FAILURES + 1);
echo fail
fi
}

##################################################################
# Test one block without -split
##################################################################
echo -e " bedtobam.t1...\c"
echo \
"read_name 0 1 1001 255 1000M * 0 0 * *">exp
echo -e "1\t1000\t2000\tread_name\t255\t+" | $BT bedtobam -i - -g chrsize.tmp| samtools view > obs
check obs exp
rm obs exp

[[ $FAILURES -eq 0 ]] || exit 1;