| 1 | #include "simcfg.h" |
|---|
| 2 | |
|---|
| 3 | #ifndef __READCFG_H |
|---|
| 4 | #include "readcfg.h" |
|---|
| 5 | #endif |
|---|
| 6 | #ifndef __MATH_H |
|---|
| 7 | #include <math.h> |
|---|
| 8 | #endif |
|---|
| 9 | #ifndef __STDLIB_H |
|---|
| 10 | #include <stdlib.h> |
|---|
| 11 | #endif |
|---|
| 12 | #ifndef __STRING_H |
|---|
| 13 | #include <string.h> |
|---|
| 14 | #endif |
|---|
| 15 | #ifndef __RNS_H |
|---|
| 16 | #include "rns.h" |
|---|
| 17 | #endif |
|---|
| 18 | |
|---|
| 19 | extern struct S_cfgLine cfg_lines[]; |
|---|
| 20 | |
|---|
| 21 | /* -------------------------------------------------------------------------- */ |
|---|
| 22 | /* static int decodeFrand(str setting, void *frandPtr) */ |
|---|
| 23 | /* ------------------------------------------------------ 20.05.95 18.19 ---- */ |
|---|
| 24 | static int decodeFrand(str setting, void *frandPtr) |
|---|
| 25 | { |
|---|
| 26 | str medium = strtok(setting, " "), |
|---|
| 27 | low = strtok(NULL, " "), |
|---|
| 28 | high = strtok(NULL, " "); |
|---|
| 29 | |
|---|
| 30 | if (medium && low && high) |
|---|
| 31 | { |
|---|
| 32 | double med_val = atof(medium), |
|---|
| 33 | low_val = atof(low), |
|---|
| 34 | high_val = atof(high); |
|---|
| 35 | |
|---|
| 36 | if (med_val<=0.0 || med_val>=1.0) |
|---|
| 37 | { |
|---|
| 38 | setCfgError("Der Mittelwert muá ZWISCHEN 0.0 und 1.0 liegen"); |
|---|
| 39 | return 0; |
|---|
| 40 | } |
|---|
| 41 | else |
|---|
| 42 | { |
|---|
| 43 | double change = fabs(low_val)+fabs(high_val); |
|---|
| 44 | |
|---|
| 45 | if (change>=med_val || change>=(1.0-med_val)) |
|---|
| 46 | { |
|---|
| 47 | setCfgError("Die Summe von nieder- und hochfrequentem Anteil " |
|---|
| 48 | "ist zu groá und erreicht eine der Grenzen 0.0 " |
|---|
| 49 | "bzw. 1.0"); |
|---|
| 50 | |
|---|
| 51 | return 0; |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | *((Frand*)frandPtr) = initFrand(med_val, low_val, high_val); |
|---|
| 56 | |
|---|
| 57 | return 1; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | setCfgError("Syntax lautet: <Mittelwert> <niederfrequenter Anteil> <hochfrequenter Anteil>"); |
|---|
| 61 | |
|---|
| 62 | return 0; |
|---|
| 63 | } |
|---|
| 64 | /* -------------------------------------------------------------------------- */ |
|---|
| 65 | /* static int decodeInt(str setting, void *intPtr) */ |
|---|
| 66 | /* ------------------------------------------------------ 20.05.95 12.33 ---- */ |
|---|
| 67 | static int decodeInt(str setting, void *intPtr) |
|---|
| 68 | { |
|---|
| 69 | *((int*)intPtr) = atoi(setting); |
|---|
| 70 | return 1; |
|---|
| 71 | } |
|---|
| 72 | /* -------------------------------------------------------------------------- */ |
|---|
| 73 | /* static int decodeProb(str setting, void *doublePtr) */ |
|---|
| 74 | /* ------------------------------------------------------ 17.05.95 21.55 ---- */ |
|---|
| 75 | static int decodeProb(str setting, void *doublePtr) |
|---|
| 76 | { |
|---|
| 77 | double *dptr = (double*)doublePtr; |
|---|
| 78 | |
|---|
| 79 | *dptr = atof(setting); |
|---|
| 80 | |
|---|
| 81 | if (*dptr<0.0 || *dptr>1.0) |
|---|
| 82 | { |
|---|
| 83 | setCfgError("Wahrscheinlichkeit muá zwischen 0.0 und 1.0 liegen"); |
|---|
| 84 | return 0; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | return 1; |
|---|
| 88 | } |
|---|
| 89 | /* -------------------------------------------------------------------------- */ |
|---|
| 90 | /* void readSimCfg(cstr fname) */ |
|---|
| 91 | /* ------------------------------------------------------ 17.05.95 22:10 ---- */ |
|---|
| 92 | void readSimCfg(cstr fname) |
|---|
| 93 | { |
|---|
| 94 | int lenTeiler, |
|---|
| 95 | stepTeiler; |
|---|
| 96 | |
|---|
| 97 | if (!readCfg(fname, cfg_lines)) errorf("Fehler beim Lesen von '%s'", fname); |
|---|
| 98 | |
|---|
| 99 | lenTeiler = (int)sqrt(orgLen); |
|---|
| 100 | stepTeiler = (int)sqrt(timeSteps); |
|---|
| 101 | |
|---|
| 102 | mrpb_Init->teiler = lenTeiler; |
|---|
| 103 | l2hrpb_Init->teiler = lenTeiler; |
|---|
| 104 | pairPart->teiler = stepTeiler; |
|---|
| 105 | mutationRate->teiler = stepTeiler; |
|---|
| 106 | splitRate->teiler = stepTeiler; |
|---|
| 107 | helixGcDruck->teiler = stepTeiler; |
|---|
| 108 | helixGcRate->teiler = stepTeiler; |
|---|
| 109 | helixAtRate->teiler = stepTeiler; |
|---|
| 110 | loopGcDruck->teiler = stepTeiler; |
|---|
| 111 | loopGcRate->teiler = stepTeiler; |
|---|
| 112 | loopAtRate->teiler = stepTeiler; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | static struct S_cfgLine cfg_lines[] = |
|---|
| 116 | { |
|---|
| 117 | |
|---|
| 118 | /* /---------------------------------------\ */ |
|---|
| 119 | /* | Nur zur Initialisierung notwendig : | */ |
|---|
| 120 | /* \---------------------------------------/ */ |
|---|
| 121 | |
|---|
| 122 | { "OriginLen", "3000", decodeInt, &orgLen, "Anzahl Basen im der Ur-RNS" }, |
|---|
| 123 | { "OriginHelixPart", "0.5", decodeProb, &orgHelixPart, "Anteil helikaler Bereiche (in der Ur-RNS)" }, |
|---|
| 124 | { "MutRatePerBase", "0.5 0.01 0.4", decodeFrand, &mrpb_Init, "Mutationsrate pro Basenposition (wird nur bei Initialisierung verwendet)" }, |
|---|
| 125 | { "Loop2HelixRate", "0.2 0.01 0.1", decodeFrand, &l2hrpb_Init, "Rate pro Basenposition mit der Loop- in Helix-Bereiche bergehen und vv. (wird nur bei Initialisierung verwendet)" }, |
|---|
| 126 | { "TimeSteps", "50", decodeInt, &timeSteps, "Anzahl Zeitschritte" }, |
|---|
| 127 | { "TransitionRate", "0.5", decodeProb, &transitionRate, "Transition-Rate" }, |
|---|
| 128 | { "TransversionRate", "0.5", decodeProb, &transversionRate, "Transversion-Rate" }, |
|---|
| 129 | |
|---|
| 130 | /* /-----------------------------------------------------------------\ */ |
|---|
| 131 | /* | Parameter, welche sich whrend des Baumdurchlaufs verndern : | */ |
|---|
| 132 | /* \-----------------------------------------------------------------/ */ |
|---|
| 133 | |
|---|
| 134 | { "PairPart", "0.85 0.1 0.01", decodeFrand, &pairPart, "Gewuenschter Anteil paarender Helix-Bindungen (Mittelwert, Anteil durch niedr. Freq, hohe Freq.)" }, |
|---|
| 135 | { "MutationRate", "0.01 0.005 0.001", decodeFrand, &mutationRate, "Mutationsrate" }, |
|---|
| 136 | { "SplitProb", "0.2 0.1 0.01", decodeFrand, &splitRate, "Spaltungsrate" }, |
|---|
| 137 | { "Helix-GC-Druck", "0.72 0.11 0.01", decodeFrand, &helixGcDruck, "Anteil der G-C Bindungen im Helixbereich" }, |
|---|
| 138 | { "Helix-GC-Rate", "0.5 0.001 0.001", decodeFrand, &helixGcRate, "Verhltniss G:C im Helixbereich" }, |
|---|
| 139 | { "Helix-AT-Rate", "0.5 0.001 0.001", decodeFrand, &helixAtRate, "Verhltniss A:T im Helixbereich" }, |
|---|
| 140 | { "Loop-GC-Druck", "0.62 0.05 0.01", decodeFrand, &loopGcDruck, "Anteil der G-C Bindungen im Loopbereich" }, |
|---|
| 141 | { "Loop-GC-Rate", "0.5 0.001 0.001", decodeFrand, &loopGcRate, "Verhltniss G:C im Loopbereich" }, |
|---|
| 142 | { "Loop-AT-Rate", "0.5 0.001 0.001", decodeFrand, &loopAtRate, "Verhltniss A:T im Loopbereich" }, |
|---|
| 143 | |
|---|
| 144 | /* { "", "", decode, &, "" }, */ |
|---|
| 145 | |
|---|
| 146 | { NULL } |
|---|
| 147 | }; |
|---|
| 148 | |
|---|