]> git.donarmstrong.com Git - mothur.git/blobdiff - counttable.cpp
added name, group and count files to chop.seqs. added intelligent warnings for when...
[mothur.git] / counttable.cpp
index c16bf9227a51580cac00de78a215b89e2a93e001..48b52d98e76e6da585c862682c3906bdf4ad0f67 100644 (file)
@@ -40,7 +40,13 @@ int CountTable::createTable(set<string>& n, map<string, string>& g, set<string>&
             if (itGroup != g.end()) {   
                 groupCounts[indexGroupMap[itGroup->second]] = 1; 
                 totalGroups[indexGroupMap[itGroup->second]]++;
-            }else { m->mothurOut("[ERROR]: Your group file does not contain " + seqName + ". Please correct."); m->mothurOutEndLine(); }
+            }else {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(seqName, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
+                m->mothurOut("[ERROR]: Your group file does not contain " + seqName + ". Please correct."); m->mothurOutEndLine();
+            }
             
             map<string, int>::iterator it2 = indexNameMap.find(seqName);
             if (it2 == indexNameMap.end()) {
@@ -360,6 +366,10 @@ vector<int> CountTable::getGroupCounts(string seqName) {
         if (hasGroups) {
             map<string, int>::iterator it = indexNameMap.find(seqName);
             if (it == indexNameMap.end()) {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(seqName, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
                 m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
             }else { 
                 temp = counts[it->second];
@@ -404,6 +414,10 @@ int CountTable::getGroupCount(string seqName, string groupName) {
             }else { 
                 map<string, int>::iterator it2 = indexNameMap.find(seqName);
                 if (it2 == indexNameMap.end()) {
+                    //look for it in names of groups to see if the user accidently used the wrong file
+                    if (m->inUsersGroups(seqName, groups)) {
+                        m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                    }
                     m->mothurOut("[ERROR]: seq " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
                 }else { 
                     return counts[it2->second][it->second];
@@ -429,6 +443,10 @@ int CountTable::setAbund(string seqName, string groupName, int num) {
             }else { 
                 map<string, int>::iterator it2 = indexNameMap.find(seqName);
                 if (it2 == indexNameMap.end()) {
+                    //look for it in names of groups to see if the user accidently used the wrong file
+                    if (m->inUsersGroups(seqName, groups)) {
+                        m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                    }
                     m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
                 }else { 
                     int oldCount = counts[it2->second][it->second];
@@ -576,6 +594,12 @@ int CountTable::renameSeq(string oldSeqName, string newSeqName) {
         
         map<string, int>::iterator it = indexNameMap.find(oldSeqName);
         if (it == indexNameMap.end()) {
+            if (hasGroupInfo()) {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(oldSeqName, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + oldSeqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
+            }
             m->mothurOut("[ERROR]: " + oldSeqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
         }else {  
             int index = it->second;
@@ -598,6 +622,12 @@ int CountTable::getNumSeqs(string seqName) {
                 
         map<string, int>::iterator it = indexNameMap.find(seqName);
         if (it == indexNameMap.end()) {
+            if (hasGroupInfo()) {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(seqName, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
+            }
             m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
         }else { 
             return totals[it->second];
@@ -617,6 +647,12 @@ int CountTable::get(string seqName) {
         
         map<string, int>::iterator it = indexNameMap.find(seqName);
         if (it == indexNameMap.end()) {
+            if (hasGroupInfo()) {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(seqName, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
+            }
             m->mothurOut("[ERROR]: " + seqName + " is not in your count table. Please correct.\n"); m->control_pressed = true;
         }else { return it->second; }
         
@@ -663,6 +699,12 @@ int CountTable::remove(string seqName) {
             total -= thisTotal;
             indexNameMap.erase(it);
         }else {
+            if (hasGroupInfo()) {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(seqName, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seqName + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
+            }
             m->mothurOut("[ERROR]: Your count table contains does not include " + seqName + ", cannot remove."); m->mothurOutEndLine(); m->control_pressed = true;
         }
         
@@ -799,10 +841,22 @@ int CountTable::mergeCounts(string seq1, string seq2) {
     try {
         map<string, int>::iterator it = indexNameMap.find(seq1);
         if (it == indexNameMap.end()) {
+            if (hasGroupInfo()) {
+                //look for it in names of groups to see if the user accidently used the wrong file
+                if (m->inUsersGroups(seq1, groups)) {
+                    m->mothurOut("[WARNING]: Your group or design file contains a group named " + seq1 + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                }
+            }
             m->mothurOut("[ERROR]: " + seq1 + " is not in your count table. Please correct.\n"); m->control_pressed = true;
         }else { 
             map<string, int>::iterator it2 = indexNameMap.find(seq2);
             if (it2 == indexNameMap.end()) {
+                if (hasGroupInfo()) {
+                    //look for it in names of groups to see if the user accidently used the wrong file
+                    if (m->inUsersGroups(seq2, groups)) {
+                        m->mothurOut("[WARNING]: Your group or design file contains a group named " + seq2 + ".  Perhaps you are used a group file instead of a design file? A common cause of this is using a tree file that relates your groups (created by the tree.shared command) with a group file that assigns sequences to a group."); m->mothurOutEndLine();
+                    }
+                }
                 m->mothurOut("[ERROR]: " + seq2 + " is not in your count table. Please correct.\n"); m->control_pressed = true;
             }else { 
                 //merge data