/*
     Description: 保存bqsr计算的各种数据，根据这些数据生成bqsr table

     Copyright : All right reserved by ICT

     Author : Zhang Zhonghai
     Date : 2025/12/24
*/
#pragma once

#include "covariate.h"
#include "nested_array.h"
#include "recal_datum.h"

struct RecalTables {
    int qualDimension = 94;  // MAX_SAM_QUAL_SCORE(93) + 1
    int eventDimension = EventType::EVENT_SIZE;
    int numReadGroups;

    // These two tables are special
    Array2D<RecalDatum> readGroupTable;
    Array3D<RecalDatum> qualityScoreTable;

    // additional tables
    Array4D<RecalDatum> contextTable;
    Array4D<RecalDatum> cycleTable;

    // NestedArray<int> testArr;

    RecalTables() {}

    RecalTables(int _numReadGroups) { init(_numReadGroups); }

    void init(int _numReadGroups) {
        numReadGroups = _numReadGroups;
        // 初始化readgroup和quality两个table
        readGroupTable.init(numReadGroups, eventDimension);
        qualityScoreTable.init(numReadGroups, qualDimension, eventDimension);

        // 初始化context和cycle两个table
        contextTable.init(numReadGroups, qualDimension, ContextCovariate::MaximumKeyValue() + 1, eventDimension);
        cycleTable.init(numReadGroups, qualDimension, CycleCovariate::MaximumKeyValue() + 1, eventDimension);
    }
};