]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeraslayercommand.cpp
added mothurgetpid function. fixed bug with align.seqs related to g++ 4.8 change...
[mothur.git] / chimeraslayercommand.cpp
index e7003c4d88bfe40266dffcf0770e3037cb39f38f..9a2b249ce213bb97096b94a41bc36d54f9919d30 100644 (file)
@@ -759,7 +759,7 @@ int ChimeraSlayerCommand::execute(){
                                if (processors == 1) {
                     numSeqs = driverGroups(outputFileName, accnosFileName, trimFastaFileName, fileToPriority, fileGroup, newCountFile);
                     if (hasCount && dups) {
-                        CountTable c; c.readTable(nameFileNames[s]);
+                        CountTable c; c.readTable(nameFileNames[s], true, false);
                         if (!m->isBlank(newCountFile)) {
                             ifstream in2;
                             m->openInputFile(newCountFile, in2);
@@ -791,7 +791,7 @@ int ChimeraSlayerCommand::execute(){
                     }else {
                         if (hasCount) {
                             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]);
@@ -868,8 +868,8 @@ int ChimeraSlayerCommand::MPIExecuteGroups(string outputFileName, string accnosF
                map<string, map<string, int> >::iterator itFile;
                vector<string> filenames;
                for(itFile = fileToPriority.begin(); itFile != fileToPriority.end(); itFile++) { filenames.push_back(itFile->first); }
-               
-               int numGroupsPerProcessor = filenames.size() / processors;
+        
+        int numGroupsPerProcessor = ceil(filenames.size() / (double) processors);
                int startIndex =  pid * numGroupsPerProcessor;
                int endIndex = (pid+1) * numGroupsPerProcessor;
                if(pid == (processors - 1)){    endIndex = filenames.size();    }
@@ -1551,7 +1551,7 @@ int ChimeraSlayerCommand::createProcessesGroups(string outputFName, string accno
                if (fileToPriority.size() < processors) { processors = fileToPriority.size(); }
         
         CountTable newCount;
-        if (hasCount && dups) { newCount.readTable(countFile); }
+        if (hasCount && dups) { newCount.readTable(countFile, true, false); }
                
                int groupsPerProcessor = fileToPriority.size() / processors;
                int remainder = fileToPriority.size() % processors;
@@ -1583,11 +1583,11 @@ int ChimeraSlayerCommand::createProcessesGroups(string outputFName, string accno
                                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", fasta + toString(getpid()) + ".temp", breakUp[process], fileGroup, accnos + toString(getpid()) + ".byCount");
+                               num = driverGroups(outputFName + toString(m->mothurGetpid(process)) + ".temp", accnos + m->mothurGetpid(process) + ".temp", fasta + toString(m->mothurGetpid(process)) + ".temp", breakUp[process], fileGroup, accnos + toString(m->mothurGetpid(process)) + ".byCount");
                                
                                //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();
@@ -1714,6 +1714,8 @@ int ChimeraSlayerCommand::createProcessesGroups(string outputFName, string accno
 int ChimeraSlayerCommand::driver(linePair filePos, string outputFName, string filename, string accnos, string fasta, map<string, int>& priority){
        try {
                
+        if (m->debug) { m->mothurOut("[DEBUG]: filename = " + filename + "\n"); }
+        
                Chimera* chimera;
                if (templatefile != "self") { //you want to run slayer with a reference template
                        chimera = new ChimeraSlayer(filename, templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());       
@@ -1998,6 +2000,8 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename
                int process = 0;
                int num = 0;
                processIDS.clear();
+        
+        if (m->debug) { m->mothurOut("[DEBUG]: filename = " + filename + "\n"); }
                
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                //loop through and create all the processes you want
@@ -2008,11 +2012,11 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename
                                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 = driver(lines[process], outputFileName + toString(getpid()) + ".temp", filename, accnos + toString(getpid()) + ".temp", fasta + toString(getpid()) + ".temp", thisPriority);
+                               num = driver(lines[process], outputFileName + toString(m->mothurGetpid(process)) + ".temp", filename, accnos + toString(m->mothurGetpid(process)) + ".temp", fasta + toString(m->mothurGetpid(process)) + ".temp", thisPriority);
                                
                                //pass numSeqs to parent
                                ofstream out;
-                               string tempFile = outputFileName + toString(getpid()) + ".num.temp";
+                               string tempFile = outputFileName + toString(m->mothurGetpid(process)) + ".num.temp";
                                m->openOutputFile(tempFile, out);
                                out << num << endl;
                                out.close();
@@ -2161,7 +2165,7 @@ map<string, int> ChimeraSlayerCommand::sortFastaFile(string fastaFile, string na
         int error;
         if (hasCount) { 
             CountTable ct;
-            ct.readTable(nameFile);
+            ct.readTable(nameFile, true, false);
             
             for(map<string, string>::iterator it = seqs.begin(); it != seqs.end(); it++) {
                 int num = ct.getNumSeqs(it->first);