1397c8063da27c352b79cde69f6107c9d005b999
[alexxy/gromacs.git] / include / hackblock.h
1 /*
2  * 
3  *                This source code is part of
4  * 
5  *                 G   R   O   M   A   C   S
6  * 
7  *          GROningen MAchine for Chemical Simulations
8  * 
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  * 
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  * 
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
34  */
35
36 #ifndef _hackblock_h
37 #define _hackblock_h
38
39 #include "visibility.h"
40 #include "typedefs.h"
41 #include "pdbio.h"
42 #include "grompp.h"
43 #include "gpp_atomtype.h"
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 /* Used for reading .rtp/.tdb */
50 /* ebtsBONDS must be the first, new types can be added to the end */
51 /* these *MUST* correspond to the arrays in hackblock.c */
52 enum { ebtsBONDS, ebtsANGLES, ebtsPDIHS, ebtsIDIHS, ebtsEXCLS, ebtsCMAP, ebtsNR };
53 extern const char *btsNames[ebtsNR];
54 extern const int btsNiatoms[ebtsNR];
55
56 /* if changing any of these structs, make sure that all of the
57    free/clear/copy/merge_t_* functions stay updated */
58
59 /* BONDEDS */
60 typedef struct {
61   char  *a[MAXATOMLIST]; /* atom names */
62   char  *s;              /* optional define string which gets copied from
63                             .rtp/.tdb to .top and will be parsed by cpp
64                             during grompp */
65 } t_rbonded;
66
67 typedef struct {
68   int       type;        /* The type of bonded interaction */
69   int       nb;          /* number of bondeds */
70   t_rbonded *b;          /* bondeds */
71 } t_rbondeds;
72
73 /* RESIDUES (rtp) */
74 typedef struct {
75   char   *resname;
76   /* The base file name this rtp entry was read from */
77   char   *filebase;
78   /* atom data */
79   int    natom;
80   t_atom *atom;
81   char   ***atomname;
82   int    *cgnr;
83   /* Bonded interaction setup */
84   gmx_bool      bKeepAllGeneratedDihedrals;
85   int       nrexcl;
86   gmx_bool      bGenerateHH14Interactions;
87   gmx_bool      bRemoveDihedralIfWithImproper;
88   /* list of bonded interactions to add */
89   t_rbondeds rb[ebtsNR];
90 } t_restp;
91
92 /* Block to hack residues */
93 typedef struct {
94   int     nr;       /* Number of atoms to hack    */
95   char    *oname;   /* Old name                   */
96   char    *nname;   /* New name                   */
97   /* the type of hack depends on the setting of oname and nname:
98    * if oname==NULL                we're adding, must have tp>0 also!
99    * if oname!=NULL && nname==NULL we're deleting
100    * if oname!=NULL && nname!=NULL we're replacing
101    */
102   t_atom  *atom;    /* New atom data              */
103   int     cgnr;     /* chargegroup number. if not read will be NOTSET */
104   int     tp;       /* Type of attachment (1..11) */
105   int     nctl;     /* How many control atoms there are */
106   char    *a[4];    /* Control atoms i,j,k,l      */
107   gmx_bool    bAlreadyPresent;
108   gmx_bool    bXSet;
109   rvec    newx;     /* calculated new position    */
110   atom_id newi;     /* new atom index number (after additions) */
111 } t_hack;
112
113 typedef struct {
114   char      *name;  /* Name of hack block (residue or terminus) */
115   char      *filebase; /* The base file name this entry was read from */
116   int       nhack;  /* Number of atoms to hack                  */
117   int       maxhack;/* used for efficient srenew-ing            */
118   t_hack    *hack;  /* Hack list                                */
119   /* list of bonded interactions to add */
120   t_rbondeds rb[ebtsNR];
121 } t_hackblock;
122
123 /* all libraries and other data to protonate a structure or trajectory */
124 typedef struct {
125   gmx_bool        bInit; /* true after init; set false by init_t_protonate */
126   /* force field name: */
127   char        FF[10];
128   /* libarary data: */
129   int         *nab;
130   t_hack      **ab;
131   t_hackblock *ah, *ntdb, *ctdb;
132   t_hackblock **sel_ntdb, **sel_ctdb;
133   int         nah;
134   t_symtab    tab;
135   /* residue indices (not numbers!) of the N and C termini */
136   int         *rN, *rC;
137   gpp_atomtype_t atype;
138   /* protonated topology: */
139   t_atoms     *patoms;
140   /* unprotonated topology: */
141   t_atoms     *upatoms;
142   
143 } t_protonate;
144
145 typedef struct {
146   char *res1, *res2;
147   char *atom1,*atom2;
148   char *newres1,*newres2;
149   int  nbond1,nbond2;
150   real length;
151 } t_specbond;
152
153 t_specbond *get_specbonds(int *nspecbond);
154 void done_specbonds(int nsb,t_specbond sb[]);
155
156 void free_t_restp(int nrtp, t_restp **rtp);
157 void free_t_hack(int nh, t_hack **h);
158 void free_t_hackblock(int nhb, t_hackblock **hb);
159 /* free the whole datastructure */
160
161 void clear_t_hackblock(t_hackblock *hb);
162 void clear_t_hack(t_hack *hack);
163 /* reset struct */
164
165 gmx_bool merge_t_bondeds(t_rbondeds s[], t_rbondeds d[], 
166                             gmx_bool bMin, gmx_bool bPlus);
167 /* add s[].b[] to d[].b[]
168  * If bMin==TRUE, don't copy bondeds with atoms starting with '-'
169  * If bPlus==TRUE, don't copy bondeds with atoms starting with '+'
170  * Returns if bonds were removed at the termini.
171  */
172      
173 void copy_t_restp(t_restp *s, t_restp *d);
174 void copy_t_hack(t_hack *s, t_hack *d);
175 void copy_t_hackblock(t_hackblock *s, t_hackblock *d);
176 /* make copy of whole datastructure */
177
178 void merge_hacks_lo(int ns, t_hack *s, int *nd, t_hack **d);
179 /* add s[] to *d[] */
180
181 void merge_hacks(t_hackblock *s, t_hackblock *d);
182 /* add s->hacks[] to d->hacks[] */
183
184 void merge_t_hackblock(t_hackblock *s, t_hackblock *d);
185 /* add s->hacks[] and s->rb[] to d*/
186
187 void dump_hb(FILE *out, int nres, t_hackblock hb[]);
188 /* print out whole datastructure */
189
190 GMX_LIBGMXPREPROCESS_EXPORT
191 void init_t_protonate(t_protonate *protonate);
192 /* initialize t_protein struct */
193
194 #ifdef __cplusplus
195 }
196 #endif
197
198 #endif  /* _hackblock_h */