]> git.donarmstrong.com Git - mothur.git/blobdiff - getsharedotucommand.cpp
added set.current and get.current commands and modified existing commands to update...
[mothur.git] / getsharedotucommand.cpp
index f8c245f95f8e159b61db3acda6cfa42dee9417d3..4fe711e568728f0fa1af026bec4c21af822732cd 100644 (file)
@@ -25,7 +25,7 @@ vector<string> GetSharedOTUCommand::getValidParameters(){
 //**********************************************************************************************************************
 GetSharedOTUCommand::GetSharedOTUCommand(){    
        try {
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["accnos"] = tempOutNames;
@@ -64,13 +64,13 @@ GetSharedOTUCommand::GetSharedOTUCommand(string option)  {
        try {
        
                globaldata = GlobalData::getInstance();
-               abort = false;
+               abort = false; calledHelp = false;   
                unique = true;
                allLines = 1;
                labels.clear();
                
                //allow user to run help
-               if(option == "help") { help(); abort = true; }
+               if(option == "help") { help(); abort = true; calledHelp = true; }
                
                else {
                        //valid paramters for this command
@@ -196,7 +196,7 @@ void GetSharedOTUCommand::help(){
                m->mothurOut("The output parameter allows you to output the list of names without the group and bin number added. \n");
                m->mothurOut("With this option you can use the names file as an input in get.seqs and remove.seqs commands. To do this enter output=accnos. \n");
                m->mothurOut("The get.sharedseqs command outputs a .names file for each distance level containing a list of sequences in the OTUs shared by the groups specified.\n");
-               m->mothurOut("The get.sharedseqs command should be in the following format: get.sabund(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
+               m->mothurOut("The get.sharedseqs command should be in the following format: get.sharedseqs(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
                m->mothurOut("Example get.sharedseqs(list=amazon.fn.list, label=unique-0.01, group=forest-pasture, fasta=amazon.fasta, output=accnos).\n");
                m->mothurOut("The output to the screen is the distance and the number of otus at that distance for the groups you specified.\n");
                m->mothurOut("The default value for label is all labels in your inputfile. The default for groups is all groups in your file.\n");
@@ -217,7 +217,7 @@ GetSharedOTUCommand::~GetSharedOTUCommand(){}
 int GetSharedOTUCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                groupMap = new GroupMap(groupfile);
                int error = groupMap->readMap();
@@ -334,6 +334,20 @@ int GetSharedOTUCommand::execute(){
                
                if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str()); }  delete groupMap; return 0; } 
                
+               //set fasta file as new current fastafile
+               string current = "";
+               itTypes = outputTypes.find("fasta");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
+               }
+               
+               if (output == "accnos") {
+                       itTypes = outputTypes.find("accnos");
+                       if (itTypes != outputTypes.end()) {
+                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
+                       }
+               }
+               
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }