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=
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; } } }