forked from andrelmartins/TwoBit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_freq.c
40 lines (31 loc) · 791 Bytes
/
main_freq.c
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
37
38
39
40
#include "twobit.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char ** argv) {
char * filename;
TwoBit * tb;
char * name;
double * freqs;
int i;
if (argc != 3) {
printf("twoBitFreq - Compute base frequencies of a given sequence\n\n");
printf("Usage: %s <2bit filename> <name>\n", argv[0]);
return EXIT_FAILURE;
}
filename = argv[1];
name = argv[2];
tb = twobit_open(filename);
if (tb == NULL) {
fprintf(stderr, "Failed to open: %s\n", filename);
return EXIT_FAILURE;
}
freqs = twobit_base_frequencies(tb, name);
printf("%s base frequencies (ACGT):", name);
for (i = 0; i < 4; ++i)
printf(" %g", freqs[i]);
putc('\n', stdout);
/* free resources */
free(freqs);
twobit_close(tb);
return EXIT_SUCCESS;
}