blob: d1a4f1c14105ab85a1484766ce80a2b243aa11ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2013 Calvin Morrison
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
int main(int argc, char **argv) {
if(argc != 2) {
printf("Please supply a filename, and only a filename\n");
exit(EXIT_FAILURE);
}
FILE *fh = fopen(argv[1], "r" );
if(fh == NULL) {
fprintf(stderr, "Couldn't open: %s\n", argv[1]);
exit(EXIT_FAILURE);
}
char line[8192];
long unsigned long counts[256];
while (fgets(line, 8192, fh) != NULL) {
unsigned int i = 0;
for(i = 0; i < strlen(line); i++) {
counts[line[i]]++;
}
}
printf("A:%llu\nC:%llu\nG:%llu\nT:%llu\n",
counts['a'] + counts['A'],
counts['c'] + counts['C'],
counts['g'] + counts['G'],
counts['t'] + counts['T']);
return EXIT_SUCCESS;
}
|