]> git.donarmstrong.com Git - mothur.git/blobdiff - sensspeccommand.cpp
removed read.dist, read.otu, read.tree and globaldata. added current to defaults...
[mothur.git] / sensspeccommand.cpp
index 6a22fd686096e83308faf7a68e98e9391d722fe0..7f5d9dc05ff88882f90680a4f9281908102b573c 100644 (file)
 #include "sensspeccommand.h"
 
 //**********************************************************************************************************************
-vector<string> SensSpecCommand::getValidParameters(){  
+vector<string> SensSpecCommand::setParameters(){       
        try {
-               string Array[] =  {"list", "phylip", "column", "name", "hard", "label", "cutoff", "precision", "outputdir", "inputdir"};
-               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
+               //CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pcolumn);
+               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
+               CommandParameter pcutoff("cutoff", "Number", "", "-1.00", "", "", "",false,false); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
+               CommandParameter phard("hard", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(phard);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               
+               vector<string> myArray;
+               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
                return myArray;
        }
        catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "getValidParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SensSpecCommand::SensSpecCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               vector<string> tempOutNames;
-               outputTypes["sensspec"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "SensSpecCommand");
+               m->errorOut(e, "SensSpecCommand", "setParameters");
                exit(1);
        }
 }
 //**********************************************************************************************************************
-vector<string> SensSpecCommand::getRequiredParameters(){       
+string SensSpecCommand::getHelpString(){       
        try {
-               string Array[] =  {"list","phylip","column","or"};
-               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-               return myArray;
+               string helpString = "";
+               helpString += "The get.oturep command parameters are phylip, column, list, fasta, name, group, large, weighted, cutoff, precision, groups, sorted and label.  The fasta and list parameters are required, as well as phylip or column and name, unless you have valid current files.\n";
+               helpString += "The label parameter allows you to select what distance levels you would like a output files created for, and is separated by dashes.\n";
+               helpString += "The phylip or column parameter is required, but only one may be used.  If you use a column file the name filename is required. \n";
+               helpString += "If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n";
+               helpString += "The get.oturep command should be in the following format: get.oturep(phylip=yourDistanceMatrix, fasta=yourFastaFile, list=yourListFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n";
+               helpString += "Example get.oturep(phylip=amazon.dist, fasta=amazon.fasta, list=amazon.fn.list, group=amazon.groups).\n";
+               helpString += "The default value for label is all labels in your inputfile.\n";
+               helpString += "The sorted parameter allows you to indicate you want the output sorted. You can sort by sequence name, bin number, bin size or group. The default is no sorting, but your options are name, number, size, or group.\n";
+               helpString += "The large parameter allows you to indicate that your distance matrix is too large to fit in RAM.  The default value is false.\n";
+               helpString += "The weighted parameter allows you to indicate that want to find the weighted representative. You must provide a namesfile to set weighted to true.  The default value is false.\n";
+               helpString += "The representative is found by selecting the sequence that has the smallest total distance to all other sequences in the OTU. If a tie occurs the smallest average distance is used.\n";
+               helpString += "For weighted = false, mothur assumes the distance file contains only unique sequences, the list file may contain all sequences, but only the uniques are considered to become the representative. If your distance file contains all the sequences it would become weighted=true.\n";
+               helpString += "For weighted = true, mothur assumes the distance file contains only unique sequences, the list file must contain all sequences, all sequences are considered to become the representative, but unique name will be used in the output for consistency.\n";
+               helpString += "If your distance file contains all the sequence and you do not provide a name file, the weighted representative will be given, unless your listfile is unique. If you provide a namefile, then you can select weighted or unweighted.\n";
+               helpString += "The group parameter allows you provide a group file.\n";
+               helpString += "The groups parameter allows you to indicate that you want representative sequences for each group specified for each OTU, group name should be separated by dashes. ex. groups=A-B-C.\n";
+               helpString += "The get.oturep command outputs a .fastarep and .rep.names file for each distance you specify, selecting one OTU representative for each bin.\n";
+               helpString += "If you provide a groupfile, then it also appends the names of the groups present in that bin.\n";
+               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n";
+               return helpString;
        }
        catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "getRequiredParameters");
+               m->errorOut(e, "SensSpecCommand", "getHelpString");
                exit(1);
        }
 }
 //**********************************************************************************************************************
-vector<string> SensSpecCommand::getRequiredFiles(){    
+SensSpecCommand::SensSpecCommand(){    
        try {
-               vector<string> myArray;
-               return myArray;
+               abort = true; calledHelp = true; 
+               setParameters();
+               vector<string> tempOutNames;
+               outputTypes["sensspec"] = tempOutNames;
        }
        catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "getRequiredFiles");
+               m->errorOut(e, "SensSpecCommand", "SensSpecCommand");
                exit(1);
        }
 }
@@ -70,7 +89,7 @@ SensSpecCommand::SensSpecCommand(string option)  {
                        string temp;
 
                        //valid paramters for this command
-                       string AlignArray[] =  {"list", "phylip", "column", "name", "hard", "label", "cutoff", "precision", "outputdir", "inputdir"};
+                       string AlignArray[] =  {"list", "phylip", "column", "hard", "label", "cutoff", "precision", "outputdir", "inputdir"};
                        
                        vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
                        
@@ -118,29 +137,49 @@ SensSpecCommand::SensSpecCommand(string option)  {
                                        if (path == "") {       parameters["column"] = inputDir + it->second;           }
                                }
                                
-                               it = parameters.find("name");
+                               //it = parameters.find("name");
                                //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
+                               //if(it != parameters.end()){ 
+                                       //path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
+                                       //if (path == "") {     parameters["name"] = inputDir + it->second;             }
+                               //}
                                
                        }
                        //check for required parameters
                        listFile = validParameter.validFile(parameters, "list", true);
-                       if (listFile == "not found") { m->mothurOut("list is a required parameter for the sens.spec command."); m->mothurOutEndLine(); abort = true; }
+                       if (listFile == "not found") {          
+                               listFile = m->getListFile(); 
+                               if (listFile != "") { m->mothurOut("Using " + listFile + " as input file for the list parameter."); m->mothurOutEndLine(); }
+                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
+                       }
                        else if (listFile == "not open") { abort = true; }      
                        
-                       distFile = validParameter.validFile(parameters, "column", true);
-                       format = "column";
-                       if(distFile == "not found")     {
-                               distFile = validParameter.validFile(parameters, "phylip", true);
-                               format = "phylip";      
-                       }
-                       if(distFile == "not found") { m->mothurOut("either column or phylip are required for the sens.spec command."); m->mothurOutEndLine(); abort = true; }
-                       else if (distFile == "not open") { abort = true; }      
-               
+                       phylipfile = validParameter.validFile(parameters, "phylip", true);
+                       if (phylipfile == "not found") { phylipfile = "";  }
+                       else if (phylipfile == "not open") { abort = true; }    
+                       else { distFile = phylipfile; format = "phylip";   }
+                       
+                       columnfile = validParameter.validFile(parameters, "column", true);
+                       if (columnfile == "not found") { columnfile = ""; }
+                       else if (columnfile == "not open") { abort = true; }    
+                       else { distFile = columnfile; format = "column";   }
+                       
+                       if ((phylipfile == "") && (columnfile == "")) { //is there are current file available for either of these?
+                               //give priority to column, then phylip
+                               columnfile = m->getColumnFile(); 
+                               if (columnfile != "") {  distFile = columnfile; format = "column";  m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
+                               else { 
+                                       phylipfile = m->getPhylipFile(); 
+                                       if (phylipfile != "") {  distFile = phylipfile; format = "phylip"; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
+                                       else { 
+                                               m->mothurOut("No valid current files. You must provide a phylip or column file."); m->mothurOutEndLine(); 
+                                               abort = true;
+                                       }
+                               }
+                       }else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a sens.spec command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
+                       
+                       
                        //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"){  
@@ -179,30 +218,6 @@ SensSpecCommand::SensSpecCommand(string option)  {
                exit(1);
        }
 }
-
-//**********************************************************************************************************************
-
-void SensSpecCommand::help(){
-       try {
-               m->mothurOut("The sens.spec command reads a fastaFile and creates .....\n");
-
-               
-               
-               m->mothurOut("Example sens.spec(...).\n");
-               m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n");
-               m->mothurOut("For more details please check out the wiki http://www.mothur.org/wiki/Trim.seqs .\n\n");
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "help");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-SensSpecCommand::~SensSpecCommand(){   /*      do nothing      */      }
-
 //***************************************************************************************************************
 
 int SensSpecCommand::execute(){