2 * bl2exp, extract blast E-values from blastp output
4 * Copyright (C) 2012 Ali Gholami Rudi <ali at rudi dot ir>
6 * This program is released under the modified BSD license.
14 static char *readword(char *d
, char *s
)
18 while (*s
&& !isspace(*s
))
24 static int readentries(void)
33 if (!fgets(line
, sizeof(line
), stdin
))
35 if (!strncmp(line
, "Query= ", 6)) {
36 readword(query
, line
+ 7);
41 if (!fgets(line
, sizeof(line
), stdin
))
43 if (!strncmp(line
, "Sequences producing", 16))
45 if (!strncmp(line
, " ***** No hits found", 16))
48 fgets(line
, sizeof(line
), stdin
);
50 if (!fgets(line
, sizeof(line
), stdin
))
52 if (sscanf(line
, "%s %d %s", other
, &junk
, s_score
) != 3)
54 sprintf(line
, "%s%s", s_score
[0] == 'e' ? "1" : "", s_score
);
55 sscanf(line
, "%lf", &score
);
57 printf("%s\t%s\t%lg\n", query
, other
, score
);
62 int main(int argc
, char *argv
[])
65 printf("usage: %s <blast >e_values\n", argv
[0]);
68 while (!readentries())