]> git.donarmstrong.com Git - mothur.git/blobdiff - summarysharedcommand.cpp
removed various build warnings
[mothur.git] / summarysharedcommand.cpp
index 99c62a53c0580d51859673288a7955b7347442ae..029ca26638830f456179f5595b3fd8300f631c70 100644 (file)
 #include "sharedbraycurtis.h"
 #include "sharedjackknife.h"
 #include "whittaker.h"
+#include "odum.h"
+#include "canberra.h"
+#include "structeuclidean.h"
+#include "structchord.h"
+#include "hellinger.h"
+#include "manhattan.h"
+#include "structpearson.h"
+#include "soergel.h"
+#include "spearman.h"
+#include "structkulczynski.h"
+#include "structchi2.h"
+#include "speciesprofile.h"
+#include "hamming.h"
+#include "gower.h"
+#include "memchi2.h"
+#include "memchord.h"
+#include "memeuclidean.h"
+#include "mempearson.h"
 
 //**********************************************************************************************************************
 vector<string> SummarySharedCommand::getValidParameters(){     
@@ -47,6 +65,7 @@ vector<string> SummarySharedCommand::getValidParameters(){
 //**********************************************************************************************************************
 SummarySharedCommand::SummarySharedCommand(){  
        try {
+               abort = true;
                //initialize outputTypes
                vector<string> tempOutNames;
                outputTypes["summary"] = tempOutNames;
@@ -209,6 +228,42 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
                                                        sumCalculators.push_back(new BrayCurtis());
                                                }else if (Estimators[i] == "whittaker") { 
                                                        sumCalculators.push_back(new Whittaker());
+                                               }else if (Estimators[i] == "odum") { 
+                                                       sumCalculators.push_back(new Odum());
+                                               }else if (Estimators[i] == "canberra") { 
+                                                       sumCalculators.push_back(new Canberra());
+                                               }else if (Estimators[i] == "structeuclidean") { 
+                                                       sumCalculators.push_back(new StructEuclidean());
+                                               }else if (Estimators[i] == "structchord") { 
+                                                       sumCalculators.push_back(new StructChord());
+                                               }else if (Estimators[i] == "hellinger") { 
+                                                       sumCalculators.push_back(new Hellinger());
+                                               }else if (Estimators[i] == "manhattan") { 
+                                                       sumCalculators.push_back(new Manhattan());
+                                               }else if (Estimators[i] == "structpearson") { 
+                                                       sumCalculators.push_back(new StructPearson());
+                                               }else if (Estimators[i] == "soergel") { 
+                                                       sumCalculators.push_back(new Soergel());
+                                               }else if (Estimators[i] == "spearman") { 
+                                                       sumCalculators.push_back(new Spearman());
+                                               }else if (Estimators[i] == "structkulczynski") { 
+                                                       sumCalculators.push_back(new StructKulczynski());
+                                               }else if (Estimators[i] == "speciesprofile") { 
+                                                       sumCalculators.push_back(new SpeciesProfile());
+                                               }else if (Estimators[i] == "hamming") { 
+                                                       sumCalculators.push_back(new Hamming());
+                                               }else if (Estimators[i] == "structchi2") { 
+                                                       sumCalculators.push_back(new StructChi2());
+                                               }else if (Estimators[i] == "gower") { 
+                                                       sumCalculators.push_back(new Gower());
+                                               }else if (Estimators[i] == "memchi2") { 
+                                                       sumCalculators.push_back(new MemChi2());
+                                               }else if (Estimators[i] == "memchord") { 
+                                                       sumCalculators.push_back(new MemChord());
+                                               }else if (Estimators[i] == "memeuclidean") { 
+                                                       sumCalculators.push_back(new MemEuclidean());
+                                               }else if (Estimators[i] == "mempearson") { 
+                                                       sumCalculators.push_back(new MemPearson());
                                                }
                                        }
                                }
@@ -228,13 +283,14 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
 void SummarySharedCommand::help(){
        try {
                m->mothurOut("The summary.shared command can only be executed after a successful read.otu command.\n");
-               m->mothurOut("The summary.shared command parameters are label, calc and all.  No parameters are required.\n");
+               m->mothurOut("The summary.shared command parameters are label, calc, distance and all.  No parameters are required.\n");
                m->mothurOut("The summary.shared command should be in the following format: \n");
                m->mothurOut("summary.shared(label=yourLabel, calc=yourEstimators, groups=yourGroups).\n");
                m->mothurOut("Example summary.shared(label=unique-.01-.03, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n");
                validCalculator->printCalc("sharedsummary", cout);
                m->mothurOut("The default value for calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan\n");
                m->mothurOut("The default value for groups is all the groups in your groupfile.\n");
+               m->mothurOut("The distance parameter allows you to indicate you would like a distance file created for each calculator for each label, default=f.\n");
                m->mothurOut("The label parameter is used to analyze specific labels in your input.\n");
                m->mothurOut("The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n");
                m->mothurOut("If you use sharedchao and run into memory issues, set all to false. \n");
@@ -506,7 +562,11 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string
                                                        }
                                                        
                                                        exit(0);
-                                               }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
+                                               }else { 
+                                                       m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
+                                                       for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
+                                                       exit(0);
+                                               }
                                        }
                                        
                                        //parent do your part
@@ -605,6 +665,7 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string
                                        outDist.close();
                                }
                        }
+               return 0;
        }
        catch(exception& e) {
                m->errorOut(e, "SummarySharedCommand", "process");
@@ -667,7 +728,15 @@ int SummarySharedCommand::driver(vector<SharedRAbundVector*> thisLookup, int sta
                                }
                                
                                for(int i=0;i<sumCalculators.size();i++) {
-
+                                       
+                                       //if this calc needs all groups to calculate the pair load all groups
+                                       if (sumCalculators[i]->getNeedsAll()) { 
+                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                               for (int w = 0; w < thisLookup.size(); w++) {
+                                                       if ((w != k) && (w != l)) { subset.push_back(thisLookup[w]); }
+                                               }
+                                       }
+                                       
                                        vector<double> tempdata = sumCalculators[i]->getValues(subset); //saves the calculator outputs
                                        
                                        if (m->control_pressed) { outputFileHandle.close(); return 1; }