]> git.donarmstrong.com Git - mothur.git/blobdiff - seqsummarycommand.cpp
added summary outputs for align.check
[mothur.git] / seqsummarycommand.cpp
index 8730997883ac5da6f8588e216f8311285303160d..8c13e7fbbd76895b751ae982b8df9a093e1c1ca9 100644 (file)
@@ -172,7 +172,7 @@ int SeqSummaryCommand::execute(){
                vector<int> ambigBases;
                vector<int> longHomoPolymer;
                
-               if (namefile != "") { readNames(); }
+               if (namefile != "") { nameMap = m->readNames(namefile); }
                
                if (m->control_pressed) { return 0; }
                        
@@ -328,13 +328,14 @@ int SeqSummaryCommand::execute(){
                sort(seqLength.begin(), seqLength.end());
                sort(ambigBases.begin(), ambigBases.end());
                sort(longHomoPolymer.begin(), longHomoPolymer.end());
-               
-               int ptile0_25   = int(numSeqs * 0.025);
-               int ptile25             = int(numSeqs * 0.250);
-               int ptile50             = int(numSeqs * 0.500);
-               int ptile75             = int(numSeqs * 0.750);
-               int ptile97_5   = int(numSeqs * 0.975);
-               int ptile100    = numSeqs - 1;
+               int size = startPosition.size();
+                               
+               int ptile0_25   = int(size * 0.025);
+               int ptile25             = int(size * 0.250);
+               int ptile50             = int(size * 0.500);
+               int ptile75             = int(size * 0.750);
+               int ptile97_5   = int(size * 0.975);
+               int ptile100    = size - 1;
                
                //to compensate for blank sequences that would result in startPosition and endPostion equalling -1
                if (startPosition[0] == -1) {  startPosition[0] = 0;    }
@@ -480,7 +481,7 @@ int SeqSummaryCommand::MPICreateSummary(int start, int num, vector<int>& startPo
                                        //make sure this sequence is in the namefile, else error 
                                        map<string, int>::iterator it = nameMap.find(current.getName());
                                        
-                                       if (it == nameMap.end()) { m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
+                                       if (it == nameMap.end()) { cout << "[ERROR]: " << current.getName() << " is not in your namefile, please correct." << endl; m->control_pressed = true; }
                                        else { num = it->second; }
                                }
                                
@@ -589,34 +590,6 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector<int>& startPosition,
        }
 }
 /**********************************************************************************************************************/
-int SeqSummaryCommand::readNames() { 
-       try {
-               //open input file
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (m->control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       
-                       int num = m->getNumNames(secondCol);
-                       
-                       nameMap[firstCol] = num;
-               }
-               in.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "readNames");
-               exit(1);
-       }
-}
-
-/**********************************************************************************************************************/