068ad43ea229499fb024c03a5b5dcdef96749489
[alexxy/gromacs.git] / src / programs / gmx / legacymodules.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, by the GROMACS development team, led by
5  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6  * others, as listed in the AUTHORS file in the top-level source
7  * directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \internal \brief
36  * Registers command-line modules for pre-5.0 binaries.
37  *
38  * \author Teemu Murtola <teemu.murtola@gmail.com>
39  */
40 #include "legacymodules.h"
41
42 #include <cstdio>
43
44 #include "gromacs/commandline/cmdlinemodule.h"
45 #include "gromacs/commandline/cmdlinemodulemanager.h"
46
47 #include "gromacs/gmxana/gmx_ana.h"
48
49 #include "../view/view.h"
50 #include "../mdrun/mdrun_main.h"
51
52 extern "C"
53 {
54
55 int gmx_gmxcheck(int argc, char *argv[]);
56 int gmx_gmxdump(int argc, char *argv[]);
57 int gmx_grompp(int argc, char *argv[]);
58 int gmx_pdb2gmx(int argc, char *argv[]);
59 int gmx_protonate(int argc, char *argv[]);
60 int gmx_tpbconv(int argc, char *argv[]);
61 int gmx_x2top(int argc, char *argv[]);
62
63 }
64
65 namespace
66 {
67
68 /*! \brief
69  * Command line module that provides information about obsolescence.
70  *
71  * Prints a message directing the user to a wiki page describing replacement
72  * options.
73  */
74 class ObsoleteToolModule : public gmx::CommandLineModuleInterface
75 {
76     public:
77         //! Creates an obsolete tool module for a tool with the given name.
78         explicit ObsoleteToolModule(const char *name)
79             : name_(name)
80         {
81         }
82
83         virtual const char *name() const
84         {
85             return name_;
86         }
87         virtual const char *shortDescription() const
88         {
89             return NULL;
90         }
91
92         virtual int run(int /*argc*/, char * /*argv*/[])
93         {
94             printMessage();
95             return 0;
96         }
97         virtual void writeHelp(const gmx::CommandLineHelpContext & /*context*/) const
98         {
99             printMessage();
100         }
101
102     private:
103         void printMessage() const
104         {
105             std::fprintf(stderr,
106                          "This tool has been removed from Gromacs 5.0. Please see\n"
107                          "  http://www.gromacs.org/Documentation/How-tos/Tool_Changes_for_5.0\n"
108                          "for ideas how to perform the same tasks with the "
109                          "new tools.\n");
110         }
111
112         const char             *name_;
113
114 };
115
116 /*! \brief
117  * Convenience function for creating and registering a module.
118  *
119  * \param[in] manager          Module manager to which to register the module.
120  * \param[in] mainFunction     Main function to wrap.
121  * \param[in] name             Name for the new module.
122  * \param[in] shortDescription One-line description for the new module.
123  */
124 void registerModule(gmx::CommandLineModuleManager                *manager,
125                     gmx::CommandLineModuleManager::CMainFunction  mainFunction,
126                     const char *name, const char *shortDescription)
127 {
128     manager->addModuleCMain(name, shortDescription, mainFunction);
129 }
130
131 /*! \brief
132  * Convenience function for registering a module for an obsolete tool.
133  *
134  * \param[in] manager          Module manager to which to register the module.
135  * \param[in] name             Name for the obsolete tool.
136  */
137 void registerObsoleteTool(gmx::CommandLineModuleManager *manager,
138                           const char                    *name)
139 {
140     gmx::CommandLineModulePointer module(new ObsoleteToolModule(name));
141     manager->addModule(move(module));
142 }
143
144 } // namespace
145
146 void registerLegacyModules(gmx::CommandLineModuleManager *manager)
147 {
148     // Modules from this directory (were in src/kernel/).
149     registerModule(manager, &gmx_gmxcheck, "gmxcheck",
150                    "Check and compare files");
151     registerModule(manager, &gmx_gmxdump, "gmxdump",
152                    "Make binary files human readable");
153     registerModule(manager, &gmx_grompp, "grompp",
154                    "Make a run input file");
155     registerModule(manager, &gmx_pdb2gmx, "pdb2gmx",
156                    "Convert coordinate files to topology and FF-compliant coordinate files");
157     registerModule(manager, &gmx_tpbconv, "tpbconv",
158                    "Make a run input file for restarting a crashed run");
159
160     registerModule(manager, &gmx_protonate, "protonate",
161                    "Protonate structures");
162     registerModule(manager, &gmx_x2top, "x2top",
163                    "Generate a primitive topology from coordinates");
164
165     registerModule(manager, &gmx_mdrun, "mdrun",
166                    "Perform a simulation, do a normal mode analysis or an energy minimization");
167
168     // Modules from gmx_ana.h.
169     registerModule(manager, &gmx_do_dssp, "do_dssp",
170                    "Assign secondary structure and calculate solvent accessible surface area");
171     registerModule(manager, &gmx_editconf, "editconf",
172                    "Convert and manipulates structure files");
173     registerModule(manager, &gmx_eneconv, "eneconv",
174                    "Convert energy files");
175     registerModule(manager, &gmx_genbox, "genbox",
176                    "Solvate a system");
177     registerModule(manager, &gmx_genconf, "genconf",
178                    "Multiply a conformation in 'random' orientations");
179     registerModule(manager, &gmx_genion, "genion",
180                    "Generate monoatomic ions on energetically favorable positions");
181     registerModule(manager, &gmx_genpr, "genrestr",
182                    "Generate position restraints or distance restraints for index groups");
183     registerModule(manager, &gmx_make_edi, "make_edi",
184                    "Generate input files for essential dynamics sampling");
185     registerModule(manager, &gmx_make_ndx, "make_ndx",
186                    "Make index files");
187     registerModule(manager, &gmx_mk_angndx, "mk_angndx",
188                    "Generate index files for 'gmx angle'");
189     registerModule(manager, &gmx_trjcat, "trjcat",
190                    "Concatenate trajectory files");
191     registerModule(manager, &gmx_trjconv, "trjconv",
192                    "Convert and manipulates trajectory files");
193     registerModule(manager, &gmx_trjorder, "trjorder",
194                    "Order molecules according to their distance to a group");
195     registerModule(manager, &gmx_xpm2ps, "xpm2ps",
196                    "Convert XPM (XPixelMap) matrices to postscript or XPM");
197
198     registerModule(manager, &gmx_anadock, "anadock",
199                    "Cluster structures from Autodock runs");
200     registerModule(manager, &gmx_anaeig, "anaeig",
201                    "Analyze eigenvectors/normal modes");
202     registerModule(manager, &gmx_analyze, "analyze",
203                    "Analyze data sets");
204     registerModule(manager, &gmx_g_angle, "angle",
205                    "Calculate distributions and correlations for angles and dihedrals");
206     registerModule(manager, &gmx_bar, "bar",
207                    "Calculate free energy difference estimates through Bennett's acceptance ratio");
208     registerObsoleteTool(manager, "bond");
209     registerObsoleteTool(manager, "dist");
210     registerObsoleteTool(manager, "sgangle");
211
212     registerModule(manager, &gmx_bundle, "bundle",
213                    "Analyze bundles of axes, e.g., helices");
214     registerModule(manager, &gmx_chi, "chi",
215                    "Calculate everything you want to know about chi and other dihedrals");
216     registerModule(manager, &gmx_cluster, "cluster",
217                    "Cluster structures");
218     registerModule(manager, &gmx_clustsize, "clustsize",
219                    "Calculate size distributions of atomic clusters");
220     registerModule(manager, &gmx_confrms, "confrms",
221                    "Fit two structures and calculates the RMSD");
222     registerModule(manager, &gmx_covar, "covar",
223                    "Calculate and diagonalize the covariance matrix");
224     registerModule(manager, &gmx_current, "current",
225                    "Calculate dielectric constants and charge autocorrelation function");
226     registerModule(manager, &gmx_density, "density",
227                    "Calculate the density of the system");
228     registerModule(manager, &gmx_densmap, "densmap",
229                    "Calculate 2D planar or axial-radial density maps");
230     registerModule(manager, &gmx_densorder, "densorder",
231                    "Calculate surface fluctuations");
232     registerModule(manager, &gmx_dielectric, "dielectric",
233                    "Calculate frequency dependent dielectric constants");
234     registerModule(manager, &gmx_dipoles, "dipoles",
235                    "Compute the total dipole plus fluctuations");
236     registerModule(manager, &gmx_disre, "disre",
237                    "Analyze distance restraints");
238     registerModule(manager, &gmx_dos, "dos",
239                    "Analyze density of states and properties based on that");
240     registerModule(manager, &gmx_dyecoupl, "dyecoupl",
241                    "Extract dye dynamics from trajectories");
242     registerModule(manager, &gmx_dyndom, "dyndom",
243                    "Interpolate and extrapolate structure rotations");
244     registerModule(manager, &gmx_enemat, "enemat",
245                    "Extract an energy matrix from an energy file");
246     registerModule(manager, &gmx_energy, "energy",
247                    "Writes energies to xvg files and display averages");
248     registerModule(manager, &gmx_filter, "filter",
249                    "Frequency filter trajectories, useful for making smooth movies");
250     registerModule(manager, &gmx_gyrate, "gyrate",
251                    "Calculate the radius of gyration");
252     registerModule(manager, &gmx_h2order, "h2order",
253                    "Compute the orientation of water molecules");
254     registerModule(manager, &gmx_hbond, "hbond",
255                    "Compute and analyze hydrogen bonds");
256     registerModule(manager, &gmx_helix, "helix",
257                    "Calculate basic properties of alpha helices");
258     registerModule(manager, &gmx_helixorient, "helixorient",
259                    "Calculate local pitch/bending/rotation/orientation inside helices");
260     registerModule(manager, &gmx_hydorder, "hydorder",
261                    "Compute tetrahedrality parameters around a given atom");
262     registerModule(manager, &gmx_kinetics, "kinetics",
263                    "Analyze kinetic constants from properties based on the Eyring model");
264     registerModule(manager, &gmx_lie, "lie",
265                    "Estimate free energy from linear combinations");
266     registerModule(manager, &gmx_mdmat, "mdmat",
267                    "Calculate residue contact maps");
268     registerModule(manager, &gmx_mindist, "mindist",
269                    "Calculate the minimum distance between two groups");
270     registerModule(manager, &gmx_morph, "morph",
271                    "Interpolate linearly between conformations");
272     registerModule(manager, &gmx_msd, "msd",
273                    "Calculates mean square displacements");
274     registerModule(manager, &gmx_nmeig, "nmeig",
275                    "Diagonalize the Hessian for normal mode analysis");
276     registerModule(manager, &gmx_nmens, "nmens",
277                    "Generate an ensemble of structures from the normal modes");
278     registerModule(manager, &gmx_nmtraj, "nmtraj",
279                    "Generate a virtual oscillating trajectory from an eigenvector");
280     registerModule(manager, &gmx_options, "options", NULL);
281     registerModule(manager, &gmx_order, "order",
282                    "Compute the order parameter per atom for carbon tails");
283     registerModule(manager, &gmx_pme_error, "pme_error",
284                    "Estimate the error of using PME with a given input file");
285     registerModule(manager, &gmx_polystat, "polystat",
286                    "Calculate static properties of polymers");
287     registerModule(manager, &gmx_potential, "potential",
288                    "Calculate the electrostatic potential across the box");
289     registerModule(manager, &gmx_principal, "principal",
290                    "Calculate principal axes of inertia for a group of atoms");
291     registerModule(manager, &gmx_rama, "rama",
292                    "Compute Ramachandran plots");
293     registerModule(manager, &gmx_rdf, "rdf",
294                    "Calculate radial distribution functions");
295     registerModule(manager, &gmx_rms, "rms",
296                    "Calculate RMSDs with a reference structure and RMSD matrices");
297     registerModule(manager, &gmx_rmsdist, "rmsdist",
298                    "Calculate atom pair distances averaged with power -2, -3 or -6");
299     registerModule(manager, &gmx_rmsf, "rmsf",
300                    "Calculate atomic fluctuations");
301     registerModule(manager, &gmx_rotacf, "rotacf",
302                    "Calculate the rotational correlation function for molecules");
303     registerModule(manager, &gmx_rotmat, "rotmat",
304                    "Plot the rotation matrix for fitting to a reference structure");
305     registerModule(manager, &gmx_saltbr, "saltbr",
306                    "Compute salt bridges");
307     registerModule(manager, &gmx_sans, "sans",
308                    "Compute the small angle neutron scattering spectra");
309     registerModule(manager, &gmx_sas, "sas",
310                    "Compute solvent accessible surface area");
311     registerModule(manager, &gmx_saxs, "saxs",
312                    "Calculates SAXS structure factors based on Cromer's method");
313     registerModule(manager, &gmx_sham, "sham",
314                    "Compute free energies or other histograms from histograms");
315     registerModule(manager, &gmx_sigeps, "sigeps",
316                    "Convert c6/12 or c6/cn combinations to and from sigma/epsilon");
317     registerModule(manager, &gmx_sorient, "sorient",
318                    "Analyze solvent orientation around solutes");
319     registerModule(manager, &gmx_spatial, "spatial",
320                    "Calculate the spatial distribution function");
321     registerModule(manager, &gmx_spol, "spol",
322                    "Analyze solvent dipole orientation and polarization around solutes");
323     registerModule(manager, &gmx_tcaf, "tcaf",
324                    "Calculate viscosities of liquids");
325     registerModule(manager, &gmx_traj, "traj",
326                    "Plot x, v, f, box, temperature and rotational energy from trajectories");
327     registerModule(manager, &gmx_tune_pme, "tune_pme",
328                    "Time mdrun as a function of PME nodes to optimize settings");
329     registerModule(manager, &gmx_vanhove, "vanhove",
330                    "Compute Van Hove correlation functions");
331     registerModule(manager, &gmx_velacc, "velacc",
332                    "Calculate velocity autocorrelation functions");
333     registerModule(manager, &gmx_wham, "wham",
334                    "Perform weighted histogram analysis after umbrella sampling");
335     registerModule(manager, &gmx_wheel, "wheel",
336                    "Plot helical wheels");
337     registerModule(manager, &gmx_view, "view",
338                    "View a trajectory on an X-Windows terminal");
339
340     // TODO: Also include binaries from other directories than src/tools/:
341     //        "mdrun|finds a potential energy minimum and calculates the Hessian");
342     //        "mdrun|with -rerun (re)calculates energies for trajectory frames");
343 }