]> git.donarmstrong.com Git - mothur.git/blobdiff - listseqscommand.cpp
added set.current and get.current commands and modified existing commands to update...
[mothur.git] / listseqscommand.cpp
index 1488cdadac766b243252e87053a0132975961884..a8a9d2b5a6cff6da2ab8e86e22af19782f5ce0bf 100644 (file)
@@ -26,8 +26,7 @@ vector<string> ListSeqsCommand::getValidParameters(){
 //**********************************************************************************************************************
 ListSeqsCommand::ListSeqsCommand(){    
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["accnos"] = tempOutNames;
        }
@@ -63,10 +62,10 @@ vector<string> ListSeqsCommand::getRequiredFiles(){
 
 ListSeqsCommand::ListSeqsCommand(string option)  {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                
                //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
@@ -206,7 +205,7 @@ void ListSeqsCommand::help(){
 int ListSeqsCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //read functions fill names vector
                if (fastafile != "")            {       inputFileName = fastafile;      readFasta();    }
@@ -227,6 +226,7 @@ int ListSeqsCommand::execute(){
 
                ofstream out;
                m->openOutputFile(outputFileName, out);
+               outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
                
                //output to .accnos file
                for (int i = 0; i < names.size(); i++) {
@@ -238,12 +238,21 @@ int ListSeqsCommand::execute(){
                out.close();
                
                if (m->control_pressed) { outputTypes.clear();  remove(outputFileName.c_str()); return 0; }
-
+               
+               m->setAccnosFile(outputFileName);
+               
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
+               m->mothurOut(outputFileName); m->mothurOutEndLine();    
                m->mothurOutEndLine();
                
+               //set accnos file as new current accnosfile
+               string current = "";
+               itTypes = outputTypes.find("accnos");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
+               }
+               
                return 0;               
        }
 
@@ -260,7 +269,7 @@ int ListSeqsCommand::readFasta(){
                ifstream in;
                m->openInputFile(fastafile, in);
                string name;
-       
+               
                while(!in.eof()){
                        
                        if (m->control_pressed) { in.close(); return 0; }
@@ -445,6 +454,7 @@ int ListSeqsCommand::readTax(){
                        names.push_back(firstCol);
                        
                        m->gobble(in);
+                       
                }
                in.close();