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