File: TreeCollection.cpp

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 (56 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (3)
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
//
// Created by Tung Nguyen on 6/23/15.
//

#include "TreeCollection.h"
#include "MPIHelper.h"

using namespace std;

TreeCollection::TreeCollection(vector<string>& trees, vector<double>& scores, vector<int> &sourceProcID) {
    ASSERT(trees.size() == scores.size());
    this->treeStrings = trees;
    this->scores = scores;
    this->sourceProcID = sourceProcID;
//    this->sourceProcID.clear();
//    this->sourceProcID.insert(this->sourceProcID.end(), scores.size(), MPIHelper::getInstance().getProcessID());
}

pair<string, double> TreeCollection::getTree(int i) {
    ASSERT(treeStrings.size() == scores.size());
    return std::make_pair(treeStrings[i], scores[i]);
}

void TreeCollection::clear() {
    treeStrings.clear();
    scores.clear();
    sourceProcID.clear();
}

void TreeCollection::addTrees(TreeCollection &trees) {
//    for (int i = 0; i < trees.getNumTrees(); i++) {
//        treeStrings.push_back(trees.getTree(i).first);
//        scores.push_back(trees.getTree(i).second);
//        
//    }
    treeStrings.insert(treeStrings.end(), trees.treeStrings.begin(), trees.treeStrings.end());
    scores.insert(scores.end(), trees.scores.begin(), trees.scores.end());
    sourceProcID.insert(sourceProcID.end(), trees.sourceProcID.begin(), trees.sourceProcID.end());
}

void TreeCollection::addTrees(CandidateSet &candidateTrees) {
    CandidateSet::reverse_iterator rit;
    for (rit = candidateTrees.rbegin(); rit != candidateTrees.rend(); rit++) {
       treeStrings.push_back(rit->second.tree);
       scores.push_back(rit->first);
       sourceProcID.push_back(MPIHelper::getInstance().getProcessID());
    }
}



size_t TreeCollection::getNumTrees() {
    size_t numTrees = treeStrings.size();
    ASSERT(numTrees == scores.size());
    return numTrees;
}