// =============================================================== //
//                                                                 //
//   File      : AP_pos_var.h                                      //
//   Purpose   : provides PVP calculation                          //
//                                                                 //
//   Institute of Microbiology (Technical University Munich)       //
//   http://www.arb-home.de/                                       //
//                                                                 //
// =============================================================== //

#ifndef AP_POS_VAR_H
#define AP_POS_VAR_H

#ifndef ARBTOOLS_H
#include <arbtools.h>
#endif
#ifndef ARBDB_H
#include <arbdb.h>
#endif

class AW_window;
class AW_root;
class arb_progress;

class AP_pos_var : virtual Noncopyable {
    GBDATA *gb_main;

    long treeLeafs; // number of leafs in tree
    long treeNodes; // number of leafs + inner nodes in tree

    arb_progress *progress;

    GB_UINT4 *frequencies[256]; // count every occurrence
    GB_UINT4 *transitions;      // minimum transitions
    GB_UINT4 *transversions;    // minimum transversions (dna only)

    unsigned char char_2_freq[256]; // mapper (~ toupper)

    long char_2_transition[256];   // a->1 c->2 g->4 ...
    long char_2_transversion[256]; // y->1 r->2

    long  ali_len;       // max len of alignment
    char *ali_name;
    char *tree_name;
    bool  is_nuc;

    const char *parsimony(TreeNode *tree, GB_UINT4 *bases = NULp, GB_UINT4 *ltbases = NULp);

public:

    AP_pos_var(GBDATA *gb_main_, const char *ali_name_, long ali_len_, bool is_nuc_, const char *tree_name_);
    ~AP_pos_var();

    GB_ERROR retrieve(TreeNode *tree);
    GB_ERROR delete_aliEntry_from_SAI(const char *sai_name);
    GB_ERROR save_aliEntry_to_SAI(const char *sai_name);
};

#else
#error AP_pos_var.h included twice
#endif // AP_POS_VAR_H
