Skip to content
Snippets Groups Projects
Commit 10b2ce25 authored by Ondřej Novák's avatar Ondřej Novák
Browse files

add results argument

parent 9648c0fc
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
#define TEST_CNT 2740 // 2740 // # of test sequences to compare (up to 9999)
#define TEST_MAX 8992 // 8992 // length of longest test sequence + 1
#define RESULTS 100 // # of results to display
// #define RESULTS 100 // # of results to display
// #define DEBUG
......@@ -178,15 +178,17 @@ void sum (const char * arg, int * seq, int seq_len, int * tab) {
}
int main (int argc, char * argv[]) {
if (argc != 7) {
if (argc != 8) {
fprintf(
stderr,
"Usage: %s <A> <C> <G> <T> <SPEED> <SEQUENCE>\n\n"
"Usage: %s <A> <C> <G> <T> <SPEED> <RESULTS> <SEQUENCE>\n\n"
"\t<A/C/G/T> - int values for sequence conversion, usually in range [-10,10]\n"
"\t<SPEED> - int value (percentage) telling how far you can go off the diagonal,\n"
"\t from 5 (very fast, not precise) to 100 (full computation)\n"
"\t<RESULTS> - # of results to output as <DTW score>:<sequence number>,\n"
"\t currently %d test sequences available\n"
"\t<SEQUENCE> - DNA sequence made of A/C/G/T letters\n",
argv[0]
argv[0], TEST_CNT
);
return 1;
}
......@@ -195,6 +197,7 @@ int main (int argc, char * argv[]) {
int speed; // speed (but also precision) of computation
int tab[4]; // A/C/G/T conversion values
int results; // # of results to output
int res[TEST_CNT]; // resulting DTW score for each comparison
int * seq, seq_len; // one input sequence
int * test, test_len; // current test sequence
......@@ -210,8 +213,11 @@ int main (int argc, char * argv[]) {
dtwm = (int **) malloc (sizeof(int*) * seq_len);
for (i = 0; i < seq_len; i++) dtwm[i] = (int *) malloc (sizeof(int) * TEST_MAX);
for (i = 0; i < 4; i++) tab[i] = atoi(argv[i+1]);
speed = atoi(argv[i+1]);
for (i = 1; i <= 4; i++) tab[i] = atoi(argv[i]);
speed = atoi(argv[i++]);
results = atoi(argv[i++]);
if (results < 0) results = 10;
if (results > TEST_CNT) results = TEST_CNT;
sum(argv[argc-1], seq, seq_len, tab);
for (i = 0; i < TEST_CNT; i++) {
sprintf(test_path, "./test/%d.seq", i);
......@@ -226,14 +232,12 @@ int main (int argc, char * argv[]) {
#endif
}
for (j = 0; j < RESULTS; j++) {
i = 0;
while (res[i] < 0) i++;
x = i;
for (i++; i < TEST_CNT; i++) {
for (j = 0; j < results; j++) {
x = 0;
for (i = 1; i < TEST_CNT; i++) {
if (res[i] < res[x] && res[i] >= 0) x = i;
}
// <DTW score>:<test file number>
// <DTW score>:<test sequence number>
printf("%d:%d\n", res[x], x);
res[x] = -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment