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 
void DeleteBioWorld(TBioWorld *bw)
Destructor.
Definition: bioworld.c:1924
double BioWorldEnergy(Tparameters *p, boolean simp, double *conformation, void *bw)
Computes the energy of a given configuration.
Definition: bioworld.c:1902
Data structure to hold the information about the name of a file.
Definition: filename.h:271
Definition of the Tfilename type and the associated functions.
void DeleteAtlas(Tatlas *a)
Destructor.
Definition: atlas.c:4634
void Error(const char *s)
General error function.
Definition: error.c:80
boolean MinimizeOnAtlas(Tparameters *pr, char *fname, double *p, TAtlasBase *w, unsigned int maxSteps, double(*costF)(Tparameters *, boolean, double *, void *), void(*costG)(Tparameters *, boolean, double *, double **, void *), void *costData, Tatlas *a)
Gradient minimization on an manifold.
Definition: atlas.c:3153
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:132
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
#define ATLAS_EXT
File extension for files storing atlas.
Definition: filename.h:200
int main(int argc, char **arg)
Main body of the cuikbiominimize application.
boolean InitBioWorld(Tparameters *p, char *filename, unsigned int maxAtomsLink, double **conformation, TBioWorld *bw)
Initializes a world form a biomolecule.
Definition: bioworld.c:1394
A table of parameters.
void CreateFileName(char *path, char *name, char *suffix, char *ext, Tfilename *fn)
Constructor.
Definition: filename.c:22
A bridge between world structures and biological information.
void InitParametersFromFile(char *file, Tparameters *p)
Constructor from a file.
Definition: parameters.c:51
Type defining the equations on which the atlas is defined.
Definition: wcs.h:30
Definition of an atlas on a manifold.
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
A atlas on a manifold.
Definition: atlas.h:289
#define NO_UINT
Used to denote an identifier that has not been initialized.
Definition: defines.h:435
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:294
void SaveAtlas(Tparameters *pr, Tfilename *fname, Tatlas *a)
Stores the atlas information on a file.
Definition: atlas.c:3946
Structure with the molecular and the mechanical information.
Definition: bioworld.h:28
#define CS_WD_GET_NUM_SYSTEM_VARS(wcs)
Gets the number of system variables.
Definition: wcs.h:264
Auxiliary functions to deal with sets of samples.
#define CS_WD_FROM_WORLD(ptr, wcs)
Initializes the equations from a world structure.
Definition: wcs.h:108
Definition of the Tparameters type and the associated functions.
Tworld * BioWorldWorld(TBioWorld *bw)
Returns a pointer to the world generated from the bio-information.
Definition: bioworld.c:1807
unsigned int ReadOneSample(Tparameters *p, char *fname, unsigned int nvs, double **s)
Reads one sample from a file.
Definition: samples.c:2772