Skip to content

Commit

Permalink
[FIX] Truncate read ids that are longer than 255 chars when writing BAM.
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Jul 1, 2019
1 parent dd81d0a commit 35c5d44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/seqan3/io/alignment_file/format_bam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ class alignment_file_output_format<format_bam> : alignment_file_output_format<fo
/* block_size */ 0, // will be initialised right after
/* refID */ -1, // will be initialised right after
/* pos */ ref_offset.value_or(-1),
/* l_read_name */ std::max<uint8_t>(std::ranges::distance(id) + 1, 2) /* empty id is repr. by '*\0' */,
/* l_read_name */ std::max<uint8_t>(std::min<size_t>(std::ranges::distance(id) + 1, 255), 2),
/* mapq */ mapq,
/* bin */ reg2bin(ref_offset.value_or(-1), std::ranges::distance(get<1>(align))),
/* n_cigar_op */ static_cast<uint16_t>(cigar.size()),
Expand Down Expand Up @@ -916,7 +916,7 @@ class alignment_file_output_format<format_bam> : alignment_file_output_format<fo
if (std::ranges::distance(id) == 0) // empty id is represented as * for backward compatibility
stream_it = '*';
else
std::ranges::copy_n(std::ranges::begin(id), std::ranges::distance(id), stream_it); // write read id
std::ranges::copy_n(std::ranges::begin(id), core.l_read_name - 1, stream_it); // write read id
stream_it = '\0';

// write cigar
Expand Down

0 comments on commit 35c5d44

Please sign in to comment.