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