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