]> git.donarmstrong.com Git - mothur.git/blobdiff - phylosummary.cpp
fixed cluster.classic and added weighted method to hcluster
[mothur.git] / phylosummary.cpp
index 84b0861e38cc450b50b481e7efdaaa76e0831e4e..39bfdf3dfecb1cd4aaecb2763043d0c8cbb00d29 100644 (file)
@@ -48,12 +48,12 @@ void PhyloSummary::summarize(string userTfile){
        try {
                
                ifstream in;
-               openInputFile(userTfile, in);
+               m->openInputFile(userTfile, in);
                
                //read in users taxonomy file and add sequences to tree
                string name, tax;
                while(!in.eof()){
-                       in >> name >> tax; gobble(in);
+                       in >> name >> tax; m->gobble(in);
                        
                        addSeqToTree(name, tax);
                        
@@ -172,6 +172,9 @@ void PhyloSummary::print(ofstream& out){
                //print labels
                out << "taxlevel\t rankID\t taxon\t daughterlevels\t total\t";
                if (groupmap != NULL) {
+                       //so the labels match the counts below, since the map sorts them automatically...
+                       //sort(groupmap->namesOfGroups.begin(), groupmap->namesOfGroups.end());
+                       
                        for (int i = 0; i < groupmap->namesOfGroups.size(); i++) {
                                out << groupmap->namesOfGroups[i] << '\t';
                        }
@@ -191,9 +194,10 @@ void PhyloSummary::print(ofstream& out){
                
                map<string, int>::iterator itGroup;
                if (groupmap != NULL) {
-                       for (itGroup = tree[0].groupCount.begin(); itGroup != tree[0].groupCount.end(); itGroup++) {
-                               out << itGroup->second << '\t';
-                       }
+                       //for (itGroup = tree[0].groupCount.begin(); itGroup != tree[0].groupCount.end(); itGroup++) {
+                       //      out << itGroup->second << '\t';
+                       //}
+                       for (int i = 0; i < groupmap->namesOfGroups.size(); i++) {  out << tree[0].groupCount[groupmap->namesOfGroups[i]] << '\t'; } 
                }
                out << endl;
                
@@ -227,9 +231,10 @@ void PhyloSummary::print(int i, ofstream& out){
                                
                                map<string, int>::iterator itGroup;
                                if (groupmap != NULL) {
-                                       for (itGroup = tree[it->second].groupCount.begin(); itGroup != tree[it->second].groupCount.end(); itGroup++) {
-                                               out << itGroup->second << '\t';
-                                       }
+                                       //for (itGroup = tree[it->second].groupCount.begin(); itGroup != tree[it->second].groupCount.end(); itGroup++) {
+                                       //      out << itGroup->second << '\t';
+                                       //}
+                                       for (int i = 0; i < groupmap->namesOfGroups.size(); i++) {  out << tree[it->second].groupCount[groupmap->namesOfGroups[i]] << '\t'; } 
                                }
                                out << endl;
                        }
@@ -245,11 +250,17 @@ void PhyloSummary::print(int i, ofstream& out){
 /**************************************************************************************************/
 void PhyloSummary::readTreeStruct(ifstream& in){
        try {
+       
+               //read version
+               string line = m->getline(in); m->gobble(in);
+               
                int num;
                
-               in >> num; gobble(in);
+               in >> num; m->gobble(in);
                
                tree.resize(num);
+               
+               in >> maxLevel; m->gobble(in);
        
                //read the tree file
                for (int i = 0; i < tree.size(); i++) {
@@ -273,9 +284,9 @@ void PhyloSummary::readTreeStruct(ifstream& in){
                        
                        tree[i].total = 0;
                        
-                       gobble(in);
+                       m->gobble(in);
                        
-                       if (tree[i].level > maxLevel) {  maxLevel = tree[i].level;  }
+                       //if (tree[i].level > maxLevel) {  maxLevel = tree[i].level;  }
                }
 
        }