]> git.donarmstrong.com Git - mothur.git/blobdiff - phylosummary.cpp
modified chimera commands to process multiple fasta files and added checks to pintail...
[mothur.git] / phylosummary.cpp
index 1e8d1bc6c6b2497b85838aeebd4c31c30104a70d..84b0861e38cc450b50b481e7efdaaa76e0831e4e 100644 (file)
@@ -114,6 +114,8 @@ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
                                        //find out the sequences group
                                        string group = groupmap->getGroup(seqName);
                                        
+                                       if (group == "not found") {  m->mothurOut(seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine();  }
+                                       
                                        //do you have a count for this group?
                                        map<string, int>::iterator itGroup = tree[currentNode].groupCount.find(group);
                                        
@@ -126,9 +128,9 @@ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
                                tree[currentNode].total++;
 
                                currentNode = childPointer->second;
-                       }else{                                                                                  //otherwise, create it
-                               m->mothurOut("Error: cannot find taxonomy in tree for " + seqName + "."); m->mothurOutEndLine();
-                               seqTaxonomy = "";
+                       }else{  //otherwise, error
+                               m->mothurOut("Warning: cannot find taxon " + taxon + " in reference taxonomy tree at level " + toString(tree[currentNode].level) + " for " + seqName + ". This may cause totals of daughter levels not to add up in summary file."); m->mothurOutEndLine();
+                               break;
                        }
                        
                        level++;
@@ -168,7 +170,7 @@ void PhyloSummary::assignRank(int index){
 void PhyloSummary::print(ofstream& out){
        try {
                //print labels
-               out << "taxlevel\t rank ID\t label\t daughterlevels\t total\t";
+               out << "taxlevel\t rankID\t taxon\t daughterlevels\t total\t";
                if (groupmap != NULL) {
                        for (int i = 0; i < groupmap->namesOfGroups.size(); i++) {
                                out << groupmap->namesOfGroups[i] << '\t';
@@ -177,8 +179,15 @@ void PhyloSummary::print(ofstream& out){
                
                out << endl;
                
+               int totalChildrenInTree = 0;
+               
+               map<string,int>::iterator it;
+               for(it=tree[0].children.begin();it!=tree[0].children.end();it++){   
+                       if (tree[it->second].total != 0)  {   totalChildrenInTree++; }
+               }
+               
                //print root
-               out << tree[0].level << "\t" << tree[0].rank << "\t" << tree[0].name << "\t" << tree[0].children.size() << "\t" << tree[0].total << "\t";
+               out << tree[0].level << "\t" << tree[0].rank << "\t" << tree[0].name << "\t" << totalChildrenInTree << "\t" << tree[0].total << "\t";
                
                map<string, int>::iterator itGroup;
                if (groupmap != NULL) {
@@ -206,7 +215,15 @@ void PhyloSummary::print(int i, ofstream& out){
                for(it=tree[i].children.begin();it!=tree[i].children.end();it++){
                        
                        if (tree[it->second].total != 0)  {
-                               out << tree[it->second].level << "\t" << tree[it->second].rank << "\t" << tree[it->second].name << "\t" << tree[it->second].children.size() << "\t" << tree[it->second].total << "\t";
+                       
+                               int totalChildrenInTree = 0;
+               
+                               map<string,int>::iterator it2;
+                               for(it2=tree[it->second].children.begin();it2!=tree[it->second].children.end();it2++){   
+                                       if (tree[it2->second].total != 0)  {   totalChildrenInTree++; }
+                               }
+                       
+                               out << tree[it->second].level << "\t" << tree[it->second].rank << "\t" << tree[it->second].name << "\t" << totalChildrenInTree << "\t" << tree[it->second].total << "\t";
                                
                                map<string, int>::iterator itGroup;
                                if (groupmap != NULL) {