11 str medium = strtok(setting,
" "),
12 low = strtok(NULL,
" "),
13 high = strtok(NULL,
" ");
15 if (medium && low && high) {
16 double med_val = atof(medium),
18 high_val = atof(high);
20 if (med_val<=0.0 || med_val>=1.0) {
21 setCfgError(
"The average value has to be BETWEEN 0.0 and 1.0");
25 double change = fabs(low_val)+fabs(high_val);
27 if (change>=med_val || change>=(1.0-med_val)) {
28 setCfgError(
"The sum of low and high frequent part is too big and "
29 "reaches one of the borders of the allowed range ]0.0, 1.1[");
40 setCfgError(
"Syntax is: <meanvalue> <lowfreqpart> <highfreqpart>");
45 *((
int*)intPtr) = atoi(setting);
49 double *dptr = (
double*)doublePtr;
51 *dptr = atof(setting);
53 if (*dptr<0.0 || *dptr>1.0) {
54 setCfgError(
"Probability has to be between 0.0 and 1.0");
87 {
"OriginLen",
"3000",
decodeInt, &
orgLen,
"Number of base positions in origin species" },
88 {
"OriginHelixPart",
"0.5",
decodeProb, &
orgHelixPart,
"size of helical part in origin species (0.5 means 50% helix and 50% loop regions)" },
89 {
"MutRatePerBase",
"0.5 0.01 0.4",
decodeFrand, &
mrpb_Init,
"mutation rate per base position (used for origin only)" },
90 {
"Loop2HelixRate",
"0.2 0.01 0.1",
decodeFrand, &
l2hrpb_Init,
"loop<->helix conversion rate per base position (used for origin only)" },
98 {
"PairPart",
"0.85 0.1 0.01",
decodeFrand, &
pairPart,
"part of pairing helix positions (mean value, low frequent part, high frequent part)" },
100 {
"SplitProb",
"0.2 0.1 0.01",
decodeFrand, &
splitRate,
"split rate (split into two species)" },
void readSimCfg(cstr fname)
static struct S_cfgLine cfg_lines[]
int readCfg(cstr fname, struct S_cfgLine line[])
Frand initFrand(double medium, double low, double high)
static int decodeInt(str setting, void *intPtr)
static void errorf(const char *format,...) __attribute__((format(__printf__
static int decodeFrand(str setting, void *frandPtr)
void setCfgError(cstr message)
static int decodeProb(str setting, void *doublePtr)