]> git.donarmstrong.com Git - mothur.git/blob - validcommands.cpp
working on libshuff
[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.dist"]                   = "read.dist"; 
18                 commands["read.otu"]                    = "read.otu";
19                 commands["read.tree"]                   = "read.tree"; 
20                 commands["cluster"]                             = "cluster"; 
21                 commands["deconvolute"]                 = "deconvolute"; 
22                 commands["parsimony"]                   = "parsimony";
23                 commands["help"]                                = "help"; 
24                 commands["quit"]                                = "quit"; 
25                 commands["collect.single"]              = "collect.single"; 
26                 commands["collect.shared"]              = "collect.shared"; 
27                 commands["get.group"]           = "get.group";
28                 commands["get.label"]           = "get.label";
29                 commands["get.line"]            = "get.line";
30                 commands["rarefaction.single"]  = "rarefaction.single"; 
31                 commands["rarefaction.shared"]  = "rarefaction.shared"; 
32                 commands["summary.single"]              = "summary.single"; 
33                 commands["summary.shared"]              = "summary.shared"; 
34                 commands["unifrac.weighted"]    = "unifrac.weighted"; 
35                 commands["unifrac.unweighted"]  = "unifrac.unweighted"; 
36                 commands["libshuff"]                    = "libshuff";
37
38                                 
39         }
40         catch(exception& e) {
41                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function ValidCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
42                 exit(1);
43         }
44         catch(...) {
45                 cout << "An unknown error has occurred in the ValidCommands class function ValidCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
46                 exit(1);
47         }       
48 }
49
50 /***********************************************************************/
51
52 ValidCommands::~ValidCommands() {}
53
54 /***********************************************************************/
55 bool ValidCommands::isValidCommand(string command) {
56         try {   
57         
58                 //is the command in the map
59                 if ((commands.find(command)) != (commands.end())) {
60                         return true;
61                 }else{
62                         cout << command << " is not a valid command in Mothur.  Valid commands are ";
63                         for (it = commands.begin(); it != commands.end(); it++) {
64                                 cout << it->first << ", ";
65                         }
66                         cout << endl;
67                         return false;
68                 }
69                 
70         }
71         catch(exception& e) {
72                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
73                 exit(1);
74         }
75         catch(...) {
76                 cout << "An unknown error has occurred in the ValidCommands class function isValidCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
77                 exit(1);
78         }
79 }
80
81 /***********************************************************************/
82 void ValidCommands::printCommands(ostream& out) {
83         try {   
84                 out << "Valid commands are ";
85                 for (it = commands.begin(); it != commands.end(); it++) {
86                         out << it->first << ", ";
87                 }
88                 out << endl;
89         }
90         catch(exception& e) {
91                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
92                 exit(1);
93         }
94         catch(...) {
95                 cout << "An unknown error has occurred in the ValidCommands class function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
96                 exit(1);
97         }
98 }
99
100
101
102