]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeraperseuscommand.cpp
added oligos class. added check orient parameter to trim.flows, sffinfo, fastq.info...
[mothur.git] / chimeraperseuscommand.cpp
index 1835862f6b970ffdf7469002866f33a6682257ad..ef3058d8cda30d8781e9a0057c9e93d77feeb1b9 100644 (file)
@@ -469,10 +469,7 @@ ChimeraPerseusCommand::ChimeraPerseusCommand(string option)  {
                        m->mothurConvert(temp, beta);
             
                        temp = validParameter.validFile(parameters, "dereplicate", false);      
-                       if (temp == "not found") { 
-                               if (groupfile != "")    {  temp = "false";                                      }
-                               else                    {  temp = "true";       }
-                       }
+                       if (temp == "not found") { temp = "false";                      }
                        dups = m->isTrue(temp);
                }
        }
@@ -519,7 +516,7 @@ int ChimeraPerseusCommand::execute(){
             
             if (hasCount) {
                 CountTable* ct = new CountTable();
-                ct->readTable(nameFile);
+                ct->readTable(nameFile, true, false);
                 
                 if (ct->hasGroupInfo()) {
                     cparser = new SequenceCountParser(fastaFileNames[s], *ct);
@@ -537,7 +534,7 @@ int ChimeraPerseusCommand::execute(){
                     
                     if(processors == 1)        {       numSeqs = driverGroups(outputFileName, accnosFileName, newCountFile, 0, groups.size(), groups);
                         if (dups) {
-                            CountTable c; c.readTable(nameFile);
+                            CountTable c; c.readTable(nameFile, true, false);
                             if (!m->isBlank(newCountFile)) {
                                 ifstream in2;
                                 m->openInputFile(newCountFile, in2);
@@ -562,7 +559,7 @@ int ChimeraPerseusCommand::execute(){
                         numChimeras = deconvoluteResults(uniqueNames, outputFileName, accnosFileName);
                     }else {
                         set<string> doNotRemove;
-                        CountTable c; c.readTable(newCountFile);
+                        CountTable c; c.readTable(newCountFile, true, true);
                         vector<string> namesInTable = c.getNamesOfSeqs();
                         for (int i = 0; i < namesInTable.size(); i++) {
                             int temp = c.getNumSeqs(namesInTable[i]);
@@ -649,6 +646,11 @@ int ChimeraPerseusCommand::execute(){
                if (itTypes != outputTypes.end()) {
                        if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
                }
+        
+        itTypes = outputTypes.find("count");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); }
+               }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -1044,10 +1046,10 @@ int ChimeraPerseusCommand::driver(string chimeraFileName, vector<seqData>& seque
                        }
        
                        //report progress
-                       if((i+1) % 100 == 0){   m->mothurOut("Processing sequence: " + toString(i+1) + "\n");           }
+                       if((i+1) % 100 == 0){   m->mothurOutJustToScreen("Processing sequence: " + toString(i+1) + "\n");               }
                }
                
-               if((numSeqs) % 100 != 0){       m->mothurOut("Processing sequence: " + toString(numSeqs) + "\n");               }
+               if((numSeqs) % 100 != 0){       m->mothurOutJustToScreen("Processing sequence: " + toString(numSeqs) + "\n");           }
                
                chimeraFile.close();
                accnosFile.close();
@@ -1068,36 +1070,39 @@ int ChimeraPerseusCommand::createProcessesGroups(string outputFName, string accn
                int num = 0;
                
         CountTable newCount;
-        if (hasCount && dups) { newCount.readTable(name); }
+        if (hasCount && dups) { newCount.readTable(name, true, false); }
         
                //sanity check
                if (groups.size() < processors) { processors = groups.size(); }
                
                //divide the groups between the processors
                vector<linePair> lines;
-               int numGroupsPerProcessor = groups.size() / processors;
-               for (int i = 0; i < processors; i++) {
-                       int startIndex =  i * numGroupsPerProcessor;
-                       int endIndex = (i+1) * numGroupsPerProcessor;
-                       if(i == (processors - 1)){      endIndex = groups.size();       }
-                       lines.push_back(linePair(startIndex, endIndex));
-               }
+               int remainingPairs = groups.size();
+        int startIndex = 0;
+        for (int remainingProcessors = processors; remainingProcessors > 0; remainingProcessors--) {
+            int numPairs = remainingPairs; //case for last processor
+            if (remainingProcessors != 1) { numPairs = ceil(remainingPairs / remainingProcessors); }
+            lines.push_back(linePair(startIndex, (startIndex+numPairs))); //startIndex, endIndex
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
+        }
+
                
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
                
                //loop through and create all the processes you want
                while (process != processors) {
-                       int pid = fork();
+                       pid_t pid = fork();
                        
                        if (pid > 0) {
                                processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
                                process++;
                        }else if (pid == 0){
-                               num = driverGroups(outputFName + toString(getpid()) + ".temp", accnos + toString(getpid()) + ".temp", accnos + ".byCount." + toString(getpid()) + ".temp", lines[process].start, lines[process].end, groups);
+                               num = driverGroups(outputFName + toString(m->mothurGetpid(process)) + ".temp", accnos + toString(m->mothurGetpid(process)) + ".temp", accnos + ".byCount." + toString(m->mothurGetpid(process)) + ".temp", lines[process].start, lines[process].end, groups);
                                
                                //pass numSeqs to parent
                                ofstream out;
-                               string tempFile = outputFName + toString(getpid()) + ".num.temp";
+                               string tempFile = outputFName + toString(m->mothurGetpid(process)) + ".num.temp";
                                m->openOutputFile(tempFile, out);
                                out << num << endl;
                                out.close();