]> git.donarmstrong.com Git - mothur.git/blob - validcommands.cpp
Initial revision
[mothur.git] / validcommands.cpp
1 /*
2  *  validcommands.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/5/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "validcommands.h"
11
12 /***********************************************************************/
13
14 ValidCommands::ValidCommands() {
15         try {
16         
17                 commands["read.phylip"]                 = "read.phylip"; 
18                 commands["read.column"]                 = "read.column"; 
19                 commands["read.list"]                   = "read.list"; 
20                 commands["read.rabund"]                 = "read.rabund"; 
21                 commands["read.sabund"]                 = "read.sabund"; 
22                 commands["read.shared"]                 = "read.shared"; 
23                 commands["cluster"]                             = "cluster"; 
24                 commands["help"]                                = "help"; 
25                 commands["quit"]                                = "quit"; 
26                 commands["collect.single"]              = "collect.single"; 
27                 commands["shared"]                              = "shared"; 
28                 commands["collect.shared"]              = "collect.shared"; 
29                 commands["rarefaction.single"]  = "rarefaction.single"; 
30                 commands["rarefaction.shared"]  = "rarefaction.shared"; 
31                 commands["summary.single"]              = "summary.single"; 
32                 commands["summary.shared"]              = "summary.shared"; 
33                 commands["parselist"]                   = "parselist"; 
34                 
35         }
36         catch(exception& e) {
37                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function ValidCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
38                 exit(1);
39         }
40         catch(...) {
41                 cout << "An unknown error has occurred in the ValidCommands class function ValidCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
42                 exit(1);
43         }       
44 }
45
46 /***********************************************************************/
47
48 ValidCommands::~ValidCommands() {}
49
50 /***********************************************************************/
51 bool ValidCommands::isValidCommand(string command) {
52         try {   
53         
54                 //is the command in the map
55                 if ((commands.find(command)) != (commands.end())) {
56                         return true;
57                 }else{
58                         cout << command << " is not a valid command in Mothur.  Valid commands are read.phylip(), read.column(), read.list(), read.rabund(), read.sabund(), read.shared(), cluster(), collect.single(), collect.shared(), parselist(), shared(), rarefaction.single(), rarefaction.shared(), summary.single(), summary.shared(), quit(), help()." << endl;
59                         return false;
60                 }
61                 
62         }
63         catch(exception& e) {
64                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
65                 exit(1);
66         }
67         catch(...) {
68                 cout << "An unknown error has occurred in the ValidCommands class function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
69                 exit(1);
70         }
71 }
72
73 /***********************************************************************/