cuikbiominimize.c
Go to the documentation of this file.
1 #include "bioworld.h"
2 #include "parameters.h"
3 
4 #include "atlas.h"
5 #include "filename.h"
6 #include "samples.h"
7 
8 #include <stdlib.h>
9 #include <string.h>
10 #include <time.h>
11 
77 int main(int argc, char **arg)
78 {
79  if (argc>1)
80  {
81  TBioWorld bioWorld; /* The molecular information. */
82  Tatlas atlas; /* The atlas defined during minimization. */
83  Tparameters parameters; /* Parameters used in the Cuik process. */
84 
85  Tfilename fparam;
86  Tfilename fatlas;
87 
88  double *s1; /* Starting point for the minimization. */
89 
90  TAtlasBase ab;
91 
92  /*Init parameters*/
93  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
94  fprintf(stderr,"Reading parameters from : %s\n",GetFileFullName(&fparam));
95  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
96 
97  if (!InitBioWorld(&parameters,arg[1],NO_UINT,&s1,&bioWorld))
98  Error("Could not read the molecular information");
99  free(s1);
100  CS_WD_FROM_WORLD(BioWorldWorld(&bioWorld),&ab);
101 
102  /* Read the start sample */
103  ReadOneSample(&parameters,arg[1],CS_WD_GET_NUM_SYSTEM_VARS(&ab),&s1);
104 
105  /* Minimize */
106  MinimizeOnAtlas(&parameters,arg[1],s1,&ab,100,
107  BioWorldEnergy,(void *)(&bioWorld),NULL,&atlas);
108 
109 
110  /* Save the results (the tracked paths are already saved in MinimizeOnAtlas) */
111  CreateFileName(NULL,arg[1],NULL,ATLAS_EXT,&fatlas);
112  fprintf(stderr,"Writing atlas to : %s\n",GetFileFullName(&fatlas));
113  SaveAtlas(&parameters,&fatlas,&atlas);
114 
115  /* Release memory */
116  free(s1);
117  DeleteAtlas(&atlas);
118  DeleteParameters(&parameters);
119  DeleteBioWorld(&bioWorld);
120 
121  DeleteFileName(&fparam);
122  DeleteFileName(&fatlas);
123  }
124  else
125  {
126  fprintf(stderr," Wrong number of parameters.\n");
127  fprintf(stderr," Use:\n");
128  fprintf(stderr," cuikbiominimize <problem filename>.pdb\n");
129  fprintf(stderr," where <problem filename>.pdb contains the molecular information\n");
130  fprintf(stderr," The extension for the problem file (ex. pdb) is required.\n");
131  fprintf(stderr," All the extensions managed by OpenBabel can be used\n");
132  }
133  return(EXIT_SUCCESS);
134 }
135