-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfasta2kmer.c
43 lines (33 loc) · 861 Bytes
/
fasta2kmer.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
41
42
43
#include<stdio.h>
#include"dataset.h"
#include"kmers.h"
int main(int argc, char** argv) {
size_t length;
dataset ds;
kmer_frequencies freq;
int i;
int n_threads;
int protein;
FILE* in = fopen(argv[1],"r");
if(argc < 3) {
printf("Arguments are: \n"
" [file] fasta file \n"
" [int] kmer length \n"
" [int] number of threads \n"
" [int] protein ? if yes 1 otherwise 0) \n");
return(1);
}
if(in == NULL) {
printf("Could not open fasta file %s \n", argv[1]);
return(1);
}
sscanf(argv[2],"%lu", &length);
sscanf(argv[3],"%d", &n_threads);
sscanf(argv[4],"%i", &protein);
ds = dataset_from_fasta(in);
fclose(in);
freq = frequencies_from_dataset(ds, length, n_threads,protein);
write_kmer_base(stdout, freq);
free_kmer_frequencies(freq);
free_sequences_from_dataset(ds);
}