I got qlen = 276 using bam_cigar2qlen in htslib but I count that cigar by myself, it should be 263.
1
0
Entering edit mode
5 months ago
Aaron ▴ 10

the cigar string is as following: 1=1I4=1I7=1D5=1D4=1D2=1I9=1I13=1X7=1I13=1X1=1I11=1D3=1D1=1X2=1I10=1I2=1X1=1I11=1X3=1D9=2D2=1D26=1D5=1D6=1I17=1D3=1D4=1D3=1I1=1I1=1X3=1D10=1I10=1D2=1D10=1D22=

bam cigar htslib • 471 views
ADD COMMENT
0
Entering edit mode

my encoding logic is as following:

const static std::unordered_map<int, int> opMapping { {'M', 0}, {'I', 1}, {'D', 2}, {'N', 3}, {'S', 4}, {'H', 5}, {'P', 6}, {'=', 7}, {'X', 8} };

void encodeCigar(const string& cigarStr, AlignmentRecord::CigarVT& res) { //int32_t n_cigar = bam_str2cigar(cigar_str, &b->core.n_cigar, &b->data); auto optNum = 0; auto opt = 0; for (auto c : cigarStr) { if (isdigit(c)) { optNum += optNum * 10 + (c - '0'); } else { res.push_back(bam_cigar_gen(optNum, opMapping.at(c))); optNum = 0; } } }

ADD REPLY
1
Entering edit mode
5 months ago

Your conversion code does not produce the correct result when an operator length has more than one digit:

 optNum += optNum * 10 + (c - '0');

I would recommend you spend more time practising debugging. It is a useful skill.

ADD COMMENT
0
Entering edit mode

thanks very much.

ADD REPLY

Login before adding your answer.

Traffic: 2318 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6