-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkamix_main.cpp
More file actions
70 lines (63 loc) · 1.94 KB
/
kamix_main.cpp
File metadata and controls
70 lines (63 loc) · 1.94 KB
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
62
63
64
65
66
67
68
69
70
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#include "bgzf.h"
#include "kamix.h"
#define VERSION "0.0.2"
static int usage()
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: kamix <command> file:path <arguments>\n");
fprintf(stderr, "Version: %s\n\n", VERSION);
fprintf(stderr, "Command: index Create a kamix index (kmers.gz.gbi)\n");
fprintf(stderr, " query Query a k-mer\n");
fprintf(stderr, " random Extract the 100 random k-mers\n");
fprintf(stderr, " check Is the file bgzipped?\n");
fprintf(stderr, " size Get total number of k-mers in the file\n");
fprintf(stderr, "\n");
return 1;
}
int main (int argc, char **argv)
{
if (argc == 1) {
return usage();
} else if (argc == 2) {
fprintf(stderr, "Missing kmers matrice\n");
return usage();
} else if (argc >= 3) {
// create input file for the purpose of the example
string bgzf_file = argv[2];
string sub_command = argv[1];
if (sub_command == "index")
{
create_kamix_index(bgzf_file, argc-2, argv+2);
}
else if (sub_command == "query")
{
kamix_query(bgzf_file, argc-2, argv+2);
}
else if (sub_command == "k")
{
cout << "k = " << get_kmer_length(bgzf_file) << endl;
}
else if (sub_command == "random")
{
size_t N = atoi(argv[3]);
random(bgzf_file, N);
}
else if (sub_command == "check")
{
cout << ((bgzf_is_bgzf(bgzf_file.c_str()) == 1) ? "yes" : "no") << "\n";
}
else if (sub_command == "size")
{
cout << size(bgzf_file) << "\n";
} else {
cout << "unknown command: " << sub_command << endl;
cout << "available commands are: index, grab, random, check, size" << endl;
}
}
return EXIT_SUCCESS;
}