#include "baq.h"

#include <spdlog/spdlog.h>

vector<double> BAQ::qual2prob(256); // 质量分数转化概率
vector<vector<vector<double>>> BAQ::EPSILONS(256, vector<vector<double>>(256, vector<double>(SAM_MAX_PHRED_SCORE + 1)));  // [ref][read][qual]

// 计算baq数组，返回成功与否
bool BAQ::calcBAQFromHMM(SamData& ad, string ref, int refOffset, vector<int>& baqArray) {
    // 检测ref是否覆盖了read
    if (ref.size() < refOffset + ad.read_len) {
        spdlog::error("BAQ calculation error: reference sequence length {} is less than required length {} (refOffset {} + read_len {})",
                      ref.size(), refOffset + ad.read_len, refOffset,  ad.read_len);
        return false;
    }
    return true;
}