Debian Codegraph @

sim4dbutils/plotCoverageVsIdentity.C

raw
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <errno.h>
6
7 #include "sim4.H"
8
9 int
10 main(int argc, char ** argv) {
11 int c[101] = {0};
12 int i[101] = {0};
13
14 if (isatty(fileno(stdin))) {
15 fprintf(stderr, "creates three files:\n");
16 fprintf(stderr, " coverage.histogram\n");
17 fprintf(stderr, " identity.histogram\n");
18 fprintf(stderr, " c-vs-i.scatter\n");
19 fprintf(stderr, "\n");
20 fprintf(stderr, "error: I cannot read polishes from the terminal!\n\n");
21 exit(1);
22 }
23
24 FILE *C = fopen("coverage.histogram", "w");
25 FILE *I = fopen("identity.histogram", "w");
26 FILE *S = fopen("c-vs-i.scatter", "w");
27
28 sim4polishReader *R = new sim4polishReader("-");
29 sim4polish *p = 0L;
30
31 while (R->nextAlignment(p)) {
32 fprintf(S, uint32FMT" "uint32FMT"\n", p->_percentIdentity, p->_querySeqIdentity);
33
34 i[p->_percentIdentity]++;
35 c[p->_querySeqIdentity]++;
36 }
37
38 for (int x=0; x<101; x++) {
39 fprintf(C, "%d\n", c[x]);
40 fprintf(I, "%d\n", i[x]);
41 }
42
43 fclose(C);
44 fclose(I);
45 fclose(S);
46
47 return(0);
48 }