Establish `api/` as the home for installed headers.
[alexxy/gromacs.git] / api / legacy / include / 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,2015,2016,2017 by the GROMACS development team.
7  * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
8  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9  * and including many others, as listed in the AUTHORS file in the
10  * top-level source 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 GMX_FILEIO_PDBIO_H
40 #define GMX_FILEIO_PDBIO_H
41
42 #include <stdio.h>
43
44 #include "gromacs/math/vectypes.h"
45 #include "gromacs/topology/atoms.h"
46 #include "gromacs/utility/basedefinitions.h"
47 #include "gromacs/utility/real.h"
48
49 class AtomProperties;
50 struct t_atoms;
51 struct t_symtab;
52 struct t_topology;
53 enum class PbcType : int;
54
55 typedef struct gmx_conect_t* gmx_conect;
56
57 /* Write a PDB line with an ATOM or HETATM record directly to a file pointer.
58  *
59  * Returns the number of characters printed.
60  */
61 int gmx_fprintf_pdb_atomline(FILE*           fp,
62                              enum PDB_record record,
63                              int             atom_seq_number,
64                              const char*     atom_name,
65                              char            alternate_location,
66                              const char*     res_name,
67                              char            chain_id,
68                              int             res_seq_number,
69                              char            res_insertion_code,
70                              real            x,
71                              real            y,
72                              real            z,
73                              real            occupancy,
74                              real            b_factor,
75                              const char*     element);
76
77 /* Enumerated value for indexing an uij entry (anisotropic temperature factors) */
78 enum
79 {
80     U11,
81     U22,
82     U33,
83     U12,
84     U13,
85     U23
86 };
87
88 void pdb_use_ter(gmx_bool bSet);
89 /* set read_pdbatoms to read upto 'TER' or 'ENDMDL' (default, bSet=FALSE).
90    This function is fundamentally broken as far as thread-safety is concerned.*/
91
92 void gmx_write_pdb_box(FILE* out, PbcType pbcType, const matrix box);
93 /* write the box in the CRYST1 record,
94  * with pbcType=PbcType::Unset the pbc is guessed from the box
95  * This function is fundamentally broken as far as thread-safety is concerned.
96  */
97
98 void write_pdbfile_indexed(FILE*          out,
99                            const char*    title,
100                            const t_atoms* atoms,
101                            const rvec     x[],
102                            PbcType        pbcType,
103                            const matrix   box,
104                            char           chain,
105                            int            model_nr,
106                            int            nindex,
107                            const int      index[],
108                            gmx_conect     conect,
109                            bool           usePqrFormat);
110 /* REALLY low level */
111
112 void write_pdbfile(FILE*          out,
113                    const char*    title,
114                    const t_atoms* atoms,
115                    const rvec     x[],
116                    PbcType        pbcType,
117                    const matrix   box,
118                    char           chain,
119                    int            model_nr,
120                    gmx_conect     conect);
121 /* Low level pdb file writing routine.
122  *
123  *          ONLY FOR SPECIAL PURPOSES,
124  *
125  *       USE write_sto_conf WHEN YOU CAN.
126  *
127  * override chain-identifiers with chain when chain>0
128  * write ENDMDL when bEndmodel is TRUE.
129  *
130  * If the gmx_conect structure is not NULL its content is dumped as CONECT records
131  * which may be useful for visualization purposes.
132  */
133
134 void get_pdb_atomnumber(const t_atoms* atoms, AtomProperties* aps);
135 /* Routine to extract atomic numbers from the atom names */
136
137 int read_pdbfile(FILE*            in,
138                  char*            title,
139                  int*             model_nr,
140                  struct t_atoms*  atoms,
141                  struct t_symtab* symtab,
142                  rvec             x[],
143                  PbcType*         pbcType,
144                  matrix           box,
145                  gmx_conect       conect);
146 /* Function returns number of atoms found.
147  * pbcType and gmx_conect structure may be NULL.
148  */
149
150 void gmx_pdb_read_conf(const char* infile,
151                        t_symtab*   symtab,
152                        char**      name,
153                        t_atoms*    atoms,
154                        rvec        x[],
155                        PbcType*    pbcType,
156                        matrix      box);
157 /* Read a pdb file and extract ATOM and HETATM fields.
158  * Read a box from the CRYST1 line, return 0 box when no CRYST1 is found.
159  * pbcType may be NULL.
160  *
161  * If name is not nullptr, gmx_strdup the title string into it. */
162
163 void get_pdb_coordnum(FILE* in, int* natoms);
164 /* Read a pdb file and count the ATOM and HETATM fields. */
165
166 gmx_bool is_hydrogen(const char* nm);
167 /* Return whether atom nm is a hydrogen */
168
169 gmx_bool is_dummymass(const char* nm);
170 /* Return whether atom nm is a dummy mass */
171
172 /* Routines to handle CONECT records if they have been read in */
173 void gmx_conect_dump(FILE* fp, gmx_conect conect);
174
175 gmx_bool gmx_conect_exist(gmx_conect conect, int ai, int aj);
176 /* Return TRUE if there is a conection between the atoms */
177
178 void gmx_conect_add(gmx_conect conect, int ai, int aj);
179 /* Add a connection between ai and aj (numbered from 0 to natom-1) */
180
181 gmx_conect gmx_conect_generate(const t_topology* top);
182 /* Generate a conect structure from a topology */
183
184 gmx_conect gmx_conect_init();
185 /* Initiate data structure */
186
187 void gmx_conect_done(gmx_conect gc);
188 /* Free memory */
189
190 #endif /* GMX_FILEIO_PDBIO_H */