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