-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
61 lines (54 loc) · 1.91 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <string.h>
#include <iostream>
#include <string>
// Self include
#include "GrabJellyfishKmer.h"
#include "GetCnvSignal.h"
//#include "GenerateKmer.h"
struct SubCommand {
const unsigned int no_sub_commands = 2;
//const std::string sub_commands[3] = {"GrabJellyfishKmer", "GetCnvSignal", "GenerateKmer"};
const std::string sub_commands[2] = {"GrabJellyfishKmer", "GetCnvSignal"};
const std::string Help (const char* program) const { return
std::string("\n") +
std::string("USAGE: ") + program + std::string(" <command> [options]\n\n") +
std::string("Commands:\n") +
std::string("\tGrabJellyfishKmer Report the count of kmer giving Jellyfish database and a FASTA.\n") +
std::string("\tGetCnvSignal Report CNV signals such as read depth and kmer count.\n");
//std::string("\tGenerateKmer Generate a kmer table by giving a FASTA. The kmer is shown by ascii code of log2(kmer)+34.\n");
}
};
int main (int argc, char** argv) {
SubCommand cml_option;
std::string command;
if(argc < 2) {
std::cerr << cml_option.Help(argv[0]) << std::endl;
return 1;
} else {
for (unsigned int i = 0; i < cml_option.no_sub_commands; ++i) {
if (strcmp(argv[1], cml_option.sub_commands[i].c_str()) == 0) {
// Get the valid subcommand
command = cml_option.sub_commands[i];
break;
}
}
}
if (command.empty()) { // The given command is not in the list
std::cerr << "ERROR: The given command (" << argv[1] << ") is not valid." << std::endl;
std::cerr << cml_option.Help(argv[0]) << std::endl;
return 1;
} else { // Get the valid subcommand
if (command == "GrabJellyfishKmer") {
GrabJellyfishKmer count_kmer(argc - 1, argv + 1);
count_kmer.Run();
} else if (command == "GetCnvSignal") {
GetCnvSignal get_cnv_signal(argc - 1, argv + 1);
get_cnv_signal.Run();
}
//else if (command == "GenerateKmer") {
// GenerateKmer generate_kmer(argc - 1, argv + 1);
// generate_kmer.Run();
//}
}
return 0;
}