]> git.donarmstrong.com Git - mothur.git/blobdiff - sffinfocommand.cpp
fixed get.lienage and remove.lineage bug with confidence scores that are floats....
[mothur.git] / sffinfocommand.cpp
index c9bc469cf80c0871e7a4e8868ae1866960f4afcd..973e14f4fd68416bac6949a149a75bb5fbe174c4 100644 (file)
@@ -25,13 +25,12 @@ vector<string> SffInfoCommand::getValidParameters(){
 //**********************************************************************************************************************
 SffInfoCommand::SffInfoCommand(){      
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["flow"] = tempOutNames;
                outputTypes["sfftxt"] = tempOutNames;
-               outputTypes["qual"] = tempOutNames;
+               outputTypes["qfile"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
@@ -65,11 +64,11 @@ vector<string> SffInfoCommand::getRequiredFiles(){
 
 SffInfoCommand::SffInfoCommand(string option)  {
        try {
-               abort = false;
+               abort = false; calledHelp = false;   
                hasAccnos = 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
@@ -90,7 +89,7 @@ SffInfoCommand::SffInfoCommand(string option)  {
                        outputTypes["fasta"] = tempOutNames;
                        outputTypes["flow"] = tempOutNames;
                        outputTypes["sfftxt"] = tempOutNames;
-                       outputTypes["qual"] = tempOutNames;
+                       outputTypes["qfile"] = tempOutNames;
                        
                        //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 = "";         }
@@ -279,7 +278,7 @@ SffInfoCommand::~SffInfoCommand(){}
 int SffInfoCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                for (int s = 0; s < filenames.size(); s++) {
                        
@@ -301,6 +300,18 @@ int SffInfoCommand::execute(){
                
                if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } 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); }
+               }
+               
+               itTypes = outputTypes.find("qfile");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
+               }       
+               
                //report output filenames
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -337,7 +348,7 @@ int SffInfoCommand::extractSffInfo(string input, string accnos){
                
                if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName);  outputTypes["sfftxt"].push_back(sfftxtFileName); }
                if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
-               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qual"].push_back(outQualFileName);  }
+               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qfile"].push_back(outQualFileName);  }
                if (flow)       { m->openOutputFile(outFlowFileName, outFlow);          outputNames.push_back(outFlowFileName);  outFlow.setf(ios::fixed, ios::floatfield); outFlow.setf(ios::showpoint); outputTypes["flow"].push_back(outFlowFileName);  }
                
                ifstream in;