| 1 |
#ifndef SEQGEN_H_ |
| 2 |
#define SEQGEN_H_ |
| 3 |
|
| 4 |
#include <stdio.h> |
| 5 |
#include <iostream> |
| 6 |
#include <fstream> |
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
using namespace std; |
| 10 |
|
| 11 |
const int alphNum = 4; |
| 12 |
const char iTb[alphNum] = {'A', 'C', 'G', 'T'}; |
| 13 |
|
| 14 |
size_t sequenceLen; |
| 15 |
|
| 16 |
void makeRead(const size_t rNum, const size_t rLen) { |
| 17 |
srand(time(NULL)); |
| 18 |
size_t bTc[alphNum] = {0, 0, 0, 0}; |
| 19 |
string myrSeq; |
| 20 |
myrSeq.resize(rLen); |
| 21 |
ofstream rFile("reads.fa"); |
| 22 |
|
| 23 |
for (size_t j=0; j < rNum; j++) { |
| 24 |
for (size_t i=0; i< rLen; i++) { |
| 25 |
int ranInd = rand() % alphNum; |
| 26 |
myrSeq[i] = iTb[ranInd]; |
| 27 |
++bTc[ranInd]; |
| 28 |
} |
| 29 |
rFile << ">f" << j << "\n" << myrSeq << "\n"; |
| 30 |
} |
| 31 |
|
| 32 |
//for (size_t i=0; i< alphNum; i++) |
| 33 |
// cerr << bTc[i] << "\n"; |
| 34 |
rFile.close(); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
void makeGenome(const size_t seqLen) { |
| 39 |
srand(time(NULL)); |
| 40 |
size_t bTc[alphNum] = {0, 0, 0, 0}; |
| 41 |
string mygSeq; |
| 42 |
mygSeq.resize(seqLen); |
| 43 |
for (size_t i=0; i< seqLen; i++) { |
| 44 |
int ranInd = rand() % alphNum; |
| 45 |
mygSeq[i] = iTb[ranInd]; |
| 46 |
++bTc[ranInd]; |
| 47 |
} |
| 48 |
ofstream gFile("genome.fa"); |
| 49 |
gFile << ">1\n" << mygSeq << "\n"; |
| 50 |
//for (int i=0; i< alphNum; i++) |
| 51 |
// cerr << bTc[i] << "\n"; |
| 52 |
gFile.close(); |
| 53 |
} |
| 54 |
|
| 55 |
void makeGene(const size_t gNum, const size_t gLen) { |
| 56 |
srand(time(NULL)); |
| 57 |
size_t bTc[alphNum] = {0, 0, 0, 0}; |
| 58 |
string mygSeq; |
| 59 |
mygSeq.resize(gLen); |
| 60 |
ofstream gFile("genes.fa"); |
| 61 |
for (size_t j=0; j < gNum; j++) { |
| 62 |
for (size_t i=0; i< gLen; i++) { |
| 63 |
int ranInd = rand() % alphNum; |
| 64 |
mygSeq[i] = iTb[ranInd]; |
| 65 |
++bTc[ranInd]; |
| 66 |
} |
| 67 |
} |
| 68 |
gFile.close(); |
| 69 |
} |
| 70 |
|
| 71 |
void makeGene(const size_t gNum, const size_t gLen, const size_t rNum, const size_t rLen) { |
| 72 |
srand(time(NULL)); |
| 73 |
size_t bTc[alphNum] = {0, 0, 0, 0}; |
| 74 |
string mygSeq; |
| 75 |
mygSeq.resize(gLen); |
| 76 |
ofstream gFile("genes.fa"); |
| 77 |
ofstream rFile("treads.fa"); |
| 78 |
for (size_t j=0; j < gNum; j++) { |
| 79 |
for (size_t i=0; i< gLen; i++) { |
| 80 |
int ranInd = rand() % alphNum; |
| 81 |
mygSeq[i] = iTb[ranInd]; |
| 82 |
++bTc[ranInd]; |
| 83 |
} |
| 84 |
gFile << ">g" << j << "\n" << mygSeq << "\n"; |
| 85 |
for(size_t k=0; k<rNum/gNum; k++) { |
| 86 |
int ranR = rand() % (gLen-rLen+1); |
| 87 |
rFile << ">t" << k << "\n" << mygSeq.substr(ranR, rLen) << "\n"; |
| 88 |
} |
| 89 |
|
| 90 |
} |
| 91 |
gFile.close(); |
| 92 |
rFile.close(); |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
int testseqgen() { |
| 97 |
//makeGenome(3000000000+32-1); |
| 98 |
makeRead(1000000000, 32); |
| 99 |
makeGene(50, 2000000+32-1); |
| 100 |
//makeGene(6, 50+32-1); |
| 101 |
return 0; |
| 102 |
} |
| 103 |
|
| 104 |
#endif |