978cf4778a3ba2b89a066f6f25f0fde3240e094e
[alexxy/gromacs.git] / include / pdbio.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, 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 _pdbio_h
40 #define _pdbio_h
41 #include "visibility.h"
42 #include "sysstuff.h"
43 #include "typedefs.h"
44 #include "symtab.h"
45 #include "atomprop.h"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 typedef struct gmx_conect_t *gmx_conect;
52
53 /* THE pdb format (for ATOM/HETATOM lines) */
54 static const char *pdbformat ="%-6s%5u  %-4.4s%3.3s %c%4d%c   %8.3f%8.3f%8.3f";
55 static const char *pdbformat4="%-6s%5u %-4.4s %3.3s %c%4d%c   %8.3f%8.3f%8.3f";
56
57 /* Enumerated type for pdb records. The other entries are ignored
58  * when reading a pdb file 
59  */
60 enum { epdbATOM,   epdbHETATM, epdbANISOU, epdbCRYST1, epdbCOMPND, 
61        epdbMODEL,  epdbENDMDL, epdbTER,    epdbHEADER, epdbTITLE, epdbREMARK, 
62        epdbCONECT, epdbNR };
63
64 /* Enumerated value for indexing an uij entry (anisotropic temperature factors) */
65 enum { U11, U22, U33, U12, U13, U23 };
66        
67 GMX_LIBGMX_EXPORT
68 void set_pdb_wide_format(gmx_bool bSet);
69 /* If bSet, use wider format for occupancy and bfactor */
70
71 void pdb_use_ter(gmx_bool bSet);
72 /* set read_pdbatoms to read upto 'TER' or 'ENDMDL' (default, bSet=FALSE).
73    This function is fundamentally broken as far as thread-safety is concerned.*/
74
75 GMX_LIBGMX_EXPORT
76 void gmx_write_pdb_box(FILE *out,int ePBC,matrix box);
77 /* write the box in the CRYST1 record,
78  * with ePBC=-1 the pbc is guessed from the box
79  * This function is fundamentally broken as far as thread-safety is concerned.
80  */
81
82 GMX_LIBGMX_EXPORT
83 void write_pdbfile_indexed(FILE *out,const char *title,t_atoms *atoms,
84                                   rvec x[],int ePBC,matrix box,char chain,
85                                   int model_nr,atom_id nindex,atom_id index[],
86                                   gmx_conect conect,gmx_bool bTerSepChains);
87 /* REALLY low level */
88
89 GMX_LIBGMX_EXPORT
90 void write_pdbfile(FILE *out,const char *title,t_atoms *atoms,
91                           rvec x[],int ePBC,matrix box,char chain,
92                           int model_nr,gmx_conect conect,gmx_bool bTerSepChains);
93 /* Low level pdb file writing routine.
94  * 
95  *          ONLY FOR SPECIAL PURPOSES,
96  * 
97  *       USE write_sto_conf WHEN YOU CAN.
98  *
99  * override chain-identifiers with chain when chain>0
100  * write ENDMDL when bEndmodel is TRUE.
101  *
102  * If the gmx_conect structure is not NULL its content is dumped as CONECT records
103  * which may be useful for visualization purposes.
104  */
105   
106 GMX_LIBGMX_EXPORT
107 void get_pdb_atomnumber(t_atoms *atoms,gmx_atomprop_t aps);
108 /* Routine to extract atomic numbers from the atom names */
109
110 int read_pdbfile(FILE *in,char *title,int *model_nr,
111                         t_atoms *atoms,rvec x[],int *ePBC,matrix box,
112                         gmx_bool bChange,gmx_conect conect);
113 /* Function returns number of atoms found.
114  * ePBC and gmx_conect structure may be NULL.
115  */
116
117 void read_pdb_conf(const char *infile,char *title, 
118                           t_atoms *atoms,rvec x[],int *ePBC,matrix box,
119                           gmx_bool bChange,gmx_conect conect);
120 /* Read a pdb file and extract ATOM and HETATM fields.
121  * Read a box from the CRYST1 line, return 0 box when no CRYST1 is found.
122  * Change atom names according to protein conventions if wanted.
123  * ePBC and gmx_conect structure may be NULL.
124  */
125
126 void get_pdb_coordnum(FILE *in,int *natoms);
127 /* Read a pdb file and count the ATOM and HETATM fields. */
128
129 GMX_LIBGMX_EXPORT
130 gmx_bool is_hydrogen(const char *nm);
131 /* Return whether atom nm is a hydrogen */
132
133 GMX_LIBGMX_EXPORT
134 gmx_bool is_dummymass(const char *nm);
135 /* Return whether atom nm is a dummy mass */
136
137 /* Routines to handle CONECT records if they have been read in */
138 void gmx_conect_dump(FILE *fp,gmx_conect conect);
139
140 gmx_bool gmx_conect_exist(gmx_conect conect,int ai,int aj);
141 /* Return TRUE if there is a conection between the atoms */
142
143 void gmx_conect_add(gmx_conect conect,int ai,int aj);
144 /* Add a connection between ai and aj (numbered from 0 to natom-1) */ 
145
146 GMX_LIBGMX_EXPORT
147 gmx_conect gmx_conect_generate(t_topology *top);
148 /* Generate a conect structure from a topology */
149
150 gmx_conect gmx_conect_init(void);
151 /* Initiate data structure */
152
153 void gmx_conect_done(gmx_conect gc);
154 /* Free memory */
155
156 #ifdef __cplusplus
157 }
158 #endif
159
160 #endif  /* _pdbio_h */