File: pdtree.h

package info (click to toggle)
iqtree 1.5.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,780 kB
  • ctags: 11,529
  • sloc: cpp: 96,162; ansic: 59,874; python: 242; sh: 189; makefile: 45
file content (171 lines) | stat: -rw-r--r-- 5,648 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/***************************************************************************
 *   Copyright (C) 2006 by BUI Quang Minh, Steffen Klaere, Arndt von Haeseler   *
 *   minh.bui@univie.ac.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef PDTREE_H
#define PDTREE_H

#include "mtree.h"
#include "split.h"


/**
Specialized Tree for Phylogenetic Diversity Algorithms
@author BUI Quang Minh, Steffen Klaere, Arndt von Haeseler
*/
class PDTree: public MTree{
public:
	/**
		construct from program parameters
		@param params program parameters
	*/
    PDTree(Params &params);

	/**
		constructor, get from another tree
		@param tree another MTree
	*/
    PDTree(PDTree &tree);

	/**
		constructor
	*/
	PDTree() : MTree() {};


/********************************************************
	INITIALZATION
********************************************************/
	/**
		initialize the tree from program parameters
		@param params program parameters
	*/
	void init(Params &params);

	/**
		initialize tree, get from another tree
		@param tree another MTree
	*/
	void init(PDTree &tree);

	/**
		read the parameter from the file
		@param params program parameters
	*/
	void readParams(Params &params);

	/**
		Identify the root node if specified, include it into the initial set
		@param root_name name of the root node
	*/
	void readRootNode(const char *root_name);

	/**
		read the initial set of taxa to be included into PD-tree
		@param params program parameters
	*/
	void readInitialSet(Params &params);

	/**
		incoporate the parameters to the tree
		@param node the starting node, NULL to start from the root
		@param dad dad of the node, used to direct the search
		@param scale (OUT) branch scaling factor
		@param tax_weight (OUT) taxa weights
	*/
	void incoporateParams(double &scale, DoubleVector &tax_weight, Node *node = NULL, Node* dad = NULL);

	/**
		build a set of leaf name, return to lsn
		@param node the starting node, NULL to start from the root
		@param dad dad of the node, used to direct the search
		@param lsn (OUT) leaf set name
	*/
	void buildLeafMapName(LeafMapName &lsn, Node *node = NULL, Node* dad = NULL);

	int findNearestTaxon(Node* &taxon, Node *node, Node *dad = NULL);

/********************************************************
	Computing PD of area (user-defined set of taxa)
********************************************************/

	/**
		compute the PD score of a given taxa set in filename
		@param params program parameters
		@param taxa_set (OUT) corresponding set of taxa
		@param pd_more (OUT) more computed PD measures will be stored here
	*/
	void computePD(Params &params, vector<PDTaxaSet> &taxa_set, PDRelatedMeasures &pd_more);

	/**
		compute the PD score of a given taxa set with name in taxa_name
		@param taxa_name vector of name of all taxa
		@param taxa_set (OUT) corresponding set of taxa
		@param node the starting node, NULL to start from the root
		@param dad dad of the node, used to direct the search
	*/
	void makeTaxaSet(set<string> &taxa_name, PDTaxaSet &taxa_set, Node *node = NULL, Node *dad = NULL);

	/**
		compute the PD score of a given taxa set with name in taxa_name
		@param id_set (IN/OUT) corresponding set of taxa
		@param node the starting node, NULL to start from the root
		@param dad dad of the node, used to direct the search
		@param curlen current length so far
		@return TRUE if the below subtree contains taxon in id_set
	*/
	bool calcPD(Split &id_set, double curlen = 0.0, Node *node = NULL, Node *dad = NULL);

	/**
		compute the EXCLUSIVE PD score of a given taxa set with name in taxa_name
		@param id_set (IN/OUT) corresponding set of taxa IDs
	*/
	void calcExclusivePD(Split &id_set);

	/**
		compute the area's PD ENDEMISM of set of area
		@param area_set set of area
		@param pd_endem (OUT) corresponding PD endemism
	*/
	void calcPDEndemism(vector<PDTaxaSet> &area_set, DoubleVector &pd_endem);

	/**
		compute the area's PD complementarity given a specific area
		@param area_set set of area
		@param area_name given area names as string separated by commas
		@param pd_comp (OUT) corresponding PD endemism
	*/
	void calcPDComplementarity(vector<PDTaxaSet> &area_set, char *area_name, DoubleVector &pd_comp);


/********************************************************
	VARIABLES
********************************************************/

	/**
	 	initial set of taxa which must be included into the final PD set
	*/
	NodeVector initialset;

protected:


};


#endif