]> git.donarmstrong.com Git - mothur.git/blobdiff - countseqscommand.cpp
changed reading of name file to use buffered reads. note the splitAtWhiteSpace functi...
[mothur.git] / countseqscommand.cpp
index a9bffc6eca25d3ad78ce7b01d96e196ba6308bfb..e83c6035731aa5509655dcd25a7a45995c1a0004 100644 (file)
@@ -147,9 +147,9 @@ int CountSeqsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + ".seq.count";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "seq.count";
                m->openOutputFile(outputFileName, out); outputTypes["summary"].push_back(outputFileName);
-               out << "Representative Sequence\t total\t";
+               out << "Representative_Sequence\ttotal\t";
                
                GroupMap* groupMap;
                if (groupfile != "") { 
@@ -157,7 +157,8 @@ int CountSeqsCommand::execute(){
                        
                        //make sure groups are valid. takes care of user setting groupNames that are invalid or setting groups=all
                        SharedUtil* util = new SharedUtil();
-                       util->setGroups(Groups, groupMap->namesOfGroups);
+                       vector<string> nameGroups = groupMap->getNamesOfGroups();
+                       util->setGroups(Groups, nameGroups);
                        delete util;
                        
                        //sort groupNames so that the group title match the counts below, this is needed because the map object automatically sorts
@@ -173,7 +174,8 @@ int CountSeqsCommand::execute(){
                //open input file
                ifstream in;
                m->openInputFile(namefile, in);
-               
+        
+               int total = 0;
                while (!in.eof()) {
                        if (m->control_pressed) { break; }
                        
@@ -216,14 +218,16 @@ int CountSeqsCommand::execute(){
                                out << firstCol << '\t' << names.size() << endl;
                        }
                        
-                       
+                       total += names.size();
                }
                in.close();
                
                if (groupfile != "") { delete groupMap; }
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0; }
+               if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; }
                
+        m->mothurOutEndLine();
+               m->mothurOut("Total number of sequences: " + toString(total)); m->mothurOutEndLine();
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
                m->mothurOut(outputFileName); m->mothurOutEndLine();