]> git.donarmstrong.com Git - mothur.git/commitdiff
Fixed validParameter() method so line parameter can use dashes without breaking the...
authorryabin <ryabin>
Mon, 30 Mar 2009 20:18:37 +0000 (20:18 +0000)
committerryabin <ryabin>
Mon, 30 Mar 2009 20:18:37 +0000 (20:18 +0000)
Mothur.xcodeproj/project.pbxproj
validparameter.cpp

index e71f9ce250b4f4c692b5b9cae6e4b73dbfe82fc1..31fc48121d94014c71b2a8b9954acde1b77f135c 100644 (file)
                EB6F015B0F6AC1670048081A /* sharedbdiversity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB6F015A0F6AC1670048081A /* sharedbdiversity.cpp */; };
                EB9303EB0F534D9400E8EF26 /* logsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB9303EA0F534D9400E8EF26 /* logsd.cpp */; };
                EB9303F90F53517300E8EF26 /* geom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB9303F80F53517300E8EF26 /* geom.cpp */; };
+               EBC564190F81479000A5AC46 /* sharedjackknife.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBC564180F81479000A5AC46 /* sharedjackknife.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
                EB9303EA0F534D9400E8EF26 /* logsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logsd.cpp; sourceTree = "<group>"; };
                EB9303F70F53517300E8EF26 /* geom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = geom.h; sourceTree = "<group>"; };
                EB9303F80F53517300E8EF26 /* geom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = geom.cpp; sourceTree = "<group>"; };
+               EBC564170F81479000A5AC46 /* sharedjackknife.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedjackknife.h; sourceTree = "<group>"; };
+               EBC564180F81479000A5AC46 /* sharedjackknife.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedjackknife.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                37D928240F21331F001D4494 /* sharedchao1.cpp */,
                                37D928290F21331F001D4494 /* sharedjabund.h */,
                                37D928280F21331F001D4494 /* sharedjabund.cpp */,
+                               EBC564170F81479000A5AC46 /* sharedjackknife.h */,
+                               EBC564180F81479000A5AC46 /* sharedjackknife.cpp */,
                                37D9282B0F21331F001D4494 /* sharedjclass.h */,
                                37D9282A0F21331F001D4494 /* sharedjclass.cpp */,
                                37D9282D0F21331F001D4494 /* sharedjest.h */,
                                3758740C0F7D64FC0040F377 /* sharedmorisitahorn.cpp in Sources */,
                                3758740D0F7D64FC0040F377 /* sharedochiai.cpp in Sources */,
                                37519A6B0F80E6EB00FED5E8 /* sharedanderbergs.cpp in Sources */,
+                               EBC564190F81479000A5AC46 /* sharedjackknife.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 51fefd837203aea8c3774d1581e9e579cf66fd55..11e7bf93cb91079ce0feb8ead87f41a953cfd136 100644 (file)
@@ -49,6 +49,10 @@ bool ValidParameters::isValidParameter(string parameter, string command, string
                if(!valid)
                {
                        cout << "'" << parameter << "' is not a valid parameter for the " << command << " command.\n";
+                       cout << "The valid paramters for the " << command << " command are: ";
+                       for(int i = 0; i < numParams-1; i++)
+                               cout << cParams.at(i) << ", ";
+                       cout << "and " << cParams.at(numParams-1) << ".\n";
                        return false;
                }
                
@@ -58,153 +62,155 @@ bool ValidParameters::isValidParameter(string parameter, string command, string
                int pVal;
                double piSentinel = 3.14159;
                vector<string> range = parameterRanges[parameter];
-
-               valid = convertTest(value, pVal);
-               
-               if(!valid)
-                       return false;
-               
                
+               vector<string> values;
+               splitAtDash(value, values);
                
-               /********************************************************************************************************
-                      Special Cases
-           *********************************************************************************************************/
-               
-               if(parameter.compare("precision") == 0)
+               for(int i = 0; i < values.size(); i++)
                {
-                       double logNum = log10((double)pVal);
-                       double diff = (double)((int)logNum - logNum);
-                       if(diff != 0)
+                       value = values.at(i);
+                       valid = convertTest(value, pVal);
+               
+                       if(!valid)
+                               return false;
+                       
+                       
+                       
+                       /********************************************************************************************************
+                                  Special Cases
+                       *********************************************************************************************************/
+                       
+                       if(parameter.compare("precision") == 0)
+                       {
+                               double logNum = log10((double)pVal);
+                               double diff = (double)((int)logNum - logNum);
+                               if(diff != 0)
+                               {
+                                       cout << "The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n";
+                                       return false;
+                               }
+                       }
+                       
+                       /************************************************************************************************************/
+                       
+                       
+                       
+                       double a,b,c,d,e;
+                       
+                       if(range.at(1).compare("NA") == 0)
+                               a = piSentinel;
+                       else
+                               a = atoi(range.at(1).c_str()); 
+                               
+                       if(range.at(3).compare("NA") == 0)
+                               b = piSentinel;
+                       else
+                               b = atoi(range.at(3).c_str()); 
+                                               
+                       if(range.at(4).compare("between") == 0)
+                               c = 0;
+                       else if(range.at(4).compare("only") == 0)
+                               c = 1;
+                       else
                        {
-                               cout << "The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n";
+                               cout << "The range can only be 'between' or 'only' the bounding numbers.\n";
                                return false;
                        }
-               }
-               
-               /************************************************************************************************************/
-               
-               
-               
-               double a,b,c,d,e;
-               
-               if(range.at(1).compare("NA") == 0)
-                       a = piSentinel;
-               else
-                       a = atoi(range.at(1).c_str()); 
                        
-               if(range.at(3).compare("NA") == 0)
-                       b = piSentinel;
-               else
-                       b = atoi(range.at(3).c_str()); 
-                                       
-               if(range.at(4).compare("between") == 0)
-                       c = 0;
-               else if(range.at(4).compare("only") == 0)
-                       c = 1;
-               else
-               {
-                       cout << "The range can only be 'between' or 'only' the bounding numbers.\n";
-                       return false;
-               }
-               
-               if(range.at(0).compare(">") == 0)
-                       d = 0;
-               else if(range.at(0).compare(">=") == 0 || range[3].compare("=>") == 0)
-                       d = 1;
-               else
-               {
-                       cout << "The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n";
-                       return false;
-               }
-               
-               if(range.at(2).compare("<") == 0)
-                       e = 0;
-               else if(range.at(2).compare("<=") == 0 || range[4].compare("=<") == 0)
-                       e = 1;
-               else
-               {
-                       cout << "The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n";
-                       return false;
-               }
-               
-               bool a0 = pVal > a;
-               bool a1 = pVal >= a;
-               bool b0 = pVal < b;
-               bool b1 = pVal <= b;
-               
-               if(c != 1)
-               {
-                       if(a == piSentinel && b == piSentinel)
-                               return true;
-                       if(a != piSentinel && b == piSentinel)
+                       if(range.at(0).compare(">") == 0)
+                               d = 0;
+                       else if(range.at(0).compare(">=") == 0 || range[3].compare("=>") == 0)
+                               d = 1;
+                       else
                        {
-                               if(d == 0)
-                                       valid = a0;
-                               else
-                                       valid = a1;
+                               cout << "The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n";
+                               return false;
                        }
-                       else if(a == piSentinel && b != piSentinel)
+                       
+                       if(range.at(2).compare("<") == 0)
+                               e = 0;
+                       else if(range.at(2).compare("<=") == 0 || range[4].compare("=<") == 0)
+                               e = 1;
+                       else
                        {
-                               if(e == 0)
-                                       valid = b0;
+                               cout << "The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n";
+                               return false;
+                       }
+                       
+                       bool a0 = pVal > a;
+                       bool a1 = pVal >= a;
+                       bool b0 = pVal < b;
+                       bool b1 = pVal <= b;
+                       
+                       if(c != 1)
+                       {
+                               if(a != piSentinel && b == piSentinel)
+                               {
+                                       if(d == 0)
+                                               valid = a0;
+                                       else
+                                               valid = a1;
+                               }
+                               else if(a == piSentinel && b != piSentinel)
+                               {
+                                       if(e == 0)
+                                               valid = b0;
+                                       else
+                                               valid = b1;
+                               }
                                else
-                                       valid = b1;
+                               {
+                                       if(d == 0 && e == 0)
+                                               valid = (a0 && b0);
+                                       else if(d == 0 && e == 1)
+                                               valid = (a0 && b1);
+                                       else if(d == 1 && e == 0)
+                                               valid = (a1 && b0);
+                                       else
+                                               valid = (a1 && b1);
+                               }
                        }
                        else
                        {
-                               if(d == 0 && e == 0)
-                                       valid = (a0 && b0);
-                               else if(d == 0 && e == 1)
-                                       valid = (a0 && b1);
-                               else if(d == 1 && e == 0)
-                                       valid = (a1 && b0);
+                               if(a != piSentinel && b == piSentinel)
+                                       valid = (pVal == a);
+                               else if(a == piSentinel && b != piSentinel)
+                                       valid = (pVal == b);
                                else
-                                       valid = (a1 && b1);
+                                       valid = (pVal == a || pVal == b);
                        }
-               }
-               else
-               {
-                       if(a == piSentinel && b == piSentinel)
-                               return true;
-                       if(a != piSentinel && b == piSentinel)
-                               valid = (pVal == a);
-                       else if(a == piSentinel && b != piSentinel)
-                               valid = (pVal == b);
-                       else
-                               valid = (pVal == a || pVal == b);
-               }
-               
-               if(valid)
-                       return true;
-               
-               else
-               {
-                       cout << "The '" << parameter << "' parameter needs to be ";
-                       if(c == 1)
-                               cout << "either '" << a << "' or '" << b << "'.\n";
-                       else
+                       
+                       
+                       if(!valid)
                        {
-                               if(a != piSentinel)
-                               {
-                                       cout << ">";
-                                       if(d != 0)
-                                               cout << "=";
-                                       cout << " '" << a << "'";
-                               }
-                               if(b == piSentinel)
-                                       cout << ".\n";
-                               else if(a != piSentinel)
-                                       cout << " and ";
-                               if(b != piSentinel)
+                               cout << "The '" << parameter << "' parameter needs to be ";
+                               if(c == 1)
+                                       cout << "either '" << a << "' or '" << b << "'.\n";
+                               else
                                {
-                                       cout << "<";
-                                       if(e != 0)
-                                               cout << "=";
-                                       cout << " '" << b << ".\n";
+                                       if(a != piSentinel)
+                                       {
+                                               cout << ">";
+                                               if(d != 0)
+                                                       cout << "=";
+                                               cout << " '" << a << "'";
+                                       }
+                                       if(b == piSentinel)
+                                               cout << ".\n";
+                                       else if(a != piSentinel)
+                                               cout << " and ";
+                                       if(b != piSentinel)
+                                       {
+                                               cout << "<";
+                                               if(e != 0)
+                                                       cout << "=";
+                                               cout << " '" << b << ".\n";
+                                       }
                                }
+                               return false;
                        }
-                       return false;
                }
+               return true;
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";