]> git.donarmstrong.com Git - mothur.git/commitdiff
added rjsd calculator. improved work balance load between processors for paralellize...
authorSarah Westcott <mothur.westcott@gmail.com>
Tue, 21 Jan 2014 20:26:12 +0000 (15:26 -0500)
committerSarah Westcott <mothur.westcott@gmail.com>
Tue, 21 Jan 2014 20:26:12 +0000 (15:26 -0500)
21 files changed:
Mothur.xcodeproj/project.pbxproj
chimeraperseuscommand.cpp
chimeraslayercommand.cpp
chimerauchimecommand.cpp
collectsharedcommand.cpp
getmetacommunitycommand.cpp
getmetacommunitycommand.h
matrixoutputcommand.cpp
matrixoutputcommand.h
metastatscommand.cpp
parsimony.cpp
preclustercommand.cpp
sharedrjsd.cpp [new file with mode: 0644]
sharedrjsd.h [new file with mode: 0644]
shhhseqscommand.cpp
summarysharedcommand.cpp
summarysharedcommand.h
unifracweightedcommand.cpp
unweighted.cpp
validcalculator.cpp
weighted.cpp

index 26456a3ee2c230477db7c945e2b9586dc45aea8d..f0a56a370af8b2584d46caf6cdb97bd155a30efa 100644 (file)
@@ -9,6 +9,7 @@
 /* Begin PBXBuildFile section */
                219C1DE01552C4BD004209F9 /* newcommandtemplate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DDF1552C4BD004209F9 /* newcommandtemplate.cpp */; };
                219C1DE41559BCCF004209F9 /* getcoremicrobiomecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DE31559BCCD004209F9 /* getcoremicrobiomecommand.cpp */; };
 /* Begin PBXBuildFile section */
                219C1DE01552C4BD004209F9 /* newcommandtemplate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DDF1552C4BD004209F9 /* newcommandtemplate.cpp */; };
                219C1DE41559BCCF004209F9 /* getcoremicrobiomecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DE31559BCCD004209F9 /* getcoremicrobiomecommand.cpp */; };
+               483C952E188F0CAD0035E7B7 /* sharedrjsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 483C952D188F0CAD0035E7B7 /* sharedrjsd.cpp */; };
                7E6BE10A12F710D8007ADDBE /* refchimeratest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */; };
                834D9D581656D7C400E7FAB9 /* regularizedrandomforest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834D9D561656D7C400E7FAB9 /* regularizedrandomforest.cpp */; };
                834D9D5C1656DEC800E7FAB9 /* regularizeddecisiontree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834D9D5A1656DEC700E7FAB9 /* regularizeddecisiontree.cpp */; };
                7E6BE10A12F710D8007ADDBE /* refchimeratest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */; };
                834D9D581656D7C400E7FAB9 /* regularizedrandomforest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834D9D561656D7C400E7FAB9 /* regularizedrandomforest.cpp */; };
                834D9D5C1656DEC800E7FAB9 /* regularizeddecisiontree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 834D9D5A1656DEC700E7FAB9 /* regularizeddecisiontree.cpp */; };
                219C1DE11552C508004209F9 /* newcommandtemplate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = newcommandtemplate.h; sourceTree = "<group>"; };
                219C1DE31559BCCD004209F9 /* getcoremicrobiomecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcoremicrobiomecommand.cpp; sourceTree = "<group>"; };
                219C1DE51559BCF2004209F9 /* getcoremicrobiomecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getcoremicrobiomecommand.h; sourceTree = "<group>"; };
                219C1DE11552C508004209F9 /* newcommandtemplate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = newcommandtemplate.h; sourceTree = "<group>"; };
                219C1DE31559BCCD004209F9 /* getcoremicrobiomecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcoremicrobiomecommand.cpp; sourceTree = "<group>"; };
                219C1DE51559BCF2004209F9 /* getcoremicrobiomecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getcoremicrobiomecommand.h; sourceTree = "<group>"; };
+               483C952C188F0C960035E7B7 /* sharedrjsd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sharedrjsd.h; sourceTree = "<group>"; };
+               483C952D188F0CAD0035E7B7 /* sharedrjsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedrjsd.cpp; sourceTree = "<group>"; };
                7E6BE10812F710D8007ADDBE /* refchimeratest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = refchimeratest.h; sourceTree = "<group>"; };
                7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = refchimeratest.cpp; sourceTree = "<group>"; };
                7E78911B135F3E8600E725D2 /* eachgapdistignorens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdistignorens.h; sourceTree = "<group>"; };
                7E6BE10812F710D8007ADDBE /* refchimeratest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = refchimeratest.h; sourceTree = "<group>"; };
                7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = refchimeratest.cpp; sourceTree = "<group>"; };
                7E78911B135F3E8600E725D2 /* eachgapdistignorens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdistignorens.h; sourceTree = "<group>"; };
                                A7E9B7FB12D37EC400DA6239 /* sharedjest.h */,
                                A7222D711856276C0055A993 /* sharedjsd.h */,
                                A7222D721856277C0055A993 /* sharedjsd.cpp */,
                                A7E9B7FB12D37EC400DA6239 /* sharedjest.h */,
                                A7222D711856276C0055A993 /* sharedjsd.h */,
                                A7222D721856277C0055A993 /* sharedjsd.cpp */,
+                               483C952C188F0C960035E7B7 /* sharedrjsd.h */,
+                               483C952D188F0CAD0035E7B7 /* sharedrjsd.cpp */,
                                A7E9B7FC12D37EC400DA6239 /* sharedkstest.cpp */,
                                A7E9B7FD12D37EC400DA6239 /* sharedkstest.h */,
                                A7E9B7FE12D37EC400DA6239 /* sharedkulczynski.cpp */,
                                A7E9B7FC12D37EC400DA6239 /* sharedkstest.cpp */,
                                A7E9B7FD12D37EC400DA6239 /* sharedkstest.h */,
                                A7E9B7FE12D37EC400DA6239 /* sharedkulczynski.cpp */,
                                A7E9B94112D37EC400DA6239 /* setlogfilecommand.cpp in Sources */,
                                A7E9B94212D37EC400DA6239 /* sffinfocommand.cpp in Sources */,
                                A7E9B94312D37EC400DA6239 /* shannon.cpp in Sources */,
                                A7E9B94112D37EC400DA6239 /* setlogfilecommand.cpp in Sources */,
                                A7E9B94212D37EC400DA6239 /* sffinfocommand.cpp in Sources */,
                                A7E9B94312D37EC400DA6239 /* shannon.cpp in Sources */,
+                               483C952E188F0CAD0035E7B7 /* sharedrjsd.cpp in Sources */,
                                A7E9B94412D37EC400DA6239 /* shannoneven.cpp in Sources */,
                                A7E9B94512D37EC400DA6239 /* sharedace.cpp in Sources */,
                                A7E9B94612D37EC400DA6239 /* sharedanderbergs.cpp in Sources */,
                                A7E9B94412D37EC400DA6239 /* shannoneven.cpp in Sources */,
                                A7E9B94512D37EC400DA6239 /* sharedace.cpp in Sources */,
                                A7E9B94612D37EC400DA6239 /* sharedanderbergs.cpp in Sources */,
index 0547802198960198d9d2a063bc498e79f04bfe33..b8d70c1b4c623c5a433da7334219af49a87fac00 100644 (file)
@@ -1077,13 +1077,16 @@ int ChimeraPerseusCommand::createProcessesGroups(string outputFName, string accn
                
                //divide the groups between the processors
                vector<linePair> lines;
                
                //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)         
                
                
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
                
index 41661da085060fcd66913f31764232dbbacce342..e7dc92e5919d1f5f7078fd5a11171cbb39030861 100644 (file)
@@ -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); }
                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();    }
                int startIndex =  pid * numGroupsPerProcessor;
                int endIndex = (pid+1) * numGroupsPerProcessor;
                if(pid == (processors - 1)){    endIndex = filenames.size();    }
index 3a9f42b22e0715ccf1f68313439342269da81bf8..7a48cf70d092f7d05c8b3bc3656bd66bf17c02d8 100644 (file)
@@ -1803,14 +1803,16 @@ int ChimeraUchimeCommand::createProcessesGroups(string outputFName, string filen
                
                //divide the groups between the processors
                vector<linePair> lines;
                
                //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
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
                                
                //loop through and create all the processes you want
index 56e60d88bc88200a1b21d82d70b4a9c1f22ebdef..966cc253552068ad1945a19e1aaaedfd9b3da506 100644 (file)
@@ -50,6 +50,7 @@
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
+#include "sharedrjsd.h"
 
 
 //**********************************************************************************************************************
 
 
 //**********************************************************************************************************************
@@ -58,7 +59,7 @@ vector<string> CollectSharedCommand::setParameters(){
                CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pshared);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
                CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
                CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pshared);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
                CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson-jsd", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson-jsd-rjsd", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc);
                CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall);
                CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
                CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
                CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall);
                CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
                CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
@@ -143,6 +144,7 @@ string CollectSharedCommand::getOutputPattern(string type) {
         else if (type == "memeuclidean")        {  pattern =  "[filename],memeuclidean";    }
         else if (type == "mempearson")          {  pattern =  "[filename],mempearson";      }
         else if (type == "jsd")                 {  pattern =  "[filename],jsd";             }
         else if (type == "memeuclidean")        {  pattern =  "[filename],memeuclidean";    }
         else if (type == "mempearson")          {  pattern =  "[filename],mempearson";      }
         else if (type == "jsd")                 {  pattern =  "[filename],jsd";             }
+        else if (type == "rjsd")                 {  pattern =  "[filename],rjsd";             }
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         
         return pattern;
         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         
         return pattern;
@@ -199,6 +201,7 @@ CollectSharedCommand::CollectSharedCommand(){
                outputTypes["memeuclidean"] = tempOutNames;
                outputTypes["mempearson"] = tempOutNames;
         outputTypes["jsd"] = tempOutNames;
                outputTypes["memeuclidean"] = tempOutNames;
                outputTypes["mempearson"] = tempOutNames;
         outputTypes["jsd"] = tempOutNames;
+        outputTypes["rjsd"] = tempOutNames;
                
        }
        catch(exception& e) {
                
        }
        catch(exception& e) {
@@ -272,6 +275,7 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        outputTypes["memeuclidean"] = tempOutNames;
                        outputTypes["mempearson"] = tempOutNames;
             outputTypes["jsd"] = tempOutNames;
                        outputTypes["memeuclidean"] = tempOutNames;
                        outputTypes["mempearson"] = tempOutNames;
             outputTypes["jsd"] = tempOutNames;
+            outputTypes["rjsd"] = tempOutNames;
                        
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -467,7 +471,11 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                                }else if (Estimators[i] == "jsd") {
                                                        cDisplays.push_back(new CollectDisplay(new JSD(), new SharedOneColumnFile(getOutputFileName("jsd", variables))));
                                                        outputNames.push_back(getOutputFileName("jsd", variables)); outputTypes["jsd"].push_back(getOutputFileName("jsd", variables));
                                                }else if (Estimators[i] == "jsd") {
                                                        cDisplays.push_back(new CollectDisplay(new JSD(), new SharedOneColumnFile(getOutputFileName("jsd", variables))));
                                                        outputNames.push_back(getOutputFileName("jsd", variables)); outputTypes["jsd"].push_back(getOutputFileName("jsd", variables));
+                                               }else if (Estimators[i] == "rjsd") {
+                                                       cDisplays.push_back(new CollectDisplay(new RJSD(), new SharedOneColumnFile(getOutputFileName("rjsd", variables))));
+                                                       outputNames.push_back(getOutputFileName("rjsd", variables)); outputTypes["rjsd"].push_back(getOutputFileName("rjsd", variables));
                                                }
                                                }
+
                                                
                                        }
                                }       
                                                
                                        }
                                }       
index b3160749e9031072ceafdea29b92a33a2909cff6..de59edf5204e20ab3c3541b767e50b91cbe5df64 100644 (file)
@@ -18,7 +18,7 @@ vector<string> GetMetaCommunityCommand::setParameters(){
         CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","outputType",false,true); parameters.push_back(pshared);
         CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
         CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","outputType",false,true); parameters.push_back(pshared);
         CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
-        CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson-jsd", "jsd", "", "", "","",false,false,true); parameters.push_back(pcalc);
+        CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson-jsd-rjsd", "rjsd", "", "", "","",false,false,true); parameters.push_back(pcalc);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
         CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
         CommandParameter pminpartitions("minpartitions", "Number", "", "5", "", "", "","",false,false,true); parameters.push_back(pminpartitions);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
         CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
         CommandParameter pminpartitions("minpartitions", "Number", "", "5", "", "", "","",false,false,true); parameters.push_back(pminpartitions);
@@ -190,9 +190,9 @@ GetMetaCommunityCommand::GetMetaCommunityCommand(string option)  {
                        else { m->mothurOut("[ERROR]: " + method + " is not a valid method.  Valid algorithms are dmm, kmeans and pam."); m->mothurOutEndLine(); abort = true; }
             
             calc = validParameter.validFile(parameters, "calc", false);
                        else { m->mothurOut("[ERROR]: " + method + " is not a valid method.  Valid algorithms are dmm, kmeans and pam."); m->mothurOutEndLine(); abort = true; }
             
             calc = validParameter.validFile(parameters, "calc", false);
-                       if (calc == "not found") { calc = "jsd";  }
+                       if (calc == "not found") { calc = "rjsd";  }
                        else {
                        else {
-                if (calc == "default")  {  calc = "jsd";  }
+                if (calc == "default")  {  calc = "rjsd";  }
                        }
                        m->splitAtDash(calc, Estimators);
                        if (m->inUsersGroups("citation", Estimators)) {
                        }
                        m->splitAtDash(calc, Estimators);
                        if (m->inUsersGroups("citation", Estimators)) {
@@ -961,6 +961,8 @@ vector<vector<double> > GetMetaCommunityCommand::generateDistanceMatrix(vector<S
                 matrixCalculator = new MemPearson();
             }else if (Estimators[i] == "jsd") {
                 matrixCalculator = new JSD();
                 matrixCalculator = new MemPearson();
             }else if (Estimators[i] == "jsd") {
                 matrixCalculator = new JSD();
+            }else if (Estimators[i] == "rjsd") {
+                matrixCalculator = new RJSD();
             }else {
                 m->mothurOut("[ERROR]: " + Estimators[i] + " is not a valid calculator, please correct.\n"); m->control_pressed = true; return results;
             }
             }else {
                 m->mothurOut("[ERROR]: " + Estimators[i] + " is not a valid calculator, please correct.\n"); m->control_pressed = true; return results;
             }
index 9c17e4d2eb844e6a2eb1c7b6bfee0bf96910ded4..d84a65d640605734b51efd9dd32a4e78e4038e48 100644 (file)
@@ -55,6 +55,7 @@
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
+#include "sharedrjsd.h"
 
 /**************************************************************************************************/
 
 
 /**************************************************************************************************/
 
index 8a7656cee9cda0086fd2aaedd1afd5fb27896952..2e6943f0eb7aed1c0b881b5dd5a5d079cdd4fb87 100644 (file)
@@ -17,7 +17,7 @@ vector<string> MatrixOutputCommand::setParameters(){
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
                CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
                CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
-               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson-jsd", "jclass-thetayc", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson-jsd-rjsd", "jclass-thetayc", "", "", "","",true,false,true); parameters.push_back(pcalc);
                CommandParameter poutput("output", "Multiple", "lt-square-column", "lt", "", "", "","",false,false); parameters.push_back(poutput);
         CommandParameter pmode("mode", "Multiple", "average-median", "average", "", "", "","",false,false); parameters.push_back(pmode);
                CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
                CommandParameter poutput("output", "Multiple", "lt-square-column", "lt", "", "", "","",false,false); parameters.push_back(poutput);
         CommandParameter pmode("mode", "Multiple", "average-median", "average", "", "", "","",false,false); parameters.push_back(pmode);
                CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
@@ -283,7 +283,8 @@ MatrixOutputCommand::MatrixOutputCommand(string option)  {
                                                        matrixCalculators.push_back(new MemPearson());
                         }else if (Estimators[i] == "jsd") {
                                 matrixCalculators.push_back(new JSD());
                                                        matrixCalculators.push_back(new MemPearson());
                         }else if (Estimators[i] == "jsd") {
                                 matrixCalculators.push_back(new JSD());
-
+                        }else if (Estimators[i] == "rjsd") {
+                            matrixCalculators.push_back(new RJSD());
                                                }
                                        }
                                }
                                                }
                                        }
                                }
index 5ddfb2c1c788e2d09f0f7ffcf4658a04f9e79c47..a19ffc813945e7d8b9ead51a716149881091ad2f 100644 (file)
@@ -55,6 +55,7 @@
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
+#include "sharedrjsd.h"
 
 
 // aka. dist.shared()
 
 
 // aka. dist.shared()
@@ -227,6 +228,8 @@ static DWORD WINAPI MyDistSharedThreadFunction(LPVOID lpParam){
                     matrixCalculators.push_back(new MemPearson());
                 }else if (pDataArray->Estimators[i] == "jsd") {
                     matrixCalculators.push_back(new JSD());
                     matrixCalculators.push_back(new MemPearson());
                 }else if (pDataArray->Estimators[i] == "jsd") {
                     matrixCalculators.push_back(new JSD());
+                }else if (pDataArray->Estimators[i] == "rjsd") {
+                    matrixCalculators.push_back(new RJSD());
                 }
 
             }
                 }
 
             }
index de9e373194b30bc97a2afbeceb49b5303aa66de3..de03dab2a147174384d3e3ffce329c1e16fa07f5 100644 (file)
@@ -256,15 +256,14 @@ int MetaStatsCommand::execute(){
                else if (numGroups < 2) { m->mothurOut("Not enough sets, I need at least 2 valid sets. Unable to complete command."); m->mothurOutEndLine(); m->control_pressed = true; }
 
         if(processors != 1){
                else if (numGroups < 2) { m->mothurOut("Not enough sets, I need at least 2 valid sets. Unable to complete command."); m->mothurOutEndLine(); m->control_pressed = true; }
 
         if(processors != 1){
-            int numPairs = namesOfGroupCombos.size();
-            int numPairsPerProcessor = numPairs / processors;
-                       
-            for (int i = 0; i < processors; i++) {
-                int startPos = i * numPairsPerProcessor;
-                if(i == processors - 1){
-                    numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                }
-                lines.push_back(linePair(startPos, numPairsPerProcessor));
+            int remainingPairs = namesOfGroupCombos.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, numPairs)); //startIndex, numPairs
+                startIndex = startIndex + numPairs;
+                remainingPairs = remainingPairs - numPairs;
             }
         }
                
             }
         }
                
index b12ca1fe742240a4c80e96d0d82bcb2ef612fa18..1b08e8a3fe8470e5d34944722e186fdca7e0731b 100644 (file)
@@ -56,13 +56,14 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) {
                }
         
         lines.clear();
                }
         
         lines.clear();
-        int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
-        
-        for (int i = 0; i < processors; i++) {
-            int startPos = i * numPairsPerProcessor;
-            if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
-            lines.push_back(linePair(startPos, numPairsPerProcessor));
+        int remainingPairs = namesOfGroupCombos.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, numPairs)); //startIndex, numPairs
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);
index fe722a669f2c0ca983c94ef21cc73dc95f5719bc..05c8b7d42a1ba7de160449f02707097800357bea 100644 (file)
@@ -369,13 +369,15 @@ int PreClusterCommand::createProcessesGroups(string newFName, string newNName, s
                
                //divide the groups between the processors
                vector<linePair> lines;
                
                //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)         
                
                
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
                
diff --git a/sharedrjsd.cpp b/sharedrjsd.cpp
new file mode 100644 (file)
index 0000000..4699054
--- /dev/null
@@ -0,0 +1,59 @@
+//
+//  sharedrjsd.cpp
+//  Mothur
+//
+//  Created by Sarah Westcott on 1/21/14.
+//  Copyright (c) 2014 Schloss Lab. All rights reserved.
+//
+
+#include "sharedrjsd.h"
+
+/***********************************************************************/
+//KLD <- function(x,y) sum(x *log(x/y))
+//JSD<- function(x,y) sqrt(0.5 * KLD(x, (x+y)/2) + 0.5 * KLD(y, (x+y)/2))
+EstOutput RJSD::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+        
+               data.resize(1,0);
+        
+        double KLD1 = 0.0;
+        double KLD2 = 0.0;
+        
+        vector<int> countA = shared[0]->getAbundances();
+        vector<int> countB = shared[1]->getAbundances();
+        double totalA = 0;
+        double totalB = 0;
+        
+               for (int i = 0; i < shared[0]->getNumBins(); i++) {
+            totalA += countA[i];
+            totalB += countB[i];
+        }
+        
+        for (int i = 0; i < shared[0]->getNumBins(); i++) {
+            double tempA = countA[i] / totalA;
+            double tempB = countB[i] / totalB;
+            
+            tempA = countA[i] / totalA;
+            tempB = countB[i] / totalB;
+            
+            if (tempA == 0) { tempA = 0.000001; }
+            if (tempB == 0) { tempB = 0.000001; }
+            
+            double denom = (tempA+tempB)/(double)2.0;
+            
+            if (tempA != 0) {  KLD1 += tempA * log(tempA/denom); } //KLD(x,m)
+            if (tempB != 0) {  KLD2 += tempB * log(tempB/denom); } //KLD(y,m)
+            
+        }
+        
+        data[0] = sqrt((0.5*KLD1) + (0.5*KLD2));
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RJSD", "getValues");
+               exit(1);
+       }
+}
diff --git a/sharedrjsd.h b/sharedrjsd.h
new file mode 100644 (file)
index 0000000..9c98696
--- /dev/null
@@ -0,0 +1,31 @@
+//
+//  sharedrjsd.h
+//  Mothur
+//
+//  Created by Sarah Westcott on 1/21/14.
+//  Copyright (c) 2014 Schloss Lab. All rights reserved.
+//
+
+#ifndef Mothur_sharedrjsd_h
+#define Mothur_sharedrjsd_h
+
+#include "calculator.h"
+
+/***********************************************************************/
+//Jensen-Shannon divergence (JSD)
+class RJSD : public Calculator  {
+       
+public:
+       RJSD() :  Calculator("rjsd", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+       string getCitation() { return "http://www.mothur.org/wiki/RJSD"; }
+private:
+       
+};
+
+/***********************************************************************/
+
+
+
+#endif
index 82d956189a6f025fd57dc7e901e585456f59f8ab..0cc6eb4d24d8a963b87ae58012f341d6e0c47e79 100644 (file)
@@ -377,13 +377,16 @@ vector<string> ShhhSeqsCommand::createProcessesGroups(SequenceParser& parser, st
                
                //divide the groups between the processors
                vector<linePair> lines;
                
                //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)         
                
                
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
                
index ef5e365fdfa8c356c3951c1dae74ae02bf41b978..59c12a03dae958f4bb199a6aad94056264c0426a 100644 (file)
@@ -17,7 +17,7 @@ vector<string> SummarySharedCommand::setParameters(){
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","phylip",false,false); parameters.push_back(psubsample);
                CommandParameter pdistance("distance", "Boolean", "", "F", "", "", "","phylip",false,false); parameters.push_back(pdistance);
                CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
         CommandParameter psubsample("subsample", "String", "", "", "", "", "","phylip",false,false); parameters.push_back(psubsample);
                CommandParameter pdistance("distance", "Boolean", "", "F", "", "", "","phylip",false,false); parameters.push_back(pdistance);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson-jsd", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson-jsd-rjsd", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc);
         CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "","",false,false); parameters.push_back(poutput);
                CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall);
         CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
         CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "","",false,false); parameters.push_back(poutput);
                CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall);
         CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
@@ -296,6 +296,8 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
                                                        sumCalculators.push_back(new MemPearson());
                                                }else if (Estimators[i] == "jsd") {
                                                        sumCalculators.push_back(new JSD());
                                                        sumCalculators.push_back(new MemPearson());
                                                }else if (Estimators[i] == "jsd") {
                                                        sumCalculators.push_back(new JSD());
+                                               }else if (Estimators[i] == "rjsd") {
+                                                       sumCalculators.push_back(new RJSD());
                                                }
                                        }
                                }
                                                }
                                        }
                                }
index 1b3f16469bfc64345631f489e4c6651895041de0..7a2a1909368fc9c71edbcbc90add7d3a966ac95d 100644 (file)
@@ -57,6 +57,7 @@
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
 #include "memeuclidean.h"
 #include "mempearson.h"
 #include "sharedjsd.h"
+#include "sharedrjsd.h"
 
 class SummarySharedCommand : public Command {
 
 
 class SummarySharedCommand : public Command {
 
@@ -219,6 +220,8 @@ static DWORD WINAPI MySummarySharedThreadFunction(LPVOID lpParam){
                     sumCalculators.push_back(new MemPearson());
                 }else if (pDataArray->Estimators[i] == "jsd") {
                     sumCalculators.push_back(new JSD());
                     sumCalculators.push_back(new MemPearson());
                 }else if (pDataArray->Estimators[i] == "jsd") {
                     sumCalculators.push_back(new JSD());
+                }else if (pDataArray->Estimators[i] == "rjsd") {
+                    sumCalculators.push_back(new RJSD());
                 }
             }
         }
                 }
             }
         }
index 4883c48741717c677641c6b48bf7fe4ada0245f1..1c146ac4d1b1168093cc6df20a8d37a930e1d56b 100644 (file)
@@ -699,14 +699,16 @@ int UnifracWeightedCommand::runRandomCalcs(Tree* thisTree, vector<double> usersS
         lines.clear();
         
         //breakdown work between processors
         lines.clear();
         
         //breakdown work between processors
-        int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
-            
-        for (int i = 0; i < processors; i++) {
-            int startPos = i * numPairsPerProcessor;
-            if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
-            lines.push_back(linePair(startPos, numPairsPerProcessor));
+        int remainingPairs = namesOfGroupCombos.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, numPairs)); //startIndex, numPairs
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
         }
         }
+
         
         
         //get scores for random trees
         
         
         //get scores for random trees
index a845f9bc2fa54a5c27b0d74aed20929f1aeb756f..8fbd9d2fd64a90504e083f62418a54c40e8e26e1 100644 (file)
@@ -51,13 +51,14 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) {
                }
         
         lines.clear();
                }
         
         lines.clear();
-        int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
-        
-        for (int i = 0; i < processors; i++) {
-            int startPos = i * numPairsPerProcessor;
-            if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
-            lines.push_back(linePair(startPos, numPairsPerProcessor));
+        int remainingPairs = namesOfGroupCombos.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, numPairs)); //startIndex, numPairs
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);
@@ -316,7 +317,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st
      
         lines.clear();
         int numPairs = namesOfGroupCombos.size();
      
         lines.clear();
         int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
+        int numPairsPerProcessor = ceil(numPairs / processors);
      
         for (int i = 0; i < processors; i++) {
             int startPos = i * numPairsPerProcessor;
      
         for (int i = 0; i < processors; i++) {
             int startPos = i * numPairsPerProcessor;
index 4718e2ff89f96a28013a19dc1ca2f51ae93d924e..98f0d9a2a83f4a5c903756e454cd006354ca721d 100644 (file)
@@ -77,6 +77,7 @@
 #include "sharedsobs.h"
 #include "sharednseqs.h"
 #include "sharedjsd.h"
 #include "sharedsobs.h"
 #include "sharednseqs.h"
 #include "sharedjsd.h"
+#include "sharedrjsd.h"
 
 
 /********************************************************************/
 
 
 /********************************************************************/
@@ -208,6 +209,7 @@ void ValidCalculators::printCitations(vector<string> Estimators) {
                                }else if (Estimators[i] == "sharedobserved") { Calculator* temp = new SharedSobs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
                                }else if (Estimators[i] == "kulczynski") { Calculator* temp = new Kulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
                 }else if (Estimators[i] == "jsd") { Calculator* temp = new JSD(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
                                }else if (Estimators[i] == "sharedobserved") { Calculator* temp = new SharedSobs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
                                }else if (Estimators[i] == "kulczynski") { Calculator* temp = new Kulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
                 }else if (Estimators[i] == "jsd") { Calculator* temp = new JSD(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
+                }else if (Estimators[i] == "rjsd") { Calculator* temp = new RJSD(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
                                }else { m->mothurOut("[ERROR]: Missing else if for " + Estimators[i] + " in printCitations."); m->mothurOutEndLine(); }
                        }else { m->mothurOut(Estimators[i] + " is not a valid calculator, no citation will be given."); m->mothurOutEndLine(); }
                }
                                }else { m->mothurOut("[ERROR]: Missing else if for " + Estimators[i] + " in printCitations."); m->mothurOutEndLine(); }
                        }else { m->mothurOut(Estimators[i] + " is not a valid calculator, no citation will be given."); m->mothurOutEndLine(); }
                }
@@ -458,7 +460,8 @@ void ValidCalculators::initialShared() {
                shared["memchord"]                              = "memchord";
                shared["memeuclidean"]                  = "memeuclidean";
                shared["mempearson"]                    = "mempearson";
                shared["memchord"]                              = "memchord";
                shared["memeuclidean"]                  = "memeuclidean";
                shared["mempearson"]                    = "mempearson";
-        shared["jsd"]                          = "jsd";
+        shared["jsd"]                   = "jsd";
+        shared["rjsd"]                  = "rjsd";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -572,7 +575,8 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["memchord"]                               = "memchord";
                sharedsummary["memeuclidean"]                   = "memeuclidean";
                sharedsummary["mempearson"]                             = "mempearson";
                sharedsummary["memchord"]                               = "memchord";
                sharedsummary["memeuclidean"]                   = "memeuclidean";
                sharedsummary["mempearson"]                             = "mempearson";
-        sharedsummary["jsd"]                           = "jsd";
+        sharedsummary["jsd"]                    = "jsd";
+        sharedsummary["rjsd"]                   = "rjsd";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
@@ -730,14 +734,15 @@ void ValidCalculators::initialMatrix() {
                matrix["structchi2"]                            = "structchi2";
                matrix["soergel"]                               = "soergel";
                matrix["spearman"]                              = "spearman";
                matrix["structchi2"]                            = "structchi2";
                matrix["soergel"]                               = "soergel";
                matrix["spearman"]                              = "spearman";
-               matrix["speciesprofile"]                        = "speciesprofile";
+               matrix["speciesprofile"]                = "speciesprofile";
                matrix["hamming"]                               = "hamming";
                matrix["gower"]                                 = "gower";
                matrix["memchi2"]                               = "memchi2";
                matrix["memchord"]                              = "memchord";
                matrix["memeuclidean"]                  = "memeuclidean";
                matrix["hamming"]                               = "hamming";
                matrix["gower"]                                 = "gower";
                matrix["memchi2"]                               = "memchi2";
                matrix["memchord"]                              = "memchord";
                matrix["memeuclidean"]                  = "memeuclidean";
-               matrix["mempearson"]                            = "mempearson";
-        matrix["jsd"]                          = "jsd";
+               matrix["mempearson"]                    = "mempearson";
+        matrix["rjsd"]                   = "rjsd";
+        matrix["jsd"]                   = "jsd";
                
        }
        catch(exception& e) {
                
        }
        catch(exception& e) {
index b0d06fb0078e0201975e7738d1321e7932230253..49bf6bf1fd2a2053ed7f3f7e0ea30fb5595400a0 100644 (file)
@@ -36,13 +36,14 @@ EstOutput Weighted::getValues(Tree* t, int p, string o) {
                        }
                }
                
                        }
                }
                
-        int numPairs = namesOfGroupCombos.size();
-        int numPairsPerProcessor = numPairs / processors;
-        
-        for (int i = 0; i < processors; i++) {
-            int startPos = i * numPairsPerProcessor;
-            if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; }
-            lines.push_back(linePair(startPos, numPairsPerProcessor));
+        int remainingPairs = namesOfGroupCombos.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, numPairs)); //startIndex, numPairs
+            startIndex = startIndex + numPairs;
+            remainingPairs = remainingPairs - numPairs;
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);
         }
         
         data = createProcesses(t, namesOfGroupCombos, ct);