static void apath_push(path_t& apath, path_segment& ps, const align_t t) { if ( (0==ps.length) || (ps.type==t) ) return; apath.push_back(ps); ps.clear(); }
void cigar_to_apath(const char* cigar, path_t& apath) { using illumina::blt_util::parse_unsigned; assert(NULL != cigar); apath.clear(); path_segment lps; const char* cptr(cigar); while (*cptr) { path_segment ps; // expect sequences of digits and cigar codes: if (! isdigit(*cptr)) unknown_cigar_error(cigar,cptr); ps.length = parse_unsigned(cptr); ps.type = cigar_code_to_segment_type(*cptr); if (ps.type == NONE) unknown_cigar_error(cigar,cptr); cptr++; if ((ps.type == PAD) || (ps.length == 0)) continue; if (ps.type != lps.type) { if (lps.type != NONE) apath.push_back(lps); lps = ps; } else { lps.length += ps.length; } } if (lps.type != NONE) apath.push_back(lps); }