56 printf(
"Minimale Baumtiefe = %i\n", minDepth);
57 printf(
"Maximale Baumtiefe = %i\n",
maxDepth);
71 for (b2 = 0; b2<(
BASETYPES+1); b2++) h_cnt[b1][b2] = 0;
82 for (b = 0; b<(rns->
bases); b++) {
83 char base = rns->
base[b];
102 printf(
"Helix-Basenpaare = %i\n"
107 (
double)helix/(
double)loop);
114 printf(
"GC-Paare = %i\n"
116 "Paare:Helix-Bindungen = %f\n"
117 "GC-Paare:Paare = %f\n",
120 (
double)paarend/(
double)helix,
121 (
double)gc/(
double)paarend);
131 mrpb_allocated = bases;
135 l2hrpb_allocated = bases;
140 for (b = 0; b<bases; b++) {
146 RNS rns = malloc(
sizeof(*rns));
151 rns->
base = malloc(
sizeof(*(rns->
base))*len);
164 printf(
"Generating origin species..\n");
168 rns->
laufNr = rnsCreated++;
173 if (helixLen%1) helixLen--;
177 rns->
helix = helixLen/2;
185 double actPairPart =
getFrand(pairPart),
186 actHelixGcDruck =
getFrand(helixGcDruck),
187 actHelixGcRate =
getFrand(helixGcRate),
188 actHelixAtRate =
getFrand(helixAtRate),
189 nonPairProb = (1.0-actPairPart)/2.0;
197 orgHelixProb[b1][b2] = (actPairPart*(1.0-actHelixGcDruck))/2.0;
202 orgHelixProb[b1][b2] = (actPairPart*actHelixGcDruck)/2.0;
208 double prob = nonPairProb;
214 prob = prob*(1.0-actHelixGcDruck)*actHelixAtRate;
218 prob = prob*actHelixGcDruck*(1.0-actHelixGcRate);
222 prob = prob*actHelixGcDruck*actHelixGcRate;
226 prob = prob*(1.0-actHelixGcDruck)*(1.0-actHelixAtRate);
235 orgHelixProb[b1][b2] = prob;
242 for (l = 0; l<helixLen; l+=2) {
262 double actLoopGcDruck =
getFrand(loopGcDruck),
263 actLoopGcRate =
getFrand(loopGcRate),
264 actLoopAtRate =
getFrand(loopAtRate);
266 orgLoopProb[
BASE_A] = (1.0-actLoopGcDruck)*actLoopAtRate;
267 orgLoopProb[
BASE_C] = actLoopGcDruck*(1.0-actLoopGcRate);
268 orgLoopProb[
BASE_G] = actLoopGcDruck*actLoopGcRate;
269 orgLoopProb[
BASE_T] = (1.0-actLoopGcDruck)*(1.0-actLoopAtRate);
283 RNS neu = malloc(
sizeof(*rns));
287 memcpy(neu, rns,
sizeof(*rns));
292 neu->
laufNr = rnsCreated++;
298 fa = (1.0-gcDruck)*atRate,
299 fc = gcDruck*(1.0-gcRate),
301 ft = (1.0-gcDruck)*(1.0-atRate),
343 mutatesTo[nach] = 0.0;
347 mutatesTo[nach] += mutationMatrix[von][nach]*freq[von];
358 double failProb = 1.0-pairProb,
361 while (succProb<actPairPart) {
362 pairProb *= failProb;
363 succProb += pairProb;
369 static void mutateRNS(
int no_of_father,
RNS rns,
int steps,
int depth) {
374 double mutationTime = 0.0;
380 double actualSplitRate =
getFrand(splitRate);
382 assert(actualSplitRate!=0);
384 splitInSteps = (
int)(1.0/actualSplitRate);
385 if (splitInSteps>steps) splitInSteps = steps;
393 for (s = 0; s<splitInSteps; s++) {
396 double actMutationRate =
getFrand(mutationRate),
415 mutationTime += actMutationRate;
420 for (b = 0; b<(rns->
bases);) {
421 char base = rns->
base[b];
428 int trials = pairTrials,
431 char base2 = rns->
base[b+1];
491 splitRNS(no_of_father, rns, mutationTime, steps-splitInSteps, depth+1);
493 void splitRNS(
int no_of_father,
RNS origin,
double age,
int steps,
int depth) {
502 if (no_of_father != -1) {
503 fprintf(
seq,
">no%i son of no%i\n", origin->
laufNr, no_of_father);
506 fprintf(
seq,
">no%i father of all species\n", origin->
laufNr);
508 no_of_father = origin->
laufNr;
513 double gcDruck_val = helixGcDruck->
val,
514 pairPart_val = pairPart->
val,
515 mutationRate_val = mutationRate->
val,
516 splitRate_val = splitRate->
val;
518 fprintf(
topo,
"(no%i:%f,\n", origin->
laufNr, age);
523 mutateRNS(no_of_father, left, steps, depth);
529 helixGcDruck->
val = gcDruck_val;
530 pairPart->
val = pairPart_val;
531 mutationRate->
val = mutationRate_val;
532 splitRate->
val = splitRate_val;
537 mutateRNS(no_of_father, right, steps, depth);
545 else if (depth<minDepth) minDepth = depth;
547 fprintf(
topo,
"no%i:%f", origin->
laufNr, age);
549 if ((origin->
laufNr%100) == 0) {
550 printf(
"generated Species: %i\n", origin->
laufNr);
static DoubleProb helixMutationMatrix
char loopBaseChar[BASECHARS]
double SingleProb[BASETYPES]
void freeSpreading(Spreading s)
static RNS dupRNS(RNS rns)
static int l2hrpb_allocated
static void dumpRNS(RNS rns)
char helixBaseChar[BASECHARS]
static int calcPairTrials(double pairProb, double actPairPart)
static int mrpb_allocated
double DoubleProb[BASETYPES][BASETYPES]
static void initBaseSpecificProbs(int bases)
static double * loop2helixRatePerBase
static void calcMutationMatrix(DoubleProb mutationMatrix, double gcDruck, double gcRate, double atRate, double *pairProb)
static double * mutationRatePerBase
#define isPairing(b1, b2)
static RNS allocRNS(int len)
fputs(TRACE_PREFIX, stderr)
Spreading newSpreading(double *value, int values)
int spreadRand(Spreading s)
static DoubleProb loopMutationMatrix
void splitRNS(int no_of_father, RNS origin, double age, int steps, int depth)
static void mutateRNS(int no_of_father, RNS rns, int steps, int depth)
GB_write_int const char s