]> git.donarmstrong.com Git - mothur.git/blobdiff - removelineagecommand.cpp
reworked amova / homova / anosim
[mothur.git] / removelineagecommand.cpp
index 9467ff60d50b3d72f3f016ed934ba828566f950f..6e43b1025cae8ccc828e7e48c51b63304200dc62 100644 (file)
@@ -26,8 +26,7 @@ vector<string> RemoveLineageCommand::getValidParameters(){
 //**********************************************************************************************************************
 RemoveLineageCommand::RemoveLineageCommand(){  
        try {
-               abort = true;
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["fasta"] = tempOutNames;
                outputTypes["taxonomy"] = tempOutNames;
@@ -67,10 +66,10 @@ vector<string> RemoveLineageCommand::getRequiredFiles(){
 //**********************************************************************************************************************
 RemoveLineageCommand::RemoveLineageCommand(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
@@ -237,7 +236,7 @@ void RemoveLineageCommand::help(){
 int RemoveLineageCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                if (m->control_pressed) { return 0; }
                
@@ -551,6 +550,7 @@ int RemoveLineageCommand::readTax(){
                        
                        //if the users file contains confidence scores we want to ignore them when searching for the taxons, unless the taxon has them
                        if (!taxonsHasConfidence) {
+                               
                                int hasConfidences = tax.find_first_of('(');
                                if (hasConfidences != string::npos) { 
                                        newtax = removeConfidences(tax);
@@ -568,7 +568,7 @@ int RemoveLineageCommand::readTax(){
                        }else{//if taxons has them and you don't them remove taxons
                                int hasConfidences = tax.find_first_of('(');
                                if (hasConfidences == string::npos) { 
-                                       
+                               
                                        int pos = newtax.find(noConfidenceTaxons);
                                        
                                        if (pos == string::npos) { 
@@ -579,7 +579,7 @@ int RemoveLineageCommand::readTax(){
                                        }
                                }else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
                                        //first remove confidences from both and see if the taxonomy exists
-                                       
+                               
                                        string noNewTax = tax;
                                        int hasConfidences = tax.find_first_of('(');
                                        if (hasConfidences != string::npos) { 
@@ -671,8 +671,14 @@ vector< map<string, int> > RemoveLineageCommand::getTaxons(string tax) {
                                int openParen = taxon.find_first_of('(');
                                int closeParen = taxon.find_last_of(')');
                                
-                               string newtaxon = taxon.substr(0, openParen); //rip off confidence
-                               string confidence = taxon.substr((openParen+1), (closeParen-openParen-1));  
+                               string newtaxon, confidence;
+                               if ((openParen != string::npos) && (closeParen != string::npos)) {
+                                       newtaxon = taxon.substr(0, openParen); //rip off confidence
+                                       confidence = taxon.substr((openParen+1), (closeParen-openParen-1));  
+                               }else{
+                                       newtaxon = taxon;
+                                       confidence = "0";
+                               }
                                int con = 0;
                                convert(confidence, con);