X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=pcacommand.cpp;h=ee0a5462de87049f6b026546492203be630ea8d7;hb=5694c92fbf646fe01abc87bde2af59e14a9a56b6;hp=c9fecd58ca08d9103770dd5f0e3afd7f2274c89d;hpb=aa9238c0a9e6e7aa0ed8b8b606b08ad4fd7dcfe3;p=mothur.git diff --git a/pcacommand.cpp b/pcacommand.cpp index c9fecd5..ee0a546 100644 --- a/pcacommand.cpp +++ b/pcacommand.cpp @@ -10,6 +10,55 @@ #include "pcacommand.h" +//********************************************************************************************************************** +vector PCACommand::getValidParameters(){ + try { + string Array[] = {"phylip", "outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "PCACommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +PCACommand::PCACommand(){ + try { + abort = true; + //initialize outputTypes + vector tempOutNames; + outputTypes["pcoa"] = tempOutNames; + outputTypes["loadings"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "PCACommand", "PCACommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector PCACommand::getRequiredParameters(){ + try { + string Array[] = {"phylip"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "PCACommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector PCACommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "PCACommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** PCACommand::PCACommand(string option) { @@ -42,12 +91,17 @@ PCACommand::PCACommand(string option) { it = parameters.find("phylip"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["phylip"] = inputDir + it->second; } } } - + + //initialize outputTypes + vector tempOutNames; + outputTypes["pcoa"] = tempOutNames; + outputTypes["loadings"] = tempOutNames; + //required parameters phylipfile = validParameter.validFile(parameters, "phylip", true); if (phylipfile == "not open") { abort = true; } @@ -57,7 +111,7 @@ PCACommand::PCACommand(string option) { //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 = ""; - outputDir += hasPath(phylipfile); //if user entered a file with a path then preserve it + outputDir += m->hasPath(phylipfile); //if user entered a file with a path then preserve it } //error checking on files @@ -97,7 +151,7 @@ int PCACommand::execute(){ vector names; vector > D; - fbase = outputDir + getRootName(getSimpleName(filename)); + fbase = outputDir + m->getRootName(m->getSimpleName(filename)); read(filename, names, D); @@ -219,11 +273,11 @@ int PCACommand::read_phylip(istream& f, int square_m, vector& name_list, void PCACommand::read(string fname, vector& names, vector >& D){ try { ifstream f; - openInputFile(fname, f); + m->openInputFile(fname, f); //check whether matrix is square char d; - int m = 1; + int q = 1; int numSeqs; string name; @@ -233,21 +287,21 @@ void PCACommand::read(string fname, vector& names, vector //is d a number meaning its square if(isalnum(d)){ - m = 1; + q = 1; break; } //is d a line return meaning its lower triangle if(d == '\n'){ - m = 2; + q = 2; break; } } f.close(); //reopen to get back to beginning - openInputFile(fname, f); - read_phylip(f, m, names, D); + m->openInputFile(fname, f); + read_phylip(f, q, names, D); } catch(exception& e) { m->errorOut(e, "PCACommand", "read"); @@ -512,15 +566,17 @@ void PCACommand::output(string fnameRoot, vector name_list, vector