-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpeciesDistManager.H
96 lines (90 loc) · 3.46 KB
/
SpeciesDistManager.H
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
#ifndef _SPECIES_DATA_
#define _SPECIES_DATA_
#include <map>
#include <vector>
#include <string>
using namespace std;
class Matrix;
class SpeciesDistManager
{
public:
SpeciesDistManager();
~SpeciesDistManager();
int readSpeciesTree(const char*);
int setMaxClusters(int k);
double getAncestralClustering(map<string,int>& extantStatus,map<string,int>& ancestralStatus);
double getExtantClustering(map<string,int>& ancestralClustering, map<string,int>& extantClustering);
double getConditionalProb(string& child,int parentCluster,int childCluster);
//double getProbGainLoss(string&);
//double getProbLossGain(string&);
//double getProbLossLoss(string&);
//int enumerateAllAncestors(map<string,int>& edgeStatus);
double scoreAssignment(map<string,int>& jointAssign);
double getEdgeStatusProb(map<string,int>& edgeStatus);
int showInferredConditionals(const char* outputDir);
int showInferredConditionals_ML(const char* outputDir);
struct Species;
struct Species
{
string name;
Species* parent;
vector<Species*> children;
Matrix* conditional;
Matrix* conditional_ml;
inline Matrix* getParams()
{
return conditional;
}
map<int,vector<int>*> sortedClustIDs;
inline vector<int>* getSortedClusterIDs(int rowID)
{
vector<int>* sortedIDs=NULL;
if(sortedClustIDs.find(rowID)!=sortedClustIDs.end())
{
sortedIDs=sortedClustIDs[rowID];
}
return sortedIDs;
}
inline int setSortedClusterIDs(int rowId,vector<int>* sortedIDs)
{
sortedClustIDs[rowId]=sortedIDs;
}
};
Species* getRoot();
int assignLevel();
int assignLevel(SpeciesDistManager::Species*,int);
int getLevelFromRoot(const char* nodeName);
int getSpeciesListPrefix(vector<string>&);
map<string,Species*>& getAllSpecies();
Species* getSpecies(string&);
Matrix* getConditional(string& spName);
int resetTransitionProbability();
int resetTransitionProbability(Species*);
int normalizeTransitionMatrix();
int normalizeTransitionMatrix(Species*);
int initTransitionMatrix_ML();
int initTransitionMatrix_ML(Species*);
Matrix* getTransitionMatrix_ML(string& name);
int normalizeTransitionMatrix_ML();
int normalizeTransitionMatrix_ML(Species*);
int assignExtantClustering(map<string,int>& ancestralClusterAssign,Species* node, map<string,int>& extantClusterAssign);
double getSubTree(int,Species*,map<string,int>&);
double maxSubTree(int parentCluster, Species* child, map<string,int>& extantCluster,map<string,int>& ancestralCluster);
//int enumerateChild(Species*,map<string,int>&,map<string,int>&,vector<map<string,int>*>&);
int getMaxClusterAssignForChild(int parentClustID,Species* child);
int showConditionals(const char*,SpeciesDistManager::Species* species);
int showConditionals_ML(const char*,SpeciesDistManager::Species* species);
//Should be called on a per datapoint level, where a datapoint represents the joint assignment of all
//variables. The input parameter, dataPtProb is the probability density of the data point from the
//ith cluster, where i is the key of the map.
//The output parameter is the normalization constant for each node.
//int estimateNormalizationConstants(map<string,map<int,double>*>& dataPtProb, map<string,double>& normConstants);
//int estimateNormalizationConstant_Node(map<string,map<int,double>*>& dataPtProb, map<string,double>& normConstants,Species*,int ancestralClustID);
private:
int getSpeciesListPrefix(Species*,vector<string>&);
map<string,Species*> speciesSet;
Species* root;
int maxClusterCnt;
map<string,int> levelFromRoot;
};
#endif