src/c++/lib/common/BCFHelpers.cpp
/** return number of reference padding bases */
return number of reference padding bases
return number of reference padding bases
int isRefPadded(bcf1_t* line)
{
    bcf_unpack(line, BCF_UN_SHR);
    if (line->n_allele == 1)
    {
        return 0;
    }
    const char* ref = line->d.allele[0];
    const int reflen = (int)strlen(ref);
    int max_match = reflen;
    for (int al = 1; al < line->n_allele; ++al)
    {
        const char* alt = line->d.allele[al];
        if (strcmp(alt, ".") == 0 || *alt == '<')
        {
            max_match = 0;
            break;
        }
        int rpos = 0;
        for (rpos = 0; rpos < reflen; ++rpos, ++alt)
        {
            const char rb = *(ref + rpos);
            if (*alt == 0 || *alt != rb)
            {
                break;
            }
        }
        max_match = std::min(rpos, max_match);
    }
    return max_match;
}
int isRefPadded ( bcf1_t * line ) { bcf_unpack ( line , BCF_UN_SHR ) ; if ( line -> n_allele == 1 ) { return 0 ; } const char * ref = line -> d . allele [ 0 ] ; const int reflen = ( int ) strlen ( ref ) ; int max_match = reflen ; for ( int al = 1 ; al < line -> n_allele ; ++ al ) { const char * alt = line -> d . allele [ al ] ; if ( strcmp ( alt , " " ) == 0 || * alt == ' ' ) { max_match = 0 ; break ; } int rpos = 0 ; for ( rpos = 0 ; rpos < reflen ; ++ rpos , ++ alt ) { const char rb = * ( ref + rpos ) ; if ( * alt == 0 || * alt != rb ) { break ; } } max_match = std :: min ( rpos , max_match ) ; } return max_match ; }
return number of reference padding bases
return number of reference padding bases
// symbolic or missing ALT