Skip to content

Commit

Permalink
methCall: update the parsing of cigar string
Browse files Browse the repository at this point in the history
- replace calls to deprecated sprintf with snprintf

Signed-off-by: Alexander Blume <[email protected]>
  • Loading branch information
alexg9010 committed Apr 26, 2023
1 parent 5f1c758 commit 4231e7d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/methCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,21 +900,15 @@ int process_bam ( std::string &input,
// initialize buffers for sequence, qual and cigar string
std::string seq, qual;
std::vector<char> cigar_buffer(len_cigar + 1);

// initialize counter and cigar-buffer-storage
int i = 0;
int c;

// initialize counter
int i = 0;

// parse the first cigar operation
c = std::sprintf(cigar_buffer,"%i%c", bam_cigar_oplen(cigar_pointer[0]), bam_cigar_opchr(cigar_pointer[0])) ;
// if further operations remain, append them to cigar_buffer
if (len_cigar >= 2 ) {
for (i = 1; ((unsigned) i) < len_cigar; i++ ) {
char buffer [c];
c = std::sprintf(buffer,"%i%c", bam_cigar_oplen(cigar_pointer[i]), bam_cigar_opchr(cigar_pointer[i])) ;
strcat(cigar_buffer,buffer);
}
// parse the cigar operations
for (i = 0; i < len_cigar; i++)
{
// place each operation as character into cigar_buffer
std::snprintf(&cigar_buffer[i], cigar_buffer.size(), "%i%c", bam_cigar_oplen(cigar_pointer[i]), bam_cigar_opchr(cigar_pointer[i]));
}

for (i = 0; i < len; i++ ) { qual += bam_get_qual(b)[i]+offset;}
Expand Down

0 comments on commit 4231e7d

Please sign in to comment.