static void read_int22(int use_dna_params, tab8_t *t) { fill8(t, NOT_A_NUMBER); FILE *f = parfile("int22", use_dna_params); look_for_line_containing(f, "5' ------> 3'"); char buf[MAXLINE+1]; while (fgets(buf, MAXLINE, f)) { if (strlen(buf) >= MAXLINE) die("read_int22: line too long"); if (is_only_whitespace(buf)) continue; look_for_line_containing(f, "5' ------> 3'"); char a[4]; if (!(fgets(buf, MAXLINE, f) && sscanf(buf, " %c \\/ \\_/ %c", &a[0], &a[1]) == 2)) die("read_int22: couldn't read first line"); if (!(fgets(buf, MAXLINE, f) && sscanf(buf, " %c /\\ | %c", &a[2], &a[3]) == 2)) die("read_int22: couldn't read second line"); expect_line_containing(f, "3' <------ 5'"); int i, j; base_t b[4]; for (i = 0; i < 4; i++) b[i] = base_from_char(a[i]); for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { int_t val[16]; read_next_values(f, val, 16); int k, l; for (k = 0; k < 4; k++) for (l = 0; l < 4; l++) (*t)[b[0]][b[1]][b[2]][b[3]][i][k][j][l] = val[4*k+l]; } } fclose(f); }
static void read_int21(int use_dna_params, tab7_t *t) { fill7(t, NOT_A_NUMBER); FILE *f = parfile("int21", use_dna_params); look_for_line_containing(f, "5' --> 3'"); char buf[MAXLINE+1]; while (fgets(buf, MAXLINE, f)) { if (strlen(buf) >= MAXLINE) die("read_int21: line too long"); if (is_only_whitespace(buf)) continue; look_for_line_containing(f, "5' --> 3'"); expect_line_containing(f, "X"); base_t b1[12], b2[12], b3[6]; read_next_line(f, buf); read_twelve_bases(buf, b1); read_next_line(f, buf); read_twelve_bases(buf, b2); read_next_line(f, buf); read_six_bases(buf, b3); expect_line_containing(f, "3' <-- 5'"); int i; for (i = 0; i < 4; i++) { int_t val[24]; read_next_values(f, val, 24); int j, k; for (j = 0; j < 6; j++) for (k = 0; k < 4; k++) (*t)[b1[2*j]][b2[2*j]][i][k][b3[j]][b1[2*j+1]][b2[2*j+1]] = val[4*j+k]; } } fclose(f); }
static void read_dangle(int use_dna_params, tab3_t *d3p, tab3_t *d5p) { fill3(d3p, NOT_A_NUMBER); fill3(d5p, NOT_A_NUMBER); FILE *f = parfile("dangle", use_dna_params); char buf[MAXLINE+1]; while (fgets(buf, MAXLINE, f)) { if (strlen(buf) >= MAXLINE) die("read_dangle: line too long"); if (is_only_whitespace(buf)) continue; look_for_line_containing(f, "5' --> 3'"); read_next_line(f, buf); tab3_t *d = strchr(buf,'X') ? d3p : d5p; base_t a[4], b[4]; read_four_bases(buf, a); read_next_line(f, buf); read_four_bases(buf, b); expect_line_containing(f, "3' <-- 5'"); int_t val[16]; read_next_values(f, val, 16); int i, j; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) (*d)[a[i]][b[i]][j] = val[4*i+j]; } fclose(f); }
static void read_miscloop(param_t p) { FILE *f = parfile("miscloop", p->use_dna_params); p->Extrapolation_for_large_loops = next_value(f); p->prelog = 10.79f; p->maximum_correction = next_value(f); p->fm_array_first_element = next_value(f); int_t tmp[3]; look_for_arrow(f); read_next_values(f, tmp, 3); p->a = p->multibranched_loop_offset = tmp[0]; p->b = p->multibranched_loop_per_nuc_penalty = tmp[1]; p->c = p->multibranched_loop_helix_penalty = tmp[2]; p->a_2c = p->a + 2*p->c; p->a_2b_2c = p->a + 2*p->b + 2*p->c; look_for_arrow(f); /* skip efn2 params */ look_for_arrow(f); /* skip multiloop asym */ look_for_arrow(f); /* skip multiloop strain */ p->terminal_AU_penalty = next_value(f); p->bonus_for_GGG_hairpin = next_value(f); p->c_hairpin_slope = next_value(f); p->c_hairpin_intercept = next_value(f); p->c_hairpin_of_3 = next_value(f); look_for_arrow(f); /* skip Intermolecular initiation */ p->Bonus_for_Single_C_bulges_adjacent_to_C = next_value(f); fclose(f); }
static void read_loop(param_t p) { FILE *f = parfile("loop", p->use_dna_params); look_for_dashes(f); char buf[MAXLINE+1]; int i; for (i = 0; i <= LOOP_MAX; i++) { p->internal_loop_initiation[i] = NOT_A_NUMBER; p->bulge_loop_initiation[i] = NOT_A_NUMBER; p->hairpin_loop_initiation[i] = NOT_A_NUMBER; } while (fgets(buf, MAXLINE, f)) { if (strlen(buf) >= MAXLINE) die("read_loop: line too long"); char fld[4][MAXLINE]; if (sscanf(buf, "%s%s%s%s", fld[0], fld[1], fld[2], fld[3]) != 4) die("read_loop: could not find 4 fields"); const int i = atoi(fld[0]); if (i <= 0 || i > LOOP_MAX) die("read_loop: index out of range"); p->internal_loop_initiation[i] = value_from_string(fld[1]); p->bulge_loop_initiation[i] = value_from_string(fld[2]); p->hairpin_loop_initiation[i] = value_from_string(fld[3]); } fclose(f); }
static void read_stack(const char *name, int use_dna_params, tab4_t *p) { fill4(p, NOT_A_NUMBER); const int coaxial = !strcmp(name,"coaxial"); FILE *f = parfile(name, use_dna_params); look_for_line_containing(f, "STACKING ENERGIES"); char buf[MAXLINE+1]; int i = 0, k = 0; while (fgets(buf, MAXLINE, f)) { if (strlen(buf) >= MAXLINE) die("read_stack: line too long"); if (!strchr(buf,'.')) continue; int j = 0, l = 0; char *b; for (b = strtok(buf,whitespace); b; b = strtok(0,whitespace)) { if (coaxial) (*p)[j][i][k][l] = value_from_string(b); else (*p)[i][j][k][l] = value_from_string(b); l++; if (l == NBASE) { j++; l = 0; } } k++; if (k == NBASE) { i++; k = 0; } } fclose(f); }
void initial_params::save() { adstring extension; if (current_phase == max_number_phases) { extension = "ar"; } else if (current_phase >= 10) { extension = str(current_phase); } else { extension = "0" + str(current_phase); } { adstring tadstring=ad_comm::adprogram_name + adstring(".p") + extension; ofstream parfile((char*)tadstring); if (parfile.good()) { parfile << setshowpoint() << "# Number of parameters = " << initial_params::nvarcalc() << " Objective function value = " << *objective_function_value::pobjfun << " Maximum gradient component = " << objective_function_value::gmax << endl; for (int i = 0; i < num_initial_params; ++i) { varsptr[i]->save_value(parfile); } } } { adstring tadstring = ad_comm::adprogram_name + adstring(".b") + extension; uostream barfile((char*)tadstring); if (barfile.good()) { for (int i = 0; i < num_initial_params; ++i) { (varsptr[i])->bsave_value(barfile); } } } }