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 "tree/tinatree.h"
23 #include "parsmultistate.h"
24 #include "alignment/alignment.h"
25 #include "tree/parstree.h"
26
doParsMultiState(Params & params)27 void doParsMultiState(Params ¶ms) {
28 Alignment alignment(params.aln_file, params.sequence_type, params.intype, "");
29 alignment.orderPatternByNumChars(PAT_VARIANT);
30 ParsTree pars_tree;
31 pars_tree.readTree(params.user_file, params.is_rooted);
32 if (pars_tree.rooted)
33 pars_tree.convertToUnrooted();
34 pars_tree.setAlignment(&alignment);
35 pars_tree.initCostMatrix(CM_LINEAR);
36 pars_tree.setParsimonyKernel(params.SSE);
37 pars_tree.initializeAllPartialPars();
38 int total_length = pars_tree.computeParsimony();
39 cout << "total length: " << total_length << endl;
40 pars_tree.initCostMatrix(CM_UNIFORM);
41 int pars_score = pars_tree.computeParsimony();
42 cout.unsetf(ios::fixed);
43 cout.precision(6);
44 cout << "mean length: " << double(total_length)/pars_score << endl;
45 cout << "Parsimony score is: " << pars_score << endl;
46 //cout << "Parsimony score ver2 is: " << tree.computeParsimony() << endl;
47 //tree.printParsimonyStates();
48 }
49