rangi: improve some of the comments
[rangi.git] / meval.c
blob206a636a979396556934163504c57a33dc6002ae
1 /*
2 * meval, count the complexes containing a motif
4 * Copyright (C) 2012 Ali Gholami Rudi <ali at rudi dot ir>
6 * This program is released under the modified BSD license.
7 */
8 #include <ctype.h>
9 #include <stdio.h>
10 #include <string.h>
12 #define NPROTS (1024)
13 #define NLEN (128)
15 static int readcmplx(char cmplx[][NLEN], char *s)
17 int n = 0;
18 while (*s && *s != '\t')
19 s++;
20 while (*s) {
21 char *d = cmplx[n++];
22 while (*s && !isspace(*s))
23 *d++ = *s++;
24 *d = '\0';
25 while (*s && isspace(*s))
26 s++;
28 return n;
31 int main(int argc, char *argv[])
33 char cmplx[NPROTS][NLEN];
34 char **query = argv + 1;
35 int qlen = argc - 1;
36 char line[4096];
37 int i, j;
38 int matches = 0;
39 if (!qlen) {
40 printf("usage: %s PROT1 PROT2 ... <complexes\n", argv[0]);
41 return 1;
43 while (fgets(line, sizeof(line), stdin)) {
44 int clen = readcmplx(cmplx, line);
45 for (i = 0; i < qlen; i++) {
46 for (j = 0; j < clen; j++)
47 if (!strcmp(query[i], cmplx[j]))
48 break;
49 if (j == clen)
50 break;
52 if (i == qlen)
53 matches++;
55 printf("%d\n", matches);
56 return 0;