1 /***************************************************************************
2 * Copyright (C) 2009 by BUI Quang Minh *
3 * minh.bui@univie.ac.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #include "tree/phylotree.h"
22 #include "rateheterogeneity.h"
23
24
RateHeterogeneity()25 RateHeterogeneity::RateHeterogeneity()
26 : Optimization(), CheckpointFactory()
27 {
28 name = "";
29 full_name = "Uniform";
30 phylo_tree = NULL;
31 }
32
setTree(PhyloTree * tree)33 void RateHeterogeneity::setTree(PhyloTree *tree) {
34 phylo_tree = tree;
35 }
36
~RateHeterogeneity()37 RateHeterogeneity::~RateHeterogeneity()
38 {
39 }
40
startCheckpoint()41 void RateHeterogeneity::startCheckpoint() {
42 checkpoint->startStruct("RateHeterogeneity");
43 }
44
saveCheckpoint()45 void RateHeterogeneity::saveCheckpoint() {
46 startCheckpoint();
47 // CKP_SAVE(name);
48 // CKP_SAVE(full_name);
49 endCheckpoint();
50 CheckpointFactory::saveCheckpoint();
51 }
52
restoreCheckpoint()53 void RateHeterogeneity::restoreCheckpoint() {
54 startCheckpoint();
55 // CKP_RESTORE(name);
56 // CKP_RESTORE(full_name);
57 endCheckpoint();
58 }
59
60 /*
61 void RateHeterogeneity::writeSiteRates(const char *file_name) {
62 DoubleVector pattern_rates;
63 IntVector pattern_cat;
64 int ncategory = computePatternRates(pattern_rates, pattern_cat);
65 if (pattern_rates.empty()) return;
66
67 try {
68 ofstream out;
69 out.exceptions(ios::failbit | ios::badbit);
70 out.open(file_name);
71 writeSiteRates(out, pattern_rates, pattern_cat, ncategory);
72 out.close();
73 cout << "Site rates printed to " << file_name << endl;
74 } catch (ios::failure) {
75 outError(ERR_WRITE_OUTPUT, file_name);
76 }
77 }
78 */
79
targetFunk(double x[])80 double RateHeterogeneity::targetFunk(double x[]) {
81 return -phylo_tree->computeLikelihood();
82 }
83