2 * This file is part of the GROMACS molecular simulation package.
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, 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.
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.
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.
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.
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.
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.
39 #include "filetypes.h"
43 #include "gromacs/utility/arraysize.h"
44 #include "gromacs/utility/cstringutil.h"
48 eftASC, eftXDR, eftTNG, eftGEN, eftNR
51 /* To support multiple file types with one general (eg TRX) we have
54 static const int trxs[] =
57 efGRO, efG96, efPDB, efTNG
59 #define NTRXS asize(trxs)
61 static const int trcompressed[] =
66 #define NTRCOMPRESSED asize(trcompressed)
68 static const int tros[] =
71 efGRO, efG96, efPDB, efTNG
73 #define NTROS asize(tros)
75 static const int trns[] =
80 #define NTRNS asize(trns)
82 static const int stos[] =
83 { efGRO, efG96, efPDB, efBRK, efENT, efESP };
84 #define NSTOS asize(stos)
86 static const int stxs[] =
88 efGRO, efG96, efPDB, efBRK, efENT, efESP,
91 #define NSTXS asize(stxs)
93 static const int tpss[] =
96 efGRO, efG96, efPDB, efBRK, efENT
98 #define NTPSS asize(tpss)
111 /* this array should correspond to the enum in filetypes.h */
112 static const t_deffile deffile[efNR] =
114 { eftASC, ".mdp", "grompp", "-f", "grompp input file with MD parameters" },
115 { eftGEN, ".???", "traj", "-f", "Trajectory", NTRXS, trxs },
116 { eftGEN, ".???", "trajout", "-f", "Trajectory", NTROS, tros },
117 { eftGEN, ".???", "traj", NULL,
118 "Full precision trajectory", NTRNS, trns },
119 { eftXDR, ".trr", "traj", NULL, "Trajectory in portable xdr format" },
120 { eftGEN, ".???", "traj_comp", NULL,
121 "Compressed trajectory (tng format or portable xdr format)", NTRCOMPRESSED, trcompressed},
122 { eftXDR, ".xtc", "traj", NULL,
123 "Compressed trajectory (portable xdr format): xtc" },
124 { eftTNG, ".tng", "traj", NULL,
125 "Trajectory file (tng format)" },
126 { eftXDR, ".edr", "ener", NULL, "Energy file"},
127 { eftGEN, ".???", "conf", "-c", "Structure file", NSTXS, stxs },
128 { eftGEN, ".???", "out", "-o", "Structure file", NSTOS, stos },
129 { eftASC, ".gro", "conf", "-c", "Coordinate file in Gromos-87 format" },
130 { eftASC, ".g96", "conf", "-c", "Coordinate file in Gromos-96 format" },
131 { eftASC, ".pdb", "eiwit", "-f", "Protein data bank file"},
132 { eftASC, ".brk", "eiwit", "-f", "Brookhaven data bank file"},
133 { eftASC, ".ent", "eiwit", "-f", "Entry in the protein date bank" },
134 { eftASC, ".esp", "conf", "-f", "Coordinate file in Espresso format" },
135 { eftASC, ".pqr", "state", "-o", "Coordinate file for MEAD"},
136 { eftXDR, ".cpt", "state", "-cp", "Checkpoint file"},
137 { eftASC, ".log", "run", "-l", "Log file"},
138 { eftASC, ".xvg", "graph", "-o", "xvgr/xmgr file"},
139 { eftASC, ".out", "hello", "-o", "Generic output file"},
140 { eftASC, ".ndx", "index", "-n", "Index file", },
141 { eftASC, ".top", "topol", "-p", "Topology file"},
142 { eftASC, ".itp", "topinc", NULL, "Include file for topology"},
143 { eftGEN, ".???", "topol", "-s", "Structure+mass(db)", NTPSS, tpss },
144 { eftXDR, ".tpr", "topol", "-s", "Portable xdr run input file"},
145 { eftASC, ".tex", "doc", "-o", "LaTeX file"},
146 { eftASC, ".rtp", "residue", NULL, "Residue Type file used by pdb2gmx" },
147 { eftASC, ".atp", "atomtp", NULL, "Atomtype file used by pdb2gmx" },
148 { eftASC, ".hdb", "polar", NULL, "Hydrogen data base"},
149 { eftASC, ".dat", "nnnice", NULL, "Generic data file"},
150 { eftASC, ".dlg", "user", NULL, "Dialog Box data for ngmx"},
151 { eftASC, ".map", "ss", NULL, "File that maps matrix data to colors" },
152 { eftASC, ".eps", "plot", NULL, "Encapsulated PostScript (tm) file" },
153 { eftASC, ".mat", "ss", NULL, "Matrix Data file"},
154 { eftASC, ".m2p", "ps", NULL, "Input file for mat2ps"},
155 { eftXDR, ".mtx", "hessian", "-m", "Hessian matrix"},
156 { eftASC, ".edi", "sam", NULL, "ED sampling input"},
157 { eftASC, ".cub", "pot", NULL, "Gaussian cube file" },
158 { eftASC, ".xpm", "root", NULL, "X PixMap compatible matrix file" },
159 { eftASC, "", "rundir", NULL, "Run directory" }
162 const char *ftp2ext(int ftp)
164 if ((0 <= ftp) && (ftp < efNR))
166 return deffile[ftp].ext[0] != '\0' ? deffile[ftp].ext + 1 : "";
174 const char *ftp2ext_generic(int ftp)
176 if ((0 <= ftp) && (ftp < efNR))
200 const char *ftp2ext_with_dot(int ftp)
202 if ((0 <= ftp) && (ftp < efNR))
204 return deffile[ftp].ext;
212 int ftp2generic_count(int ftp)
214 if ((0 <= ftp) && (ftp < efNR))
216 return deffile[ftp].ntps;
224 const int *ftp2generic_list(int ftp)
226 if ((0 <= ftp) && (ftp < efNR))
228 return deffile[ftp].tps;
236 const char *ftp2desc(int ftp)
238 if ((0 <= ftp) && (ftp < efNR))
240 return deffile[ftp].descr;
244 return "unknown filetype";
248 gmx_bool ftp_is_text(int ftp)
250 if ((ftp >= 0) && (ftp < efNR))
252 return deffile[ftp].ftype == eftASC;
257 gmx_bool ftp_is_xdr(int ftp)
259 if ((ftp >= 0) && (ftp < efNR))
261 return deffile[ftp].ftype == eftXDR;
266 const char *ftp2defnm(int ftp)
268 if ((0 <= ftp) && (ftp < efNR))
270 return deffile[ftp].defnm;
278 const char *ftp2defopt(int ftp)
280 if ((0 <= ftp) && (ftp < efNR))
282 return deffile[ftp].defopt;
290 int fn2ftp(const char *fn)
301 len = std::strlen(fn);
302 if ((len >= 4) && (fn[len - 4] == '.'))
304 feptr = &(fn[len - 4]);
311 for (i = 0; (i < efNR); i++)
313 if ((eptr = deffile[i].ext) != NULL)
315 if (gmx_strcasecmp(feptr, eptr) == 0)