-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadsGenerator.c
49 lines (37 loc) · 1.03 KB
/
readsGenerator.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
44
45
46
47
// readsGenerator.c
// Generate random reads
// Version 0.0
//
// Heng Wang
// National University of Defense Technology
// 2014/10/09
//
/////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define READ_LENGTH 100
#define ConvertInt2char(i) (i) == 0 ? 'A' : ((i) == 1 ? 'C' : ((i) == 2 ? 'G' : 'T'))
char singleRead[READ_LENGTH];
//unsigned baseCount[4] = {0};
void GenerateReads(int readLen, unsigned long long readsNum);
int main(int argc, char ** argv){
//int readLen = atoi(argv[1]);
int readLen = READ_LENGTH;
unsigned long long readsNum = atoi(argv[1]);
GenerateReads(readLen, readsNum);
return 0;
}
void GenerateReads(int readLen, unsigned long long readsNum){
unsigned long long readIndex;
for(readIndex = 0; readIndex < readsNum; readIndex++){
srand(readIndex);
int baseId;
for(baseId = 0; baseId < readLen; baseId++){
int tmp = rand()%4;
singleRead[baseId] = ConvertInt2char(tmp);
//baseCount[tmp]++;
}
printf("%s\n", singleRead);
}
}