1 #include <stdint.h> /* - Basically we save the 4 frequencies in a 64bit int */
2 #include <stdio.h> /* - The polynome fits the following coordinates: */
3 #include <stdlib.h> /* (65,0), (67, 16), (71, 32), (84, 48) */
4 #include <string.h> /* - Which is the mapping from ascii value and shiftwidth*/
5 /* - When no input file is given assume stdin */
6 int main(int argc
, char* argv
[])
12 FILE *f
= (argc
!=2 || strcmp(argv
[1], "-")==0) ? stdin
: fopen(argv
[1], "r");
15 while((c
=fgetc(f
)) != EOF
)
16 if(c
== '\n' && charsperline
== 100 && numlines
++ < 500)
18 else if((c
=='A' ||c
=='C' || c
=='G' || c
=='T') && charsperline
++<100)
19 occs
+= 1LL<<(char)(0.026514*c
*c
*c
-6.049*c
*c
+459.96*c
-11621.2);
26 printf("A:%u\nC:%u\nG:%u\nT:%u\n", (uint16_t)occs
, (uint16_t)(occs
>>16),
27 (uint16_t)(occs
>>32), (uint16_t)(occs
>>48));