GLYLIB  0.3.0b
initialize_GLYstruct.c
Go to the documentation of this file.
00001 /** \file initialize_GLYstruct.c 
00002  * Provides initialization functions for structures in molecules.h
00003  *
00004  * Probably needs some serious updating (20080813, BLF).
00005  *
00006  * NOTES:       char* variables are not initialized
00007  *              char** are treated like "all other pointers" (below)
00008  *              void pointers are not initialized
00009  *              all other pointers:
00010  *                      -- the number of pointers integer is set to zero
00011  *                      -- one pointer is calloc'd (in anticipation of realloc)
00012  * 
00013  * begun on 20071207 by BLFoley 
00014  */
00015 #include <mylib.h>
00016 #include <molecules.h>
00017 //#include "../inc/mylib.h"
00018 //#include "../inc/molecules.h"
00019 
00020 #define INDEX_INIT -100000000 ///< To catch use of un-set indices early on.
00021 
00022 void initialize_coord_3D(coord_3D *c) {
00023 c[0].i=c[0].j=c[0].k=0; 
00024 return;
00025 }
00026 
00027 void initialize_vectormag_3D(vectormag_3D *v) {
00028 v[0].i=v[0].j=v[0].k=v[0].d=0; 
00029 return;
00030 }
00031 
00032 void initialize_plane(plane *p) {
00033 p[0].A=p[0].B=p[0].C=p[0].D=0;
00034 return;
00035 }
00036 
00037 void initialize_atype(atype *at) {
00038 at[0].n=0; // atomic number
00039 at[0].nb=0; // number of typical bonds for this atom type
00040 at[0].nlp=0; // number of typical lone pairs (to check geometry sanity)
00041 at[0].m=0; // mass of element type
00042 at[0].bo=(double*)calloc(1,sizeof(double)); // typical bond orders (nb of these)
00043 return;
00044 } 
00045 
00046 void initialize_rtype(rtype *rt) {
00047 rt[0].c=0; // main class (amino acid, glycan, solvent, etc.)
00048 rt[0].nac=0;// number alternate classes
00049 rt[0].ac=(int*)calloc(1,sizeof(int)); // number alternate classes, those classes
00050 rt[0].nVP=0; // number of other information
00051 return;
00052 }
00053 
00054 void initialize_mtype(mtype *mt) {
00055 mt[0].c=0; // type class (amino acid, glycan, solvent, etc.)
00056 mt[0].nVP=0; // number of other information
00057 return;
00058 }
00059 
00060 void initialize_types(types *t) {
00061 t[0].na=0; // # of atom types
00062 t[0].a=(atype*)calloc(1,sizeof(atype)); // na of these
00063 t[0].nr=0; // # of residue types
00064 t[0].r=(rtype*)calloc(1,sizeof(rtype)); // nr of these
00065 t[0].nm=0; // # of molecule types
00066 t[0].m=(mtype*)calloc(1,sizeof(mtype)); // nm of these
00067 return;
00068 }
00069 
00070 void initialize_molindex(molindex *mi) {
00071 mi[0].i=INDEX_INIT; // general index
00072 mi[0].m=INDEX_INIT; // molecule index
00073 mi[0].r=INDEX_INIT; // residue index
00074 mi[0].a=INDEX_INIT; // atom index
00075 return;
00076 }
00077 
00078 void initialize_ensindex(ensindex *ei) {
00079 ei[0].i=INDEX_INIT; // general index
00080 ei[0].E=INDEX_INIT; // ensemble
00081 ei[0].A=INDEX_INIT; // assembly
00082 ei[0].m=INDEX_INIT; // molecule index
00083 ei[0].r=INDEX_INIT; // residue index
00084 ei[0].a=INDEX_INIT; // atom index
00085 return;
00086 }
00087 
00088 void initialize_bond(bond *b) {
00089 b[0].s.m=INDEX_INIT; // "source" -- index to first atom in bond
00090 b[0].s.r=INDEX_INIT; // "source" -- index to first atom in bond
00091 b[0].s.a=INDEX_INIT; // "source" -- index to first atom in bond
00092 b[0].t.m=INDEX_INIT; // "target" -- index to the other atom in the bond
00093 b[0].t.r=INDEX_INIT; // "target" -- index to the other atom in the bond
00094 b[0].t.a=INDEX_INIT; // "target" -- index to the other atom in the bond
00095 b[0].o=0; // order of bond
00096 return;
00097 }
00098 
00099 void initialize_bondset(bondset *bs) {
00100 bs[0].n=0; // number of bonds
00101 bs[0].b=(bond*)calloc(1,sizeof(bond)); // n of these
00102 return;
00103 }
00104 
00105 void initialize_molbond(molbond *mb) {
00106 mb[0].s.i=mb[0].s.m=mb[0].s.r=mb[0].s.a=INDEX_INIT;
00107 mb[0].t.i=mb[0].t.m=mb[0].t.r=mb[0].t.a=INDEX_INIT;
00108 mb[0].o=0; // order
00109 return;
00110 }
00111 
00112 void initialize_molbondset(molbondset *mbs) {
00113 mbs[0].n=0;  // source & target atoms for bond
00114 mbs[0].b=(molbond*)calloc(1,sizeof(molbond)); // order
00115 return;
00116 }
00117 
00118 void initialize_atom(atom *a) {
00119 a[0].n=0; // atom number or other identifying index
00120 a[0].N=NULL;
00121 a[0].T=NULL;
00122 a[0].D=NULL;
00123 a[0].E=NULL; 
00124 a[0].cID=NULL; 
00125 a[0].typ=NULL; 
00126 a[0].m=0;
00127 a[0].t=0; // type number -- must correspond to assignments of "atype" (see) 
00128 initialize_molindex(&a[0].moli);
00129 a[0].nb=0; // number of actual bonds (not expected bonds)
00130 a[0].b=(bond*)calloc(1,sizeof(bond)); // bond structures (nb of these)
00131 a[0].nmb=0; // number of bonds to other residues or molecules
00132 a[0].mb=(molbond*)calloc(1,sizeof(molbond)); // nmb of these
00133 a[0].mTi=-1;
00134 a[0].rTi=-1;
00135 a[0].x.i=a[0].x.j=a[0].x.k=0; // atom's coordinates 
00136 a[0].xv.i=a[0].xv.j=a[0].xv.k=0; // atom's coordinates 
00137 a[0].nalt=0; // number of alternate coordinate sets
00138 a[0].xa=(coord_3D*)calloc(1,sizeof(coord_3D)); // nalt of alternate coords
00139 a[0].nxva=0; // number of alternate coordinate sets
00140 a[0].xva=(coord_3D*)calloc(1,sizeof(coord_3D)); // nalt of alternate coords
00141 a[0].nvec=0; // number of vector sets
00142 a[0].v=(vectormag_3D*)calloc(1,sizeof(vectormag_3D)); // vector sets
00143 a[0].nch=0;
00144 a[0].ch=(double*)calloc(1,sizeof(double));
00145 a[0].ni=0; // number of other indices
00146 a[0].i=(int*)calloc(1,sizeof(int)); // other indices, as needed (ni of these)
00147 a[0].nd=0; // number of double-precision parameters
00148 a[0].d=(double*)calloc(1,sizeof(double)); // other parameters, as needed (nd of these) 
00149 a[0].nensi=0; // number of double-precision parameters
00150 a[0].ensi=(ensindex*)calloc(1,sizeof(ensindex)); // other parameters, as needed (nd of these)
00151 a[0].nOD=0; // number of double-precision parameters
00152 a[0].OD=(char**)calloc(1,sizeof(char*)); // other parameters, as needed (nd of these) 
00153 a[0].nVP=0; // number of void structures
00154 return;
00155 }
00156 
00157 // START HERE -- UPDATE all of the residue, molecule and higher structures.
00158 void initialize_residue(residue *r) {
00159 r[0].n=0; // residue number given in input file
00160 r[0].cID=NULL;
00161 r[0].IC=NULL;
00162 r[0].N=NULL;
00163 r[0].T=NULL;
00164 r[0].D=NULL;
00165 r[0].altname=NULL;
00166 r[0].typ=NULL;
00167 r[0].t=0; // index for rtype
00168 initialize_molindex(&r[0].moli);
00169 r[0].na=0; // number of atoms in residue
00170 r[0].m=0; // molecular weight
00171 r[0].COM.i=r[0].COM.j=r[0].COM.k=0; // center of mass for molecule
00172 r[0].a=(atom*)calloc(1,sizeof(atom)); // atom structures (na of these)
00173 r[0].aT=(atom_node*)calloc(1,sizeof(atom_node)); // atom structures (na of these)
00174 r[0].nrb=0; // number of bonds to other residues or molecules
00175 r[0].rb=(molbond*)calloc(1,sizeof(molbond)); // nmb of these
00176 r[0].mTi=-1;
00177 r[0].nbs=0; // number of bond sets 
00178 r[0].bs=(molbondset*)calloc(1,sizeof(molbondset)); // (consecutive bonds, use these for plotting, etc.)
00179 r[0].nring=0; // number of simple rings (no cage structures, etc.)
00180 r[0].nrc=0; // number of ring/reference coordinate sets defined
00181 r[0].rc=(coord_3D*)calloc(1,sizeof(coord_3D)); // coordinates for ring/reference centers
00182 r[0].nrp=0; // number of ring planes defined
00183 r[0].rp=(plane*)calloc(1,sizeof(plane)); // equations for average/approximate/exact/etc. ring planes (where useful)
00184 r[0].ni=0; // number of other indices
00185 r[0].i=(int*)calloc(1,sizeof(int)); // other indices, as needed (ni of these)
00186 r[0].nd=0; // number of double-precision parameters
00187 r[0].d=(double*)calloc(1,sizeof(double)); // other parameters, as needed (nd of these)
00188 r[0].nOD=0; // number of double-precision parameters
00189 r[0].OD=(char**)calloc(1,sizeof(char*)); // other parameters, as needed (nd of these)
00190 r[0].nVP=0; // number of void structures
00191 return;
00192 }
00193 
00194 void initialize_molecule(molecule *m) {
00195 m[0].i=0; // index
00196 m[0].t=0; // index
00197 m[0].m=0; // molecular weight
00198 m[0].COM.i=m[0].COM.j=m[0].COM.k=0; // center of mass for molecule
00199 m[0].na=0; // total number of atoms in molecule
00200 m[0].nr=0; // number of residues
00201 m[0].r=(residue*)calloc(1,sizeof(residue)); // pointers to residues
00202 /*
00203 m[0].nrb=0; // number of bonds between residues
00204 m[0].rb=(molbond*)calloc(1,sizeof(molbond)); // nrb of these descriptions of bonds 
00205 */
00206 m[0].nrbs=0; // number of sets of bonds between residues (for example, linear chains)
00207 m[0].rbs=(molbondset*)calloc(1,sizeof(molbondset)); // nrbs of these sets
00208 m[0].nrc=0; // number of additional reference coordinates (rings, for example)
00209 m[0].rc=(coord_3D*)calloc(1,sizeof(coord_3D)); // nrc of these
00210 m[0].nBOX=0; // changed to new BOX member on 20080813 BLF
00211 m[0].noi=0; // number of other indices
00212 m[0].oi=(int*)calloc(1,sizeof(int)); // other indices, as needed (ni of these)
00213 m[0].nd=0; // number of double-precision parameters
00214 m[0].d=(double*)calloc(1,sizeof(double)); // other parameters, as needed (nd of these)
00215 m[0].nVP=0; // number of void structures
00216 return;
00217 }
00218 
00219 void initialize_dockinfo(dockinfo *di){
00220 printf("This program will exit now, because it requests initialization of\n");
00221 printf("a dockinfo structure, but dockinfo structures should be initialized\n");
00222 printf("within the main program.\n");
00223 exit(1);
00224 return;
00225 }
00226 
00227 void initialize_assembly(assembly *A) { // structure for groups of molecules within a larger structure
00228 A[0].i=0; // index
00229 A[0].mass=0; // mass of assembly
00230 A[0].COM.i=A[0].COM.j=A[0].COM.k=0; // center of mass 
00231 A[0].nm=0; // number of molecule structures
00232 A[0].m=(molecule**)calloc(1,sizeof(molecule*)); // nm of these
00233 A[0].nb=0; // number of bonds/connections between molecules (H-bonds, for example)
00234 A[0].b=(molbond*)calloc(1,sizeof(molbond)); // nmb of these descriptions of connection 
00235 A[0].nmbs=0; // number of sets of connections between molecules (for example, linear chains)
00236 A[0].mbs=(molbondset*)calloc(1,sizeof(molbondset)); // nmbs of these sets
00237 A[0].nBOX=0; ///< changed to new BOX member on 20080813 BLF
00238 //A[0].boxl.i=A[0].boxl.j=A[0].boxl.k=0; 
00239 //A[0].boxh.i=A[0].boxh.j=A[0].boxh.k=0; 
00240 A[0].nVP=0; // number of void structures
00241 return;
00242 }
00243 
00244 void initialize_ensemble(ensemble *E) { // structure for a larger group of molecules, assemblies, etc.
00245 E[0].i=0; // index
00246 E[0].mass=0; // mass of ensemble
00247 E[0].COM.i=E[0].COM.j=E[0].COM.k=0; // center of mass 
00248 E[0].nm=0; // number of molecule structures
00249 E[0].m=(molecule*)calloc(1,sizeof(molecule)); // nm of these
00250 E[0].nA=0; // number of assembly structures
00251 E[0].A=(assembly**)calloc(1,sizeof(assembly*)); // na of these
00252 E[0].nBOX=0; ///< changed to new BOX member on 20080813 BLF
00253 //E[0].boxl.i=E[0].boxl.j=E[0].boxl.k=0; // center of mass 
00254 //E[0].boxh.i=E[0].boxh.j=E[0].boxh.k=0; // center of mass 
00255 E[0].nVP=0; // number of void structures
00256 return;
00257 }
00258 
 All Classes Files Functions Variables Typedefs Defines