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