]> git.donarmstrong.com Git - mothur.git/blobdiff - collectsharedcommand.cpp
working on anosim command
[mothur.git] / collectsharedcommand.cpp
index d63930d071da178e5ddcfdb82950ae37b03718cd..21695e328c90590572a9efebc7caf562c2525c75 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> CollectSharedCommand::getValidParameters(){     
@@ -71,8 +88,7 @@ vector<string> CollectSharedCommand::getRequiredFiles(){
 //**********************************************************************************************************************
 CollectSharedCommand::CollectSharedCommand(){  
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["sharedchao"] = tempOutNames;
                outputTypes["sharedsobs"] = tempOutNames;
@@ -95,6 +111,24 @@ CollectSharedCommand::CollectSharedCommand(){
                outputTypes["lennon"] = tempOutNames;
                outputTypes["morisitahorn"] = tempOutNames;
                outputTypes["braycurtis"] = tempOutNames;
+               outputTypes["odum"] = tempOutNames;
+               outputTypes["canberra"] = tempOutNames;
+               outputTypes["structeuclidean"] = tempOutNames;
+               outputTypes["structchord"] = tempOutNames;
+               outputTypes["hellinger"] = tempOutNames;
+               outputTypes["manhattan"] = tempOutNames;
+               outputTypes["structpearson"] = tempOutNames;
+               outputTypes["soergel"] = tempOutNames;
+               outputTypes["spearman"] = tempOutNames;
+               outputTypes["structkulczynski"] = tempOutNames;
+               outputTypes["structchi2"] = tempOutNames;
+               outputTypes["speciesprofile"] = tempOutNames;
+               outputTypes["hamming"] = tempOutNames;
+               outputTypes["gower"] = tempOutNames;
+               outputTypes["memchi2"] = tempOutNames;
+               outputTypes["memchord"] = tempOutNames;
+               outputTypes["memeuclidean"] = tempOutNames;
+               outputTypes["mempearson"] = tempOutNames;
                
        }
        catch(exception& e) {
@@ -106,14 +140,14 @@ CollectSharedCommand::CollectSharedCommand(){
 CollectSharedCommand::CollectSharedCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
-               abort = false;
+               abort = false; calledHelp = false;   
                allLines = 1;
                labels.clear();
                Estimators.clear();
                Groups.clear();
                
                //allow user to run help
-               if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
+               if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -153,7 +187,24 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        outputTypes["lennon"] = tempOutNames;
                        outputTypes["morisitahorn"] = tempOutNames;
                        outputTypes["braycurtis"] = tempOutNames;
-
+                       outputTypes["odum"] = tempOutNames;
+                       outputTypes["canberra"] = tempOutNames;
+                       outputTypes["structeuclidean"] = tempOutNames;
+                       outputTypes["structchord"] = tempOutNames;
+                       outputTypes["hellinger"] = tempOutNames;
+                       outputTypes["manhattan"] = tempOutNames;
+                       outputTypes["structpearson"] = tempOutNames;
+                       outputTypes["soergel"] = tempOutNames;
+                       outputTypes["spearman"] = tempOutNames;
+                       outputTypes["structkulczynski"] = tempOutNames;
+                       outputTypes["speciesprofile"] = tempOutNames;
+                       outputTypes["structchi2"] = tempOutNames;
+                       outputTypes["hamming"] = tempOutNames;
+                       outputTypes["gower"] = tempOutNames;
+                       outputTypes["memchi2"] = tempOutNames;
+                       outputTypes["memchord"] = tempOutNames;
+                       outputTypes["memeuclidean"] = tempOutNames;
+                       outputTypes["mempearson"] = tempOutNames;
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
@@ -277,7 +328,62 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                                }else if (Estimators[i] == "braycurtis") { 
                                                        cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+"braycurtis")));
                                                        outputNames.push_back(fileNameRoot+"braycurtis"); outputTypes["braycurtis"].push_back(fileNameRoot+"braycurtis");
+                                               }else if (Estimators[i] == "odum") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Odum(), new SharedOneColumnFile(fileNameRoot+"odum")));
+                                                       outputNames.push_back(fileNameRoot+"odum"); outputTypes["odum"].push_back(fileNameRoot+"odum");
+                                               }else if (Estimators[i] == "canberra") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Canberra(), new SharedOneColumnFile(fileNameRoot+"canberra")));
+                                                       outputNames.push_back(fileNameRoot+"canberra"); outputTypes["canberra"].push_back(fileNameRoot+"canberra");
+                                               }else if (Estimators[i] == "structeuclidean") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StructEuclidean(), new SharedOneColumnFile(fileNameRoot+"structeuclidean")));
+                                                       outputNames.push_back(fileNameRoot+"structeuclidean"); outputTypes["structeuclidean"].push_back(fileNameRoot+"structeuclidean");
+                                               }else if (Estimators[i] == "structchord") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StructChord(), new SharedOneColumnFile(fileNameRoot+"structchord")));
+                                                       outputNames.push_back(fileNameRoot+"structchord"); outputTypes["structchord"].push_back(fileNameRoot+"structchord");
+                                               }else if (Estimators[i] == "hellinger") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Hellinger(), new SharedOneColumnFile(fileNameRoot+"hellinger")));
+                                                       outputNames.push_back(fileNameRoot+"hellinger"); outputTypes["hellinger"].push_back(fileNameRoot+"hellinger");
+                                               }else if (Estimators[i] == "manhattan") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Manhattan(), new SharedOneColumnFile(fileNameRoot+"manhattan")));
+                                                       outputNames.push_back(fileNameRoot+"manhattan"); outputTypes["manhattan"].push_back(fileNameRoot+"manhattan");
+                                               }else if (Estimators[i] == "structpearson") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StructPearson(), new SharedOneColumnFile(fileNameRoot+"structpearson")));
+                                                       outputNames.push_back(fileNameRoot+"structpearson"); outputTypes["structpearson"].push_back(fileNameRoot+"structpearson");
+                                               }else if (Estimators[i] == "soergel") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Soergel(), new SharedOneColumnFile(fileNameRoot+"soergel")));
+                                                       outputNames.push_back(fileNameRoot+"soergel"); outputTypes["soergel"].push_back(fileNameRoot+"soergel");
+                                               }else if (Estimators[i] == "spearman") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Spearman(), new SharedOneColumnFile(fileNameRoot+"spearman")));
+                                                       outputNames.push_back(fileNameRoot+"spearman"); outputTypes["spearman"].push_back(fileNameRoot+"spearman");
+                                               }else if (Estimators[i] == "structkulczynski") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StructKulczynski(), new SharedOneColumnFile(fileNameRoot+"structkulczynski")));
+                                                       outputNames.push_back(fileNameRoot+"structkulczynski"); outputTypes["structkulczynski"].push_back(fileNameRoot+"structkulczynski");
+                                               }else if (Estimators[i] == "speciesprofile") { 
+                                                       cDisplays.push_back(new CollectDisplay(new SpeciesProfile(), new SharedOneColumnFile(fileNameRoot+"speciesprofile")));
+                                                       outputNames.push_back(fileNameRoot+"speciesprofile"); outputTypes["speciesprofile"].push_back(fileNameRoot+"speciesprofile");
+                                               }else if (Estimators[i] == "hamming") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Hamming(), new SharedOneColumnFile(fileNameRoot+"hamming")));
+                                                       outputNames.push_back(fileNameRoot+"hamming"); outputTypes["hamming"].push_back(fileNameRoot+"hamming");
+                                               }else if (Estimators[i] == "structchi2") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StructChi2(), new SharedOneColumnFile(fileNameRoot+"structchi2")));
+                                                       outputNames.push_back(fileNameRoot+"structchi2"); outputTypes["structchi2"].push_back(fileNameRoot+"structchi2");
+                                               }else if (Estimators[i] == "gower") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Gower(), new SharedOneColumnFile(fileNameRoot+"gower")));
+                                                       outputNames.push_back(fileNameRoot+"gower"); outputTypes["gower"].push_back(fileNameRoot+"gower");
+                                               }else if (Estimators[i] == "memchi2") { 
+                                                       cDisplays.push_back(new CollectDisplay(new MemChi2(), new SharedOneColumnFile(fileNameRoot+"memchi2")));
+                                                       outputNames.push_back(fileNameRoot+"memchi2"); outputTypes["memchi2"].push_back(fileNameRoot+"memchi2");
+                                               }else if (Estimators[i] == "memchord") { 
+                                                       cDisplays.push_back(new CollectDisplay(new MemChord(), new SharedOneColumnFile(fileNameRoot+"memchord")));
+                                                       outputNames.push_back(fileNameRoot+"memchord"); outputTypes["memchord"].push_back(fileNameRoot+"memchord");
+                                               }else if (Estimators[i] == "memeuclidean") { 
+                                                       cDisplays.push_back(new CollectDisplay(new MemEuclidean(), new SharedOneColumnFile(fileNameRoot+"memeuclidean")));
+                                                       outputNames.push_back(fileNameRoot+"memeuclidean"); outputTypes["memeuclidean"].push_back(fileNameRoot+"memeuclidean");
+                                               }else if (Estimators[i] == "mempearson") { 
+                                                       cDisplays.push_back(new CollectDisplay(new MemPearson(), new SharedOneColumnFile(fileNameRoot+"mempearson")));
+                                                       outputNames.push_back(fileNameRoot+"mempearson"); outputTypes["mempearson"].push_back(fileNameRoot+"mempearson");
                                                }
+                                               
                                        }
                                }       
                        }
@@ -332,7 +438,7 @@ CollectSharedCommand::~CollectSharedCommand(){
 int CollectSharedCommand::execute(){
        try {
                
-               if (abort == true) {    return 0;       }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //if the users entered no valid calculators don't execute command
                if (cDisplays.size() == 0) { return 0; }