Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion candidateset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool CandidateSet::update(string tree, double score) {
}

vector<double> CandidateSet::getBestScores(int numBestScore) {
if (numBestScore == 0)
if (numBestScore == 0 || numBestScore > size())
numBestScore = size();
vector<double> res;
for (reverse_iterator rit = rbegin(); rit != rend() && numBestScore > 0; rit++, numBestScore--) {
Expand Down
2 changes: 1 addition & 1 deletion iqtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ string IQTree::optimizeModelParameters(bool printInfo) {
}

void IQTree::printBestScores(int numBestScore) {
vector<double> bestScores = candidateTrees.getBestScores(candidateTrees.popSize);
vector<double> bestScores = candidateTrees.getBestScores(numBestScore);
for (vector<double>::iterator it = bestScores.begin(); it != bestScores.end(); it++)
cout << (params->maximum_parsimony ? -(*it) : (*it)) << " ";
cout << endl;
Expand Down
9 changes: 7 additions & 2 deletions phyloanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,8 +1851,13 @@ void runTreeReconstruction(Params &params, string &original_model, IQTree &iqtre
if (iqtree.isSuperTree())
((PhyloSuperTree*) &iqtree)->mapTrees();
if (params.snni && params.min_iterations) {
cout << (params.maximum_parsimony ? "Scores" : "Log-likelihoods") << " of best " << params.popSize << " trees: " << endl;
iqtree.printBestScores(iqtree.candidateTrees.popSize);
if (params.savek == 0) {
cout << (params.maximum_parsimony ? "Scores" : "Log-likelihoods") << " of best " << params.popSize << " trees: " << endl;
iqtree.printBestScores(iqtree.candidateTrees.popSize);
} else {
cout << (params.maximum_parsimony ? "Scores" : "Log-likelihoods") << " of best " << params.savek << " trees: " << endl;
iqtree.printBestScores(params.savek);
}
}

/******** Performs final model parameters optimization ******************/
Expand Down
10 changes: 10 additions & 0 deletions tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ void parseArg(int argc, char *argv[], Params &params) {
params.do_first_rell = false;
params.remove_dup_seq = false;
params.test_mode = false;
params.savek = 0;

#ifdef _OPENMP
params.num_threads = 0;
Expand Down Expand Up @@ -2263,6 +2264,15 @@ void parseArg(int argc, char *argv[], Params &params) {
assert(params.popSize < params.numParsTrees);
continue;
}
if (strcmp(argv[cnt], "-savek") == 0) {
cnt++;
if (cnt >= argc)
throw "Use -savek <number_of_saving_trees>";
params.savek = convert_int(argv[cnt]);
params.numParsTrees = max(params.savek, params.numParsTrees);
assert(params.savek > 0);
continue;
}
if (strcmp(argv[cnt], "-beststart") == 0) {
params.bestStart = true;
cnt++;
Expand Down
5 changes: 5 additions & 0 deletions tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,11 @@ struct Params {
*/
bool test_mode;

/**
* number of search trees saved
*/
int savek;

/*
* Diep:
* Use with -test_mode
Expand Down