2 Last changed Time-stamp: <2010-06-24 14:50:01 ivo>
3 c Christoph Flamm and Ivo L Hofacker
4 {xtof,ivo}@tbi.univie.ac.at
6 $Id: main.c,v 1.5 2008/08/28 09:40:55 ivo Exp $
15 #include "fold_vars.h"
19 #include "cache_util.h"
23 static char UNUSED rcsid[] ="$Id: main.c,v 1.5 2008/08/28 09:40:55 ivo Exp $";
24 extern void read_parameter_file(const char fname[]);
25 extern void get_from_cache(cache_entry *c);
27 /* PRIVAT FUNCTIONS */
28 static void ini_energy_model(void);
29 static void read_data(void);
30 static void clean_up(void);
33 int main(int argc, char *argv[]) {
38 process command-line optiones
40 decode_switches(argc, argv);
43 initialize energy parameters
53 perform GSV.num simulations
56 start = strdup(GAV.startform); /* remember startform for next run */
57 for (i = 0; i < GSV.num; i++) {
60 initialize or reset ringlist to start conditions
64 if (strlen(GAV.farbe)>GSV.glen) {
65 start[GSV.glen] = '\0';
66 GAV.farbe[GSV.glen] = '\0';
67 strcpy(GAV.startform,start);
68 strcpy(GAV.currform,start);
78 for (GSV.steps = 1;; GSV.steps++) {
82 take neighbourhood of current structure from cache if there
83 else generate it from scratch
85 if ( (c = lookup_cache(GAV.currform)) ) get_from_cache(c);
89 select a structure from neighbourhood of current structure
90 and make it to the new current structure.
91 stop simulation if stop condition is met.
93 if ( sel_nb() > 0 ) break;
95 /* if (GSV.grow>0) grow_chain(); */
108 static void ini_energy_model(void) {
111 GAV.subi[0] = xsubi[0];
112 GAV.subi[1] = xsubi[1];
113 GAV.subi[2] = xsubi[2];
116 xsubi[0] = GAV.subi[0];
117 xsubi[1] = GAV.subi[1];
118 xsubi[2] = GAV.subi[2];
121 dangles = GTV.dangle;
122 temperature = GSV.Temp;
123 if( GTV.Par ) read_parameter_file(GAV.ParamFile);
124 update_fold_params();
128 static void read_data(void) {
135 ctmp = get_line(stdin);
137 if (c=strchr(ctmp, '&')) {
138 cut_point = (int)(c-ctmp)+1;
139 for (; *c; c++) *c = *(c+1); /* splice out the & */
141 GAV.farbe = (char *)calloc(len+1, sizeof(char));
142 assert(GAV.farbe != NULL);
143 sscanf(ctmp, "%s", GAV.farbe);
144 GSV.len = strlen(GAV.farbe);
145 for (i = 0; i < len; i++) GAV.farbe[i] = toupper(GAV.farbe[i]);
147 /* allocate some global arrays */
148 GAV.currform = (char *)calloc(GSV.len +1, sizeof(char));
149 assert(GAV.currform != NULL);
150 GAV.prevform = (char *)calloc(GSV.len +1, sizeof(char));
151 assert(GAV.prevform != NULL);
152 GAV.startform = (char *)calloc(GSV.len +1, sizeof(char));
153 assert(GAV.startform != NULL);
159 ctmp = get_line(stdin);
161 sscanf(ctmp, "%s", GAV.startform);
162 if (c=strchr(GAV.startform, '&')) {
163 for (; *c; c++) *c = *(c+1); /* splice out the & */
166 if (strlen(GAV.startform) != GSV.len) {
168 "read_data():\n%s\n%s\n unequal length!\n",
169 GAV.farbe, GAV.startform);
174 else { /* start structure is open chain */
175 for (i = 0; i< GSV.len; i++) GAV.startform[i] = '.';
179 read stop structure(s)
183 while (( ctmp = get_line(stdin))) {
184 *s = (char *)calloc(GSV.len+1, sizeof(char));
185 sscanf(ctmp, "%s", *s);
186 if (c=strchr(ctmp, '&')) {
187 for (; *c; c++) *c = *(c+1); /* splice out the & */
190 if ( (s-GAV.stopform) >= GSV.maxS ) {
192 "WARNING: Can handle a maximum of %d stop structures\n",
197 if (strlen(*s) != GSV.len) {
198 fprintf(stderr, "read_data():\n%s\n%s\n unequal length!\n",
206 GSV.maxS = (s-GAV.stopform);
210 GAV.stopform[0] = (char *)calloc(GSV.len+1, sizeof(char));
213 GAV.farbe_full = strdup(GAV.farbe);
215 GAV.sE = (float *)calloc(GSV.maxS, sizeof(float));
219 void clean_up(void) {