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 addRefPad(bcf_hdr_t* hdr, bcf1_t* rec, common::FastaFile const& ref, int npad)
{
    if (npad <= 0)
    {
        error_stop("npad<=0", 0, "npad<=0");
    }
    int64_t start, end;
    getLocation(hdr, rec, start, end);
    std::string pad = ref.query(bcf_hdr_int2id(hdr, BCF_DT_CTG, rec->rid), start - npad, start - 1);
    rec->pos -= npad;
    std::string new_alleles = "";
    for (int i = 0; i < rec->n_allele; i++)
    {
        if (rec->d.allele[i][0] != '<')
        {
            if (i == 0)
            {
                new_alleles += pad;
                new_alleles += (std::string)rec->d.allele[i];
            }
            else
            {
                new_alleles += ",";
                new_alleles += pad;
                new_alleles += (std::string)rec->d.allele[i];
            }
        }
    }
    bcf_update_alleles_str(hdr, rec, new_alleles.c_str());
    return (npad);
}
int addRefPad ( bcf_hdr_t * hdr , bcf1_t * rec , common :: FastaFile const & ref , int npad ) { if ( npad <= 0 ) { error_stop ( " " , 0 , " " ) ; } int64_t start , end ; getLocation ( hdr , rec , start , end ) ; std :: string pad = ref . query ( bcf_hdr_int2id ( hdr , BCF_DT_CTG , rec -> rid ) , start - npad , start - 1 ) ; rec -> pos -= npad ; std :: string new_alleles = " " ; for ( int i = 0 ; i < rec -> n_allele ; i ++ ) { if ( rec -> d . allele [ i ] [ 0 ] != ' ' ) { if ( i == 0 ) { new_alleles += pad ; new_alleles += ( std :: string ) rec -> d . allele [ i ] ; } else { new_alleles += " " ; new_alleles += pad ; new_alleles += ( std :: string ) rec -> d . allele [ i ] ; } } } bcf_update_alleles_str ( hdr , rec , new_alleles . c_str ( ) ) ; return ( npad ) ; }
return number of reference padding bases
return number of reference padding bases