diff --git a/main/phyloanalysis.cpp b/main/phyloanalysis.cpp index b0083962..4ebaae96 100644 --- a/main/phyloanalysis.cpp +++ b/main/phyloanalysis.cpp @@ -594,7 +594,7 @@ void reportTree(ofstream &out, Params ¶ms, PhyloTree &tree, double tree_lh, else out << "NOTE: Tree is UNROOTED although outgroup taxon '" << tree.root->name << "' is drawn at root" << endl; - if (tree.isSuperTree() && params.partition_type == 0) + if (tree.isSuperTree() && params.partition_type == BRLEN_OPTIMIZE) out << "NOTE: Branch lengths are weighted average over all partitions" << endl << " (weighted by the number of sites in the partitions)" << endl; if (tree.isMixlen()) @@ -928,14 +928,16 @@ void reportPhyloAnalysis(Params ¶ms, string &original_model, out << "SUBSTITUTION PROCESS" << endl << "--------------------" << endl << endl; if (tree.isSuperTree()) { - if(params.partition_type) - out << "Proportional partition model with joint branch lengths and separate models between partitions" << endl << endl; + if(params.partition_type == BRLEN_SCALE) + out << "Edge-linked-proportional partition model but separate models between partitions" << endl << endl; + else if(params.partition_type == BRLEN_FIX) + out << "Edge-linked-equal partition model but separate models between partitions" << endl << endl; else - out << "Full partition model with separate branch lengths and models between partitions" << endl << endl; + out << "Edge-unlinked partition model and separate models between partitions" << endl << endl; PhyloSuperTree *stree = (PhyloSuperTree*) &tree; PhyloSuperTree::iterator it; int part; - if(params.partition_type) + if(params.partition_type != BRLEN_OPTIMIZE) out << " ID Model Speed Parameters" << endl; else out << " ID Model TreeLen Parameters" << endl; @@ -944,7 +946,7 @@ void reportPhyloAnalysis(Params ¶ms, string &original_model, out.width(4); out << right << (part+1) << " "; out.width(14); - if(params.partition_type) + if(params.partition_type != BRLEN_OPTIMIZE) out << left << (*it)->getModelName() << " " << stree->part_info[part].part_rate << " " << (*it)->getModelNameParams() << endl; else out << left << (*it)->getModelName() << " " << (*it)->treeLength() << " " << (*it)->getModelNameParams() << endl; @@ -1549,6 +1551,15 @@ void initializeParams(Params ¶ms, IQTree &iqtree, ModelCheckpoint &model_inf Checkpoint *orig_checkpoint = iqtree.getCheckpoint(); iqtree.setCheckpoint(&model_info); + int partition_type; + if (CKP_RESTORE2((&model_info), partition_type)) { + if (partition_type != params.partition_type) + outError("Mismatch partition type between checkpoint and partition file command option"); + } else { + partition_type = params.partition_type; + CKP_SAVE2((&model_info), partition_type); + } + // compute initial tree iqtree.computeInitialTree(dist_file, params.SSE); @@ -2734,7 +2745,7 @@ void runStandardBootstrap(Params ¶ms, string &original_model, Alignment *ali } IQTree *boot_tree; if (alignment->isSuperAlignment()){ - if(params.partition_type){ + if(params.partition_type != BRLEN_OPTIMIZE){ boot_tree = new PhyloSuperTreePlen((SuperAlignment*) bootstrap_alignment, (PhyloSuperTree*) tree); } else { boot_tree = new PhyloSuperTree((SuperAlignment*) bootstrap_alignment, (PhyloSuperTree*) tree); @@ -2997,7 +3008,7 @@ void runPhyloAnalysis(Params ¶ms, Checkpoint *checkpoint) { /****************** read in alignment **********************/ if (params.partition_file) { // Partition model analysis - if(params.partition_type){ + if(params.partition_type != BRLEN_OPTIMIZE){ // since nni5 does not work yet, stop the programm /* if(params.nni5) outError("-nni5 option is unsupported yet for proportitional partition model. please use -nni1 option");*/ @@ -3203,7 +3214,7 @@ void runPhyloAnalysis(Params ¶ms, Checkpoint *checkpoint) { // } if(verbose_mode >= VB_MED){ - if(tree->isSuperTree() && params.partition_type){ + if(tree->isSuperTree() && params.partition_type != BRLEN_OPTIMIZE){ ((PhyloSuperTreePlen*) tree)->printNNIcasesNUM(); } } diff --git a/main/phylotesting.cpp b/main/phylotesting.cpp index dee9afc1..b525a3bb 100644 --- a/main/phylotesting.cpp +++ b/main/phylotesting.cpp @@ -1455,9 +1455,9 @@ void testPartitionModel(Params ¶ms, PhyloSuperTree* in_tree, ModelCheckpoint DoubleVector lenvec; // tree length for each partition double lhsum = 0.0; int dfsum = 0; - if (params.partition_type) { + if (params.partition_type != BRLEN_OPTIMIZE) { dfsum = in_tree->getNBranchParameters(BRLEN_OPTIMIZE); - if (params.partition_type == 'p') + if (params.partition_type == BRLEN_SCALE) dfsum -= 1; } int ssize = in_tree->getAlnNSite(); @@ -1517,7 +1517,7 @@ void testPartitionModel(Params ¶ms, PhyloSuperTree* in_tree, ModelCheckpoint // read tree with branch lengths for linked partition model - if (params.partition_type && !concat_tree.empty()) { + if (params.partition_type != BRLEN_OPTIMIZE && !concat_tree.empty()) { in_tree->readTreeString(concat_tree); int part = 0; for (auto it = in_tree->begin(); it != in_tree->end(); it++, part++) { @@ -1564,8 +1564,6 @@ void testPartitionModel(Params ¶ms, PhyloSuperTree* in_tree, ModelCheckpoint } bool parallel_over_partitions = false; - int brlen_type = (params.partition_type == 0) ? BRLEN_OPTIMIZE : - ((params.partition_type == 'p') ? BRLEN_SCALE : BRLEN_FIX); #ifdef _OPENMP parallel_over_partitions = !params.model_test_and_tree && (in_tree->size() >= num_threads); @@ -1582,7 +1580,7 @@ void testPartitionModel(Params ¶ms, PhyloSuperTree* in_tree, ModelCheckpoint if (params.model_name.empty()) part_model_name = in_tree->part_info[i].model_name; ModelInfo best_model; - best_model.name = testModel(params, this_tree, part_model_info, models_block, (parallel_over_partitions ? 1 : num_threads), brlen_type, in_tree->part_info[i].name, false, part_model_name); + best_model.name = testModel(params, this_tree, part_model_info, models_block, (parallel_over_partitions ? 1 : num_threads), params.partition_type, in_tree->part_info[i].name, false, part_model_name); ASSERT(best_model.restoreCheckpoint(&part_model_info)); @@ -1732,7 +1730,7 @@ void testPartitionModel(Params ¶ms, PhyloSuperTree* in_tree, ModelCheckpoint tree->saveCheckpoint(); } best_model.name = testModel(params, tree, part_model_info, models_block, - params.model_test_and_tree ? num_threads : 1, brlen_type, cur_pair.set_name); + params.model_test_and_tree ? num_threads : 1, params.partition_type, cur_pair.set_name); best_model.restoreCheckpoint(&part_model_info); if (params.model_test_and_tree) { delete tree->getCheckpoint(); diff --git a/tree/iqtree.cpp b/tree/iqtree.cpp index b87718a4..3869aceb 100644 --- a/tree/iqtree.cpp +++ b/tree/iqtree.cpp @@ -983,7 +983,7 @@ void IQTree::initializeModel(Params ¶ms, string &model_name, ModelsBlock *mo try { if (!getModelFactory()) { if (isSuperTree()) { - if (params.partition_type) { + if (params.partition_type != BRLEN_OPTIMIZE) { setModelFactory(new PartitionModelPlen(params, (PhyloSuperTreePlen*) this, models_block)); } else setModelFactory(new PartitionModel(params, (PhyloSuperTree*) this, models_block)); @@ -2746,7 +2746,7 @@ void IQTree::refineBootTrees() { // create bootstrap tree IQTree *boot_tree; if (aln->isSuperAlignment()){ - if(params->partition_type){ + if(params->partition_type != BRLEN_OPTIMIZE){ boot_tree = new PhyloSuperTreePlen((SuperAlignment*) bootstrap_alignment, (PhyloSuperTree*) this); } else { boot_tree = new PhyloSuperTree((SuperAlignment*) bootstrap_alignment, (PhyloSuperTree*) this); diff --git a/tree/phylosupertreeplen.cpp b/tree/phylosupertreeplen.cpp index c4e736d2..2597f2bf 100644 --- a/tree/phylosupertreeplen.cpp +++ b/tree/phylosupertreeplen.cpp @@ -31,7 +31,7 @@ PhyloSuperTreePlen::PhyloSuperTreePlen(Params ¶ms) : PhyloSuperTree(params) { memset(allNNIcases_computed, 0, 5*sizeof(int)); - fixed_rates = (params.partition_type == 'j') ? true : false; + fixed_rates = (params.partition_type == BRLEN_FIX) ? true : false; int part = 0; for (iterator it = begin(); it != end(); it++, part++) { part_info[part].part_rate = 1.0; diff --git a/utils/tools.cpp b/utils/tools.cpp index dd4196c3..f76ed81c 100644 --- a/utils/tools.cpp +++ b/utils/tools.cpp @@ -768,7 +768,7 @@ void parseArg(int argc, char *argv[], Params ¶ms) { params.do_au_test = false; params.siteLL_file = NULL; //added by MA params.partition_file = NULL; - params.partition_type = 0; + params.partition_type = BRLEN_OPTIMIZE; params.partfinder_rcluster = 100; params.partfinder_rcluster_max = 0; params.partfinder_rcluster_fast = false; @@ -1648,7 +1648,7 @@ void parseArg(int argc, char *argv[], Params ¶ms) { if (cnt >= argc) throw "Use -spp "; params.partition_file = argv[cnt]; - params.partition_type = 'p'; + params.partition_type = BRLEN_SCALE; params.opt_gammai = false; continue; } @@ -1657,13 +1657,13 @@ void parseArg(int argc, char *argv[], Params ¶ms) { if (cnt >= argc) throw "Use -q "; params.partition_file = argv[cnt]; - params.partition_type = 'j'; + params.partition_type = BRLEN_FIX; params.optimize_alg_gammai = "Brent"; params.opt_gammai = false; continue; } if (strcmp(argv[cnt], "-M") == 0) { - params.partition_type = 0; + params.partition_type = BRLEN_OPTIMIZE; continue; } if (strcmp(argv[cnt], "-rcluster") == 0) { @@ -3427,9 +3427,12 @@ void parseArg(int argc, char *argv[], Params ¶ms) { usage(argv, false); #endif } - + + if (params.model_test_and_tree && params.partition_type != BRLEN_OPTIMIZE) + outError("-mtree not allowed with edge-linked partition model (-spp or -q)"); + if (params.do_au_test && params.topotest_replicates == 0) - outError("For AU test please please specify number of bootstrap replicates via -zb option"); + outError("For AU test please specify number of bootstrap replicates via -zb option"); if (params.lh_mem_save == LM_MEM_SAVE && params.partition_file) outError("-mem option does not work with partition models yet"); diff --git a/utils/tools.h b/utils/tools.h index a849bf5c..776ef695 100644 --- a/utils/tools.h +++ b/utils/tools.h @@ -825,12 +825,13 @@ class Params { char *partition_file; /** + * IMPORTANT (2012-12-21): refactor this variable as below * defines the relation between edge lengths in supertree and subtrees - * 0 (NULL) for separate edge length (default) - * 'p' for proportional edge length - * 'j' for joint edge length + * BRLEN_OPTIMIZE (0) for separate edge length (default) + * BRLEN_FIX (1) for joint edge length + * BRLEN_SCALE (2) for proportional edge length */ - char partition_type; + int partition_type; /** percentage for rcluster algorithm like PartitionFinder */ double partfinder_rcluster;