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