Simplify code structure for C++ analysis tools
[alexxy/gromacs.git] / src / gromacs / legacyheaders / pdbio.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  *
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  *
30  * For more info, check our website at http://www.gromacs.org
31  *
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #ifndef _pdbio_h
37 #define _pdbio_h
38
39 #include "sysstuff.h"
40 #include "typedefs.h"
41 #include "symtab.h"
42 #include "atomprop.h"
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 typedef struct gmx_conect_t *gmx_conect;
49
50 /* THE pdb format (for ATOM/HETATOM lines) */
51 const char* get_pdbformat(void);
52 const char* get_pdbformat4(void);
53
54 /* Enumerated type for pdb records. The other entries are ignored
55  * when reading a pdb file
56  */
57 enum {
58     epdbATOM,   epdbHETATM, epdbANISOU, epdbCRYST1, epdbCOMPND,
59     epdbMODEL,  epdbENDMDL, epdbTER,    epdbHEADER, epdbTITLE, epdbREMARK,
60     epdbCONECT, epdbNR
61 };
62
63 /* Enumerated value for indexing an uij entry (anisotropic temperature factors) */
64 enum {
65     U11, U22, U33, U12, U13, U23
66 };
67
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 void gmx_write_pdb_box(FILE *out, int ePBC, matrix box);
76 /* write the box in the CRYST1 record,
77  * with ePBC=-1 the pbc is guessed from the box
78  * This function is fundamentally broken as far as thread-safety is concerned.
79  */
80
81 void write_pdbfile_indexed(FILE *out, const char *title, t_atoms *atoms,
82                            rvec x[], int ePBC, matrix box, char chain,
83                            int model_nr, atom_id nindex, const atom_id index[],
84                            gmx_conect conect, gmx_bool bTerSepChains);
85 /* REALLY low level */
86
87 void write_pdbfile(FILE *out, const char *title, t_atoms *atoms,
88                    rvec x[], int ePBC, matrix box, char chain,
89                    int model_nr, gmx_conect conect, gmx_bool bTerSepChains);
90 /* Low level pdb file writing routine.
91  *
92  *          ONLY FOR SPECIAL PURPOSES,
93  *
94  *       USE write_sto_conf WHEN YOU CAN.
95  *
96  * override chain-identifiers with chain when chain>0
97  * write ENDMDL when bEndmodel is TRUE.
98  *
99  * If the gmx_conect structure is not NULL its content is dumped as CONECT records
100  * which may be useful for visualization purposes.
101  */
102
103 void get_pdb_atomnumber(t_atoms *atoms, gmx_atomprop_t aps);
104 /* Routine to extract atomic numbers from the atom names */
105
106 int read_pdbfile(FILE *in, char *title, int *model_nr,
107                  t_atoms *atoms, rvec x[], int *ePBC, matrix box,
108                  gmx_bool bChange, gmx_conect conect);
109 /* Function returns number of atoms found.
110  * ePBC and gmx_conect structure may be NULL.
111  */
112
113 void read_pdb_conf(const char *infile, char *title,
114                    t_atoms *atoms, rvec x[], int *ePBC, matrix box,
115                    gmx_bool bChange, gmx_conect conect);
116 /* Read a pdb file and extract ATOM and HETATM fields.
117  * Read a box from the CRYST1 line, return 0 box when no CRYST1 is found.
118  * Change atom names according to protein conventions if wanted.
119  * ePBC and gmx_conect structure may be NULL.
120  */
121
122 void get_pdb_coordnum(FILE *in, int *natoms);
123 /* Read a pdb file and count the ATOM and HETATM fields. */
124
125 gmx_bool is_hydrogen(const char *nm);
126 /* Return whether atom nm is a hydrogen */
127
128 gmx_bool is_dummymass(const char *nm);
129 /* Return whether atom nm is a dummy mass */
130
131 /* Routines to handle CONECT records if they have been read in */
132 void gmx_conect_dump(FILE *fp, gmx_conect conect);
133
134 gmx_bool gmx_conect_exist(gmx_conect conect, int ai, int aj);
135 /* Return TRUE if there is a conection between the atoms */
136
137 void gmx_conect_add(gmx_conect conect, int ai, int aj);
138 /* Add a connection between ai and aj (numbered from 0 to natom-1) */
139
140 gmx_conect gmx_conect_generate(t_topology *top);
141 /* Generate a conect structure from a topology */
142
143 gmx_conect gmx_conect_init(void);
144 /* Initiate data structure */
145
146 void gmx_conect_done(gmx_conect gc);
147 /* Free memory */
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif  /* _pdbio_h */