src/c++/lib/common/Alignment.cpp
/**
 * \param  matches will be incremented by the number of matches found
 * \return CIGAR with mismatches clipped on left if first is set
 *         or on right if last is set. If the entire sequence is
 *         clipped, an empty CIGAR is returned
 */
\param  matches will be incremented by the number of matches found
\return CIGAR with mismatches clipped on left if first is set
or on right if last is set. If the entire sequence is
clipped, an empty CIGAR is returned
\ param matches will be incremented by the number of matches found \ return CIGAR with mismatches clipped on left if first is set or on right if last is set . If the entire sequence is clipped an empty CIGAR is returned
std::string
makeCigarBit(std::string::const_iterator itRef, std::string::const_iterator& itSeq, std::size_t length, int& matches)
{
    std::string ret;
    char lastOp = 0;
    std::size_t lastOpLen = 0;
    for (; length; ++itSeq, ++itRef, --length, ++lastOpLen)
    {
        const char op = getCigarOp(*itRef, *itSeq);
        if (op != lastOp)
        {
            if (lastOpLen)
            {
                ret += std::to_string(lastOpLen) + lastOp;
                if ('M' == lastOp)
                {
                    matches += lastOpLen;
                }
            }
            lastOp = op;
            lastOpLen = 0;
        }
    }
    if (lastOpLen)
    {
        ret += std::to_string(lastOpLen) + lastOp;
        if ('M' == lastOp)
        {
            matches += lastOpLen;
        }
    }
    return ret;
}
std :: string makeCigarBit ( std :: string :: const_iterator itRef , std :: string :: const_iterator & itSeq , std :: size_t length , int & matches ) { std :: string ret ; char lastOp = 0 ; std :: size_t lastOpLen = 0 ; for ( ; length ; ++ itSeq , ++ itRef , -- length , ++ lastOpLen ) { const char op = getCigarOp ( * itRef , * itSeq ) ; if ( op != lastOp ) { if ( lastOpLen ) { ret += std :: to_string ( lastOpLen ) + lastOp ; if ( ' ' == lastOp ) { matches += lastOpLen ; } } lastOp = op ; lastOpLen = 0 ; } } if ( lastOpLen ) { ret += std :: to_string ( lastOpLen ) + lastOp ; if ( ' ' == lastOp ) { matches += lastOpLen ; } } return ret ; }
\param  matches will be incremented by the number of matches found
 \return CIGAR with mismatches clipped on left if first is set
         or on right if last is set.
\ param matches will be incremented by the number of matches found \ return CIGAR with mismatches clipped on left if first is set or on right if last is set .