annotate IMSAME/src/covident.c @ 5:353e5673bcb8 draft default tip

Uploaded
author bitlab
date Mon, 17 Dec 2018 12:20:41 -0500
parents 762009a91895
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
762009a91895 Uploaded
bitlab
parents:
diff changeset
1 /*
762009a91895 Uploaded
bitlab
parents:
diff changeset
2 for i in $IMS/_distribution; do ./covident $i computed/$(basename $i); done
762009a91895 Uploaded
bitlab
parents:
diff changeset
3 gcc -O3 -D_FILE_OFFSET_BITS=64 covident.c -o covident
762009a91895 Uploaded
bitlab
parents:
diff changeset
4 **********/
762009a91895 Uploaded
bitlab
parents:
diff changeset
5
762009a91895 Uploaded
bitlab
parents:
diff changeset
6 #include <stdio.h>
762009a91895 Uploaded
bitlab
parents:
diff changeset
7 #include <stdlib.h>
762009a91895 Uploaded
bitlab
parents:
diff changeset
8 #include <string.h>
762009a91895 Uploaded
bitlab
parents:
diff changeset
9 #include <inttypes.h>
762009a91895 Uploaded
bitlab
parents:
diff changeset
10
762009a91895 Uploaded
bitlab
parents:
diff changeset
11 #define MAXLID 200
762009a91895 Uploaded
bitlab
parents:
diff changeset
12 #define OUT_MATSIZE 101
762009a91895 Uploaded
bitlab
parents:
diff changeset
13
762009a91895 Uploaded
bitlab
parents:
diff changeset
14
762009a91895 Uploaded
bitlab
parents:
diff changeset
15
762009a91895 Uploaded
bitlab
parents:
diff changeset
16 int main(int argc, char ** av){
762009a91895 Uploaded
bitlab
parents:
diff changeset
17
762009a91895 Uploaded
bitlab
parents:
diff changeset
18 if(argc != 3){ printf("USE:covident in output.MAT\n"); exit(-1); }
762009a91895 Uploaded
bitlab
parents:
diff changeset
19
762009a91895 Uploaded
bitlab
parents:
diff changeset
20
762009a91895 Uploaded
bitlab
parents:
diff changeset
21 FILE * f, * g;
762009a91895 Uploaded
bitlab
parents:
diff changeset
22 f = fopen(av[1], "rt");
762009a91895 Uploaded
bitlab
parents:
diff changeset
23 if(f == NULL){
762009a91895 Uploaded
bitlab
parents:
diff changeset
24 printf("Error opening input file\n");
762009a91895 Uploaded
bitlab
parents:
diff changeset
25 exit(-1);
762009a91895 Uploaded
bitlab
parents:
diff changeset
26 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
27 g = fopen(av[2], "wt");
762009a91895 Uploaded
bitlab
parents:
diff changeset
28 if(g == NULL){
762009a91895 Uploaded
bitlab
parents:
diff changeset
29 printf(" Error opening output file %s\n", av[2]);
762009a91895 Uploaded
bitlab
parents:
diff changeset
30 exit(-1);
762009a91895 Uploaded
bitlab
parents:
diff changeset
31 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
32
762009a91895 Uploaded
bitlab
parents:
diff changeset
33
762009a91895 Uploaded
bitlab
parents:
diff changeset
34 uint64_t matrix[OUT_MATSIZE][OUT_MATSIZE];
762009a91895 Uploaded
bitlab
parents:
diff changeset
35 uint64_t i,j;
762009a91895 Uploaded
bitlab
parents:
diff changeset
36 for(i=0;i<OUT_MATSIZE;i++){
762009a91895 Uploaded
bitlab
parents:
diff changeset
37 for(j=0;j<OUT_MATSIZE;j++){
762009a91895 Uploaded
bitlab
parents:
diff changeset
38 matrix[i][j] = 0;
762009a91895 Uploaded
bitlab
parents:
diff changeset
39 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
40 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
41 uint64_t cov, ident, len;
762009a91895 Uploaded
bitlab
parents:
diff changeset
42 while(!feof(f)){
762009a91895 Uploaded
bitlab
parents:
diff changeset
43
762009a91895 Uploaded
bitlab
parents:
diff changeset
44 if(3 != fscanf(f, "%"PRIu64" %"PRIu64" %"PRIu64, &cov, &ident, &len) && !feof(f)){ printf("Did not read 3\n"); exit(-1);}
762009a91895 Uploaded
bitlab
parents:
diff changeset
45 matrix[cov][ident]++;
762009a91895 Uploaded
bitlab
parents:
diff changeset
46
762009a91895 Uploaded
bitlab
parents:
diff changeset
47
762009a91895 Uploaded
bitlab
parents:
diff changeset
48 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
49
762009a91895 Uploaded
bitlab
parents:
diff changeset
50
762009a91895 Uploaded
bitlab
parents:
diff changeset
51 for(i=0;i<OUT_MATSIZE;i++){
762009a91895 Uploaded
bitlab
parents:
diff changeset
52 for(j=0;j<OUT_MATSIZE;j++){
762009a91895 Uploaded
bitlab
parents:
diff changeset
53 fprintf(g, "%"PRIu64"\t", matrix[i][j]);
762009a91895 Uploaded
bitlab
parents:
diff changeset
54 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
55 fprintf(g, "\n");
762009a91895 Uploaded
bitlab
parents:
diff changeset
56 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
57
762009a91895 Uploaded
bitlab
parents:
diff changeset
58 fclose(f);
762009a91895 Uploaded
bitlab
parents:
diff changeset
59 fclose(g);
762009a91895 Uploaded
bitlab
parents:
diff changeset
60 return 0;
762009a91895 Uploaded
bitlab
parents:
diff changeset
61 }
762009a91895 Uploaded
bitlab
parents:
diff changeset
62
762009a91895 Uploaded
bitlab
parents:
diff changeset
63
762009a91895 Uploaded
bitlab
parents:
diff changeset
64
762009a91895 Uploaded
bitlab
parents:
diff changeset
65