File: parstree.h

package info (click to toggle)
iqtree 1.6.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,140 kB
  • sloc: cpp: 111,752; ansic: 53,619; python: 242; sh: 195; makefile: 52
file content (138 lines) | stat: -rw-r--r-- 3,816 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * parstree.h
 *
 *  Created on: Nov 6, 2014
 *      Author: diep
 */

#ifndef PARSTREE_H_
#define PARSTREE_H_

#include "iqtree.h"

#define BootValTypePars unsigned short // Diep added

enum CostMatrixType {CM_UNIFORM, CM_LINEAR};

class ParsTree: public IQTree {
public:
    /**************************************************************************
     * Methods
     *************************************************************************/
    /**
     * default constructor
     */
    ParsTree();

    /**
     * Constructor with given alignment
     * @param alignment
     */
    ParsTree(Alignment *alignment);


    /**
     * destructor
     */
    ~ParsTree();

    /**
     * read the cost matrix file
     * initialize for 'nstates' and 'columns'
     */
    void loadCostMatrixFile(char* file_name = NULL);

    /**
     * initialise cost_matrix as linear
     * initialize for 'nstates' and 'columns'
     */
    void initCostMatrix(CostMatrixType cost_type);

//    /**
//     * allocate for ptn_pars if needed
//     */
//    void allocatePtnPars(int nptn);

    /**
        compute the tree parsimony score
        @return parsimony score of the tree
    */
    int computeParsimony();

    /**
        compute partial parsimony score of the subtree rooted at dad
        @param dad_branch the branch leading to the subtree
        @param dad its dad, used to direct the traversal
    */
    void computePartialParsimony(PhyloNeighbor *dad_branch, PhyloNode *dad);


    /**
        compute tree parsimony score based on a particular branch
        @param dad_branch the branch leading to the subtree
        @param dad its dad, used to direct the traversal
        @param branch_subst (OUT) if not NULL, the number of substitutions on this branch
        @return parsimony score of the tree
    */
    int computeParsimonyBranch(PhyloNeighbor *dad_branch, PhyloNode *dad, int *branch_subst = NULL);

    /**
        initialize partial_pars vector of all PhyloNeighbors, allocating central_partial_pars
     */
    virtual void initializeAllPartialPars();

    /**
        initialize partial_pars vector of all PhyloNeighbors, allocating central_partial_pars
        @param node the current node
        @param dad dad of the node, used to direct the search
        @param index the index
     */
    virtual void initializeAllPartialPars(int &index, PhyloNode *node = NULL, PhyloNode *dad = NULL);

    /**
     * allocate memory enough for one partial_pars vector of one neighbor
     */
    virtual UINT* newPartialPars();

    /**
     * calculate the size of one partial_pars vector of one neighbor
     */
    size_t getParsBlockSize();

	/**
	 * to overwrite the one in PhyloTree
	 */
    virtual UINT * newBitsBlock();

    /*
     * For a leaf character corresponding to an ambiguous state
     * set elements corresponding to possible states to 0, others to UINT_MAX
     */
    void initLeafSiteParsForAmbiguousState(char state, UINT * site_partial_pars);

    /*
     * For the starting phase: phyloanalysis.cpp
     */
    virtual bool isParsimonyTree() {
        return true;
    }

    void initParsData(Params* pars_params);

	void printPatternScore();
	UINT findMstScore(int ptn); // find minimum spanning tree score of a given pattern

    /**************************************************************************
     * Data
     *************************************************************************/
//    SankoffCostMatrix* cost_matrix;
    unsigned int * cost_matrix; // Sep 2016: store cost matrix in 1D array
    int cost_nstates; // Sep 2016: # of states provided by cost matrix
    UINT tree_pars;
    /**
     * Store array of pattern parsimony computed in computeParsimonyBranch()
     */
    //BootValTypePars* _pattern_pars;
};

#endif /* PARSTREE_H_ */