]> git.donarmstrong.com Git - mothur.git/blob - parsimony.cpp
adding treeclimber and unifrac pieces
[mothur.git] / parsimony.cpp
1 /*
2  *  parsimony.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 1/26/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "parsimony.h"
11
12 /**************************************************************************************************/
13 EstOutput Parsimony::getValues(Tree* t) {
14         try {
15                 data.resize(1,0);
16                         
17                 int score = 0;
18                         
19                 for(int i=t->getNumLeaves();i<t->getNumNodes();i++){
20                         int lc = t->tree[i].getLChild();
21                         int rc = t->tree[i].getRChild();
22                         
23                          if(t->tree[i].pGroups.size() > t->tree[rc].pGroups.size() || t->tree[i].pGroups.size() > t->tree[lc].pGroups.size()){
24                                 score++;
25                         }
26                 } 
27                 
28                 data[0] = score;
29                 
30                 return data;
31         }
32         catch(exception& e) {
33                 cout << "Standard Error: " << e.what() << " has occurred in the Parsimony class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
34                 exit(1);
35         }
36         catch(...) {
37                 cout << "An unknown error has occurred in the Parsimony class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
38                 exit(1);
39         }
40
41 }
42 /**************************************************************************************************/