]> git.donarmstrong.com Git - mothur.git/blobdiff - normalizesharedcommand.cpp
fixed problem with sffinfo that caused a file mismatch when the trimming trimmed...
[mothur.git] / normalizesharedcommand.cpp
index 85265015a7e6ea4de35552bd7d27d7efdc688348..37cfb5daa98b4eeb850b44d60e5e9d80fa268de5 100644 (file)
@@ -24,8 +24,7 @@ vector<string> NormalizeSharedCommand::getValidParameters(){
 //**********************************************************************************************************************
 NormalizeSharedCommand::NormalizeSharedCommand(){      
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["shared"] = tempOutNames;
        }
@@ -62,12 +61,12 @@ vector<string> NormalizeSharedCommand::getRequiredFiles(){
 NormalizeSharedCommand::NormalizeSharedCommand(string option) {
        try {
                globaldata = GlobalData::getInstance();
-               abort = false;
+               abort = false; calledHelp = false;   
                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
@@ -185,7 +184,7 @@ NormalizeSharedCommand::~NormalizeSharedCommand(){}
 int NormalizeSharedCommand::execute(){
        try {
        
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                string outputFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "norm.shared";
                ofstream out;
@@ -382,6 +381,13 @@ int NormalizeSharedCommand::execute(){
                m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
                m->mothurOutEndLine();
                
+               //set shared file as new current sharedfile
+               string current = "";
+               itTypes = outputTypes.find("shared");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
+               }
+               
                return 0;
        }
        catch(exception& e) {
@@ -405,7 +411,7 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp, o
                                                        
                                                int abund = thisLookUp[i]->getAbundance(j);
                                                        
-                                               float relabund = relabund = abund / (float) thisLookUp[i]->getNumSeqs();
+                                               float relabund = abund / (float) thisLookUp[i]->getNumSeqs();
                                                float newNorm = relabund * norm;
                                                
                                                //round to nearest int
@@ -479,7 +485,7 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundFloatVector*>& thisLook
                                        
                                        float abund = thisLookUp[i]->getAbundance(j);
                                        
-                                       float relabund = relabund = abund / (float) thisLookUp[i]->getNumSeqs();
+                                       float relabund = abund / (float) thisLookUp[i]->getNumSeqs();
                                        float newNorm = relabund * norm;
                                        
                                        thisLookUp[i]->set(j, newNorm, thisLookUp[i]->getGroup());