]> git.donarmstrong.com Git - mothur.git/blobdiff - nmdscommand.cpp
1.23.0
[mothur.git] / nmdscommand.cpp
index 3f8e34249c3d15c94709262fd252db1b525c820a..1d936d458d2edb69e6d49f51d8a79171389ea544 100644 (file)
@@ -77,6 +77,7 @@ NMDSCommand::NMDSCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -127,7 +128,7 @@ NMDSCommand::NMDSCommand(string option)  {
                                phylipfile = m->getPhylipFile(); 
                                if (phylipfile != "") { m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
                                else {  m->mothurOut("You have no current phylip file and the phylip parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }       
+                       }else { m->setPhylipFile(phylipfile); } 
                        
                        axesfile = validParameter.validFile(parameters, "axes", true);
                        if (axesfile == "not open") { axesfile = ""; abort = true; }
@@ -140,19 +141,19 @@ NMDSCommand::NMDSCommand(string option)  {
                        }
                        
                        string temp = validParameter.validFile(parameters, "mindim", false);    if (temp == "not found") {      temp = "2";     }
-                       convert(temp, mindim);
+                       m->mothurConvert(temp, mindim);
                        
                        temp = validParameter.validFile(parameters, "maxiters", false); if (temp == "not found") {      temp = "500";   }
-                       convert(temp, maxIters);
+                       m->mothurConvert(temp, maxIters);
                        
                        temp = validParameter.validFile(parameters, "iters", false);    if (temp == "not found") {      temp = "10";    }
-                       convert(temp, iters);
+                       m->mothurConvert(temp, iters);
                        
                        temp = validParameter.validFile(parameters, "maxdim", false);   if (temp == "not found") {      temp = "2";     }
-                       convert(temp, maxdim);
+                       m->mothurConvert(temp, maxdim);
                        
                        temp = validParameter.validFile(parameters, "epsilon", false);  if (temp == "not found") {      temp = "0.000000000001";        }
-                       convert(temp, epsilon); 
+                       m->mothurConvert(temp, epsilon); 
                        
                        if (mindim < 1) { m->mothurOut("mindim must be at least 1."); m->mothurOutEndLine(); abort = true; }
                        if (maxdim < mindim) { m->mothurOut("maxdim must be greater than mindim."); m->mothurOutEndLine(); abort = true; }
@@ -216,21 +217,21 @@ int NMDSCommand::execute(){
                                vector< vector<double> > thisConfig;
                                if (axesfile == "") {   thisConfig = generateStartingConfiguration(names.size(), i);            }
                                else                            {       thisConfig = getConfiguration(axes, i);                                                         }
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     remove(outputNames[k].c_str()); } return 0; }
+                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
                                
                                //calc nmds for this dimension
                                double stress;
                                vector< vector<double> > endConfig = nmdsCalc(matrix, thisConfig, stress);
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     remove(outputNames[k].c_str()); } return 0; }
+                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
                                
                                //calc euclid distances for new config
                                vector< vector<double> > newEuclid = linearCalc.calculateEuclidianDistance(endConfig);
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     remove(outputNames[k].c_str()); } return 0; }
+                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
                                
                                //calc correlation between original distances and euclidean distances from this config
                                double rsquared = linearCalc.calcPearson(newEuclid, matrix);
                                rsquared *= rsquared;
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     remove(outputNames[k].c_str()); } return 0; }
+                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
                                
                                //output results
                                out << "Config" << (j+1) << '\t';
@@ -248,7 +249,7 @@ int NMDSCommand::execute(){
                                        bestConfig = endConfig;
                                }
                                
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     remove(outputNames[k].c_str()); } return 0; }
+                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
                        }
                }
                
@@ -275,7 +276,7 @@ int NMDSCommand::execute(){
                
                outBest.close();
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } return 0; }
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();