Skip to content

Instantly share code, notes, and snippets.

@codepainkiller
Created August 31, 2015 18:31
Show Gist options
  • Save codepainkiller/41d6aee07b8bf02080af to your computer and use it in GitHub Desktop.
Save codepainkiller/41d6aee07b8bf02080af to your computer and use it in GitHub Desktop.
Kilobases
#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