Merge release-4-6 into release-5-0
[alexxy/gromacs.git] / src / gromacs / fileio / 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  * Copyright (c) 2013,2014, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37
38 #ifndef GMX_FILEIO_PDBIO_H
39 #define GMX_FILEIO_PDBIO_H
40
41 #include "../legacyheaders/sysstuff.h"
42 #include "../legacyheaders/typedefs.h"
43 #include "../legacyheaders/symtab.h"
44 #include "../legacyheaders/atomprop.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 typedef struct gmx_conect_t *gmx_conect;
51
52 /* Enumerated type for pdb records. The other entries are ignored
53  * when reading a pdb file
54  */
55 enum PDB_record {
56     epdbATOM,   epdbHETATM, epdbANISOU, epdbCRYST1, epdbCOMPND,
57     epdbMODEL,  epdbENDMDL, epdbTER,    epdbHEADER, epdbTITLE, epdbREMARK,
58     epdbCONECT, epdbNR
59 };
60
61 /* Write a PDB line with an ATOM or HETATM record directly to a file pointer.
62  *
63  * Returns the number of characters printed.
64  */
65 int
66 gmx_fprintf_pdb_atomline(FILE *            fp,
67                          enum PDB_record   record,
68                          int               atom_seq_number,
69                          const char *      atom_name,
70                          char              alternate_location,
71                          const char *      res_name,
72                          char              chain_id,
73                          int               res_seq_number,
74                          char              res_insertion_code,
75                          real              x,
76                          real              y,
77                          real              z,
78                          real              occupancy,
79                          real              b_factor,
80                          const char *      element);
81
82 /* Enumerated value for indexing an uij entry (anisotropic temperature factors) */
83 enum {
84     U11, U22, U33, U12, U13, U23
85 };
86
87 void pdb_use_ter(gmx_bool bSet);
88 /* set read_pdbatoms to read upto 'TER' or 'ENDMDL' (default, bSet=FALSE).
89    This function is fundamentally broken as far as thread-safety is concerned.*/
90
91 void gmx_write_pdb_box(FILE *out, int ePBC, matrix box);
92 /* write the box in the CRYST1 record,
93  * with ePBC=-1 the pbc is guessed from the box
94  * This function is fundamentally broken as far as thread-safety is concerned.
95  */
96
97 void write_pdbfile_indexed(FILE *out, const char *title, t_atoms *atoms,
98                            rvec x[], int ePBC, matrix box, char chain,
99                            int model_nr, atom_id nindex, const atom_id index[],
100                            gmx_conect conect, gmx_bool bTerSepChains);
101 /* REALLY low level */
102
103 void write_pdbfile(FILE *out, const char *title, t_atoms *atoms,
104                    rvec x[], int ePBC, matrix box, char chain,
105                    int model_nr, gmx_conect conect, gmx_bool bTerSepChains);
106 /* Low level pdb file writing routine.
107  *
108  *          ONLY FOR SPECIAL PURPOSES,
109  *
110  *       USE write_sto_conf WHEN YOU CAN.
111  *
112  * override chain-identifiers with chain when chain>0
113  * write ENDMDL when bEndmodel is TRUE.
114  *
115  * If the gmx_conect structure is not NULL its content is dumped as CONECT records
116  * which may be useful for visualization purposes.
117  */
118
119 void get_pdb_atomnumber(t_atoms *atoms, gmx_atomprop_t aps);
120 /* Routine to extract atomic numbers from the atom names */
121
122 int read_pdbfile(FILE *in, char *title, int *model_nr,
123                  t_atoms *atoms, rvec x[], int *ePBC, matrix box,
124                  gmx_bool bChange, gmx_conect conect);
125 /* Function returns number of atoms found.
126  * ePBC and gmx_conect structure may be NULL.
127  */
128
129 void read_pdb_conf(const char *infile, char *title,
130                    t_atoms *atoms, rvec x[], int *ePBC, matrix box,
131                    gmx_bool bChange, gmx_conect conect);
132 /* Read a pdb file and extract ATOM and HETATM fields.
133  * Read a box from the CRYST1 line, return 0 box when no CRYST1 is found.
134  * Change atom names according to protein conventions if wanted.
135  * ePBC and gmx_conect structure may be NULL.
136  */
137
138 void get_pdb_coordnum(FILE *in, int *natoms);
139 /* Read a pdb file and count the ATOM and HETATM fields. */
140
141 gmx_bool is_hydrogen(const char *nm);
142 /* Return whether atom nm is a hydrogen */
143
144 gmx_bool is_dummymass(const char *nm);
145 /* Return whether atom nm is a dummy mass */
146
147 /* Routines to handle CONECT records if they have been read in */
148 void gmx_conect_dump(FILE *fp, gmx_conect conect);
149
150 gmx_bool gmx_conect_exist(gmx_conect conect, int ai, int aj);
151 /* Return TRUE if there is a conection between the atoms */
152
153 void gmx_conect_add(gmx_conect conect, int ai, int aj);
154 /* Add a connection between ai and aj (numbered from 0 to natom-1) */
155
156 gmx_conect gmx_conect_generate(t_topology *top);
157 /* Generate a conect structure from a topology */
158
159 gmx_conect gmx_conect_init(void);
160 /* Initiate data structure */
161
162 void gmx_conect_done(gmx_conect gc);
163 /* Free memory */
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif  /* GMX_FILEIO_PDBIO_H */