Created
August 31, 2015 18:31
-
-
Save codepainkiller/41d6aee07b8bf02080af to your computer and use it in GitHub Desktop.
Kilobases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
string kilobases() | |
{ | |
float kb = 0.03; | |
float gc = 0.5; | |
int longitud = kb * 1000; | |
int cantidadGC = ((gc * 100) * longitud) / 100; | |
string secuencia(longitud, 'x'); | |
cout << "cantidad de GC = " << cantidadGC << endl; | |
int i = 0; | |
int index = 0; | |
while (i < cantidadGC) | |
{ | |
index = rand()%longitud; | |
if (secuencia.at(index) == 'x') | |
{ | |
if (rand()%2 == 0) | |
secuencia.replace(index, 1, "G"); | |
else | |
secuencia.replace(index, 1, "C"); | |
i++; | |
} | |
} | |
for(i = 0; i < secuencia.size(); i++) | |
{ | |
if (secuencia.at(i) == 'x') | |
{ | |
if (rand()%2 == 0) | |
secuencia.replace(i, 1, "A"); | |
else | |
secuencia.replace(i, 1, "T"); | |
} | |
} | |
return secuencia; | |
} | |
int main() | |
{ | |
srand(time(0)); | |
cout << kilobases() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment