cuikpdb2sample.c
Go to the documentation of this file.
1 #include "defines.h"
2 #include "filename.h"
3 #include "bioworld.h"
4 
5 #include <stdlib.h>
6 
59 int main(int argc, char **arg)
60 {
61  if (argc>1)
62  {
63  Tparameters parameters;
64  TBioWorld bioWorld;
65 
66  Tfilename fparam;
67  Tfilename fsamples;
68 
69  boolean nv;
70  double *sample;
71 
72  unsigned int i,r;
73 
74  FILE *fout;
75 
76  /* Init parameters */
77  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
78  fprintf(stderr,"Reading parameters : %s\n",GetFileFullName(&fparam));
79  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
80 
81  /* Read the problem file */
82  InitBioWorld(&parameters,arg[1],NO_UINT,&sample,&bioWorld);
83  nv=BioWorldConformationSize(&bioWorld);
84 
85  /* Open the file where to store the output sample */
86  r=(unsigned int)(GetParameter(CT_REPRESENTATION,&parameters));
87  if (r==REP_JOINTS)
88  CreateFileName(NULL,arg[1],"_pdb",JOINTS_EXT,&fsamples);
89  else
90  CreateFileName(NULL,arg[1],"_pdb",LINKS_EXT,&fsamples);
91  fprintf(stderr,"Writing sample to : %s\n",GetFileFullName(&fsamples));
92 
93  fout=fopen(GetFileFullName(&fsamples),"w");
94  if (!fout)
95  Error("Could not open the file to write the sample");
96 
97  /* Save the conformation */
98  for(i=0;i<nv;i++)
99  fprintf(fout,"%.16f ",sample[i]);
100  fprintf(fout,"\n");
101 
102  /* Close the files */
103  fclose(fout);
104 
105  /* Release memeory */
106  free(sample);
107 
108  DeleteBioWorld(&bioWorld);
109  DeleteParameters(&parameters);
110 
111  DeleteFileName(&fparam);
112  DeleteFileName(&fsamples);
113  }
114  else
115  {
116  fprintf(stderr," Wrong number of parameters.\n");
117  fprintf(stderr," Use:\n");
118  fprintf(stderr," cuikpdb2sample <problem_name>.pdb\n");
119  fprintf(stderr," where:\n");
120  fprintf(stderr," <problem_name>.pdb the prefix to define the bio-info.\n");
121  fprintf(stderr," The extension (e.g., '.pdb') is required\n");
122  fprintf(stderr," All the extensions managed by OpenBabel can be used\n");
123  fprintf(stderr," The output is stored in <proble_name>_pdb.dof\n");
124  fprintf(stderr," or in <proble_name>_pdb.sample depending on the representation used\n");
125  }
126 
127  return(EXIT_SUCCESS);
128 }
void InitBioWorld(Tparameters *p, char *filename, unsigned int maxAtomsLink, double **conformation, TBioWorld *bw)
Initializes a world form a biomolecule.
Definition: bioworld.c:1394
#define REP_JOINTS
One of the possible values of the REPRESENTATION parameter.
Definition: parameters.h:60
void DeleteBioWorld(TBioWorld *bw)
Destructor.
Definition: bioworld.c:1918
Data structure to hold the information about the name of a file.
Definition: filename.h:248
Definition of the Tfilename type and the associated functions.
void Error(const char *s)
General error function.
Definition: error.c:80
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:131
int main(int argc, char **arg)
Main body of the cuikpdb2sample application.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
Definitions of constants and macros used in several parts of the cuik library.
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
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
#define CT_REPRESENTATION
Representation.
Definition: parameters.h:215
#define JOINTS_EXT
File extension for files with samples represented by the joint values.
Definition: filename.h:187
#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:295
Structure with the molecular and the mechanical information.
Definition: bioworld.h:28
double GetParameter(unsigned int n, Tparameters *p)
Gets the value for a particular parameter.
Definition: parameters.c:93
#define LINKS_EXT
File extension for files with samples represented by the link poses.
Definition: filename.h:180
unsigned int BioWorldConformationSize(TBioWorld *bw)
Number of variables used to represent a conformation.
Definition: bioworld.c:1812