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