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