Allow creating mock HardwareTopology objects
[gromacs.git] / src / programs / legacymodules.cpp
blob406e2711dc25098a77e71c0f7e275039ab43ad1d
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
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.
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.
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.
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.
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.
35 /*! \internal \brief
36 * Registers command-line modules for pre-5.0 binaries.
38 * \author Teemu Murtola <teemu.murtola@gmail.com>
40 #include "gmxpre.h"
42 #include "legacymodules.h"
44 #include <cstdio>
46 #include "gromacs/commandline/cmdlinemodule.h"
47 #include "gromacs/commandline/cmdlinemodulemanager.h"
48 #include "gromacs/commandline/cmdlineoptionsmodule.h"
49 #include "gromacs/gmxana/gmx_ana.h"
50 #include "gromacs/gmxpreprocess/genconf.h"
51 #include "gromacs/gmxpreprocess/grompp.h"
52 #include "gromacs/gmxpreprocess/insert-molecules.h"
53 #include "gromacs/gmxpreprocess/pdb2gmx.h"
54 #include "gromacs/gmxpreprocess/solvate.h"
55 #include "gromacs/gmxpreprocess/x2top.h"
56 #include "gromacs/tools/check.h"
57 #include "gromacs/tools/convert_tpr.h"
58 #include "gromacs/tools/dump.h"
60 #include "mdrun/mdrun_main.h"
61 #include "view/view.h"
63 namespace
66 /*! \brief
67 * Command line module that provides information about obsolescence.
69 * Prints a message directing the user to a wiki page describing replacement
70 * options.
72 class ObsoleteToolModule : public gmx::ICommandLineModule
74 public:
75 //! Creates an obsolete tool module for a tool with the given name.
76 explicit ObsoleteToolModule(const char *name)
77 : name_(name)
81 virtual const char *name() const
83 return name_;
85 virtual const char *shortDescription() const
87 return NULL;
90 virtual void init(gmx::CommandLineModuleSettings * /*settings*/)
93 virtual int run(int /*argc*/, char * /*argv*/[])
95 printMessage();
96 return 0;
98 virtual void writeHelp(const gmx::CommandLineHelpContext & /*context*/) const
100 printMessage();
103 private:
104 void printMessage() const
106 std::fprintf(stderr,
107 "This tool is no longer present in GROMACS. Please see\n"
108 " http://jenkins.gromacs.org/job/Documentation_Nightly_master/javadoc/user-guide/cmdline.html#command-changes\n"
109 "for ideas how to perform the same tasks with the "
110 "new tools.\n");
113 const char *name_;
116 // TODO: Consider removing duplication with CMainCommandLineModule from
117 // cmdlinemodulemanager.cpp.
118 class NoNiceModule : public gmx::ICommandLineModule
120 public:
121 //! \copydoc gmx::CommandLineModuleManager::CMainFunction
122 typedef gmx::CommandLineModuleManager::CMainFunction CMainFunction;
124 /*! \brief
125 * Creates a wrapper module for the given main function.
127 * \param[in] name Name for the module.
128 * \param[in] shortDescription One-line description for the module.
129 * \param[in] mainFunction Main function to wrap.
131 * Does not throw.
133 NoNiceModule(const char *name, const char *shortDescription,
134 CMainFunction mainFunction)
135 : name_(name), shortDescription_(shortDescription),
136 mainFunction_(mainFunction)
140 virtual const char *name() const
142 return name_;
144 virtual const char *shortDescription() const
146 return shortDescription_;
149 virtual void init(gmx::CommandLineModuleSettings *settings)
151 settings->setDefaultNiceLevel(0);
153 virtual int run(int argc, char *argv[])
155 return mainFunction_(argc, argv);
157 virtual void writeHelp(const gmx::CommandLineHelpContext &context) const
159 writeCommandLineHelpCMain(context, name_, mainFunction_);
162 private:
163 const char *name_;
164 const char *shortDescription_;
165 CMainFunction mainFunction_;
168 /*! \brief
169 * Convenience function for creating and registering a module.
171 * \param[in] manager Module manager to which to register the module.
172 * \param[in] mainFunction Main function to wrap.
173 * \param[in] name Name for the new module.
174 * \param[in] shortDescription One-line description for the new module.
176 void registerModule(gmx::CommandLineModuleManager *manager,
177 gmx::CommandLineModuleManager::CMainFunction mainFunction,
178 const char *name, const char *shortDescription)
180 manager->addModuleCMain(name, shortDescription, mainFunction);
183 /*! \brief
184 * Convenience function for creating and registering a module that defaults to
185 * -nice 0.
187 * \param[in] manager Module manager to which to register the module.
188 * \param[in] mainFunction Main function to wrap.
189 * \param[in] name Name for the new module.
190 * \param[in] shortDescription One-line description for the new module.
192 void registerModuleNoNice(gmx::CommandLineModuleManager *manager,
193 gmx::CommandLineModuleManager::CMainFunction mainFunction,
194 const char *name, const char *shortDescription)
196 gmx::CommandLineModulePointer module(
197 new NoNiceModule(name, shortDescription, mainFunction));
198 manager->addModule(std::move(module));
201 /*! \brief
202 * Convenience function for registering a module for an obsolete tool.
204 * \param[in] manager Module manager to which to register the module.
205 * \param[in] name Name for the obsolete tool.
207 void registerObsoleteTool(gmx::CommandLineModuleManager *manager,
208 const char *name)
210 gmx::CommandLineModulePointer module(new ObsoleteToolModule(name));
211 manager->addModule(std::move(module));
214 } // namespace
216 void registerLegacyModules(gmx::CommandLineModuleManager *manager)
218 // Modules from this directory (were in src/kernel/).
219 registerModule(manager, &gmx_check, "check",
220 "Check and compare files");
221 registerModule(manager, &gmx_dump, "dump",
222 "Make binary files human readable");
223 registerModule(manager, &gmx_grompp, "grompp",
224 "Make a run input file");
225 registerModule(manager, &gmx_pdb2gmx, "pdb2gmx",
226 "Convert coordinate files to topology and FF-compliant coordinate files");
227 registerModule(manager, &gmx_convert_tpr, "convert-tpr",
228 "Make a modifed run-input file");
229 registerObsoleteTool(manager, "tpbconv");
230 registerModule(manager, &gmx_x2top, "x2top",
231 "Generate a primitive topology from coordinates");
233 registerModuleNoNice(manager, &gmx_mdrun, "mdrun",
234 "Perform a simulation, do a normal mode analysis or an energy minimization");
236 gmx::ICommandLineOptionsModule::registerModuleFactory(
237 manager, gmx::InsertMoleculesInfo::name,
238 gmx::InsertMoleculesInfo::shortDescription,
239 &gmx::InsertMoleculesInfo::create);
241 // Modules from gmx_ana.h.
242 registerModule(manager, &gmx_do_dssp, "do_dssp",
243 "Assign secondary structure and calculate solvent accessible surface area");
244 registerModule(manager, &gmx_editconf, "editconf",
245 "Convert and manipulates structure files");
246 registerModule(manager, &gmx_eneconv, "eneconv",
247 "Convert energy files");
248 registerModule(manager, &gmx_solvate, "solvate",
249 "Solvate a system");
250 registerObsoleteTool(manager, "genbox");
251 registerModule(manager, &gmx_genconf, "genconf",
252 "Multiply a conformation in 'random' orientations");
253 registerModule(manager, &gmx_genion, "genion",
254 "Generate monoatomic ions on energetically favorable positions");
255 registerModule(manager, &gmx_genpr, "genrestr",
256 "Generate position restraints or distance restraints for index groups");
257 registerModule(manager, &gmx_make_edi, "make_edi",
258 "Generate input files for essential dynamics sampling");
259 registerModule(manager, &gmx_make_ndx, "make_ndx",
260 "Make index files");
261 registerModule(manager, &gmx_mk_angndx, "mk_angndx",
262 "Generate index files for 'gmx angle'");
263 registerModule(manager, &gmx_trjcat, "trjcat",
264 "Concatenate trajectory files");
265 registerModule(manager, &gmx_trjconv, "trjconv",
266 "Convert and manipulates trajectory files");
267 registerModule(manager, &gmx_trjorder, "trjorder",
268 "Order molecules according to their distance to a group");
269 registerModule(manager, &gmx_xpm2ps, "xpm2ps",
270 "Convert XPM (XPixelMap) matrices to postscript or XPM");
272 registerModule(manager, &gmx_anadock, "anadock",
273 "Cluster structures from Autodock runs");
274 registerModule(manager, &gmx_anaeig, "anaeig",
275 "Analyze eigenvectors/normal modes");
276 registerModule(manager, &gmx_analyze, "analyze",
277 "Analyze data sets");
278 registerModule(manager, &gmx_g_angle, "angle",
279 "Calculate distributions and correlations for angles and dihedrals");
280 registerModule(manager, &gmx_bar, "bar",
281 "Calculate free energy difference estimates through Bennett's acceptance ratio");
282 registerObsoleteTool(manager, "bond");
283 registerObsoleteTool(manager, "dist");
284 registerObsoleteTool(manager, "sas");
285 registerObsoleteTool(manager, "sgangle");
287 registerModule(manager, &gmx_bundle, "bundle",
288 "Analyze bundles of axes, e.g., helices");
289 registerModule(manager, &gmx_chi, "chi",
290 "Calculate everything you want to know about chi and other dihedrals");
291 registerModule(manager, &gmx_cluster, "cluster",
292 "Cluster structures");
293 registerModule(manager, &gmx_clustsize, "clustsize",
294 "Calculate size distributions of atomic clusters");
295 registerModule(manager, &gmx_confrms, "confrms",
296 "Fit two structures and calculates the RMSD");
297 registerModule(manager, &gmx_covar, "covar",
298 "Calculate and diagonalize the covariance matrix");
299 registerModule(manager, &gmx_current, "current",
300 "Calculate dielectric constants and current autocorrelation function");
301 registerModule(manager, &gmx_density, "density",
302 "Calculate the density of the system");
303 registerModule(manager, &gmx_densmap, "densmap",
304 "Calculate 2D planar or axial-radial density maps");
305 registerModule(manager, &gmx_densorder, "densorder",
306 "Calculate surface fluctuations");
307 registerModule(manager, &gmx_dielectric, "dielectric",
308 "Calculate frequency dependent dielectric constants");
309 registerModule(manager, &gmx_dipoles, "dipoles",
310 "Compute the total dipole plus fluctuations");
311 registerModule(manager, &gmx_disre, "disre",
312 "Analyze distance restraints");
313 registerModule(manager, &gmx_dos, "dos",
314 "Analyze density of states and properties based on that");
315 registerModule(manager, &gmx_dyecoupl, "dyecoupl",
316 "Extract dye dynamics from trajectories");
317 registerModule(manager, &gmx_dyndom, "dyndom",
318 "Interpolate and extrapolate structure rotations");
319 registerModule(manager, &gmx_enemat, "enemat",
320 "Extract an energy matrix from an energy file");
321 registerModule(manager, &gmx_energy, "energy",
322 "Writes energies to xvg files and display averages");
323 registerModule(manager, &gmx_filter, "filter",
324 "Frequency filter trajectories, useful for making smooth movies");
325 registerModule(manager, &gmx_gyrate, "gyrate",
326 "Calculate the radius of gyration");
327 registerModule(manager, &gmx_h2order, "h2order",
328 "Compute the orientation of water molecules");
329 registerModule(manager, &gmx_hbond, "hbond",
330 "Compute and analyze hydrogen bonds");
331 registerModule(manager, &gmx_helix, "helix",
332 "Calculate basic properties of alpha helices");
333 registerModule(manager, &gmx_helixorient, "helixorient",
334 "Calculate local pitch/bending/rotation/orientation inside helices");
335 registerModule(manager, &gmx_hydorder, "hydorder",
336 "Compute tetrahedrality parameters around a given atom");
337 registerModule(manager, &gmx_lie, "lie",
338 "Estimate free energy from linear combinations");
339 registerModule(manager, &gmx_mdmat, "mdmat",
340 "Calculate residue contact maps");
341 registerModule(manager, &gmx_mindist, "mindist",
342 "Calculate the minimum distance between two groups");
343 registerModule(manager, &gmx_morph, "morph",
344 "Interpolate linearly between conformations");
345 registerModule(manager, &gmx_msd, "msd",
346 "Calculates mean square displacements");
347 registerModule(manager, &gmx_nmeig, "nmeig",
348 "Diagonalize the Hessian for normal mode analysis");
349 registerModule(manager, &gmx_nmens, "nmens",
350 "Generate an ensemble of structures from the normal modes");
351 registerModule(manager, &gmx_nmtraj, "nmtraj",
352 "Generate a virtual oscillating trajectory from an eigenvector");
353 registerModule(manager, &gmx_order, "order",
354 "Compute the order parameter per atom for carbon tails");
355 registerModule(manager, &gmx_pme_error, "pme_error",
356 "Estimate the error of using PME with a given input file");
357 registerModule(manager, &gmx_polystat, "polystat",
358 "Calculate static properties of polymers");
359 registerModule(manager, &gmx_potential, "potential",
360 "Calculate the electrostatic potential across the box");
361 registerModule(manager, &gmx_principal, "principal",
362 "Calculate principal axes of inertia for a group of atoms");
363 registerModule(manager, &gmx_rama, "rama",
364 "Compute Ramachandran plots");
365 registerModule(manager, &gmx_rms, "rms",
366 "Calculate RMSDs with a reference structure and RMSD matrices");
367 registerModule(manager, &gmx_rmsdist, "rmsdist",
368 "Calculate atom pair distances averaged with power -2, -3 or -6");
369 registerModule(manager, &gmx_rmsf, "rmsf",
370 "Calculate atomic fluctuations");
371 registerModule(manager, &gmx_rotacf, "rotacf",
372 "Calculate the rotational correlation function for molecules");
373 registerModule(manager, &gmx_rotmat, "rotmat",
374 "Plot the rotation matrix for fitting to a reference structure");
375 registerModule(manager, &gmx_saltbr, "saltbr",
376 "Compute salt bridges");
377 registerModule(manager, &gmx_sans, "sans",
378 "Compute small angle neutron scattering spectra");
379 registerModule(manager, &gmx_saxs, "saxs",
380 "Compute small angle X-ray scattering spectra");
381 registerModule(manager, &gmx_sham, "sham",
382 "Compute free energies or other histograms from histograms");
383 registerModule(manager, &gmx_sigeps, "sigeps",
384 "Convert c6/12 or c6/cn combinations to and from sigma/epsilon");
385 registerModule(manager, &gmx_sorient, "sorient",
386 "Analyze solvent orientation around solutes");
387 registerModule(manager, &gmx_spatial, "spatial",
388 "Calculate the spatial distribution function");
389 registerModule(manager, &gmx_spol, "spol",
390 "Analyze solvent dipole orientation and polarization around solutes");
391 registerModule(manager, &gmx_tcaf, "tcaf",
392 "Calculate viscosities of liquids");
393 registerModule(manager, &gmx_traj, "traj",
394 "Plot x, v, f, box, temperature and rotational energy from trajectories");
395 registerModule(manager, &gmx_tune_pme, "tune_pme",
396 "Time mdrun as a function of PME ranks to optimize settings");
397 registerModule(manager, &gmx_vanhove, "vanhove",
398 "Compute Van Hove displacement and correlation functions");
399 registerModule(manager, &gmx_velacc, "velacc",
400 "Calculate velocity autocorrelation functions");
401 registerModule(manager, &gmx_wham, "wham",
402 "Perform weighted histogram analysis after umbrella sampling");
403 registerModule(manager, &gmx_wheel, "wheel",
404 "Plot helical wheels");
405 registerModuleNoNice(manager, &gmx_view, "view",
406 "View a trajectory on an X-Windows terminal");
409 gmx::CommandLineModuleGroup group =
410 manager->addModuleGroup("Generating topologies and coordinates");
411 group.addModuleWithDescription("editconf", "Edit the box and write subgroups");
412 group.addModule("x2top");
413 group.addModule("solvate");
414 group.addModule("insert-molecules");
415 group.addModule("genconf");
416 group.addModule("genion");
417 group.addModule("genrestr");
418 group.addModule("pdb2gmx");
421 gmx::CommandLineModuleGroup group =
422 manager->addModuleGroup("Running a simulation");
423 group.addModule("grompp");
424 group.addModule("mdrun");
425 group.addModule("convert-tpr");
428 gmx::CommandLineModuleGroup group =
429 manager->addModuleGroup("Viewing trajectories");
430 group.addModule("nmtraj");
431 group.addModule("view");
434 gmx::CommandLineModuleGroup group =
435 manager->addModuleGroup("Processing energies");
436 group.addModule("enemat");
437 group.addModule("energy");
438 group.addModuleWithDescription("mdrun", "(Re)calculate energies for trajectory frames with -rerun");
441 gmx::CommandLineModuleGroup group =
442 manager->addModuleGroup("Converting files");
443 group.addModule("editconf");
444 group.addModule("eneconv");
445 group.addModule("sigeps");
446 group.addModule("trjcat");
447 group.addModule("trjconv");
448 group.addModule("xpm2ps");
451 gmx::CommandLineModuleGroup group =
452 manager->addModuleGroup("Tools");
453 group.addModule("analyze");
454 group.addModule("dyndom");
455 group.addModule("filter");
456 group.addModule("lie");
457 group.addModule("morph");
458 group.addModule("pme_error");
459 group.addModule("sham");
460 group.addModule("spatial");
461 group.addModule("traj");
462 group.addModule("tune_pme");
463 group.addModule("wham");
464 group.addModule("check");
465 group.addModule("dump");
466 group.addModule("make_ndx");
467 group.addModule("mk_angndx");
468 group.addModule("trjorder");
469 group.addModule("xpm2ps");
472 gmx::CommandLineModuleGroup group =
473 manager->addModuleGroup("Distances between structures");
474 group.addModule("cluster");
475 group.addModule("confrms");
476 group.addModule("rms");
477 group.addModule("rmsf");
480 gmx::CommandLineModuleGroup group =
481 manager->addModuleGroup("Distances in structures over time");
482 group.addModule("mindist");
483 group.addModule("mdmat");
484 group.addModule("polystat");
485 group.addModule("rmsdist");
488 gmx::CommandLineModuleGroup group =
489 manager->addModuleGroup("Mass distribution properties over time");
490 group.addModule("gyrate");
491 group.addModule("msd");
492 group.addModule("polystat");
493 group.addModule("rdf");
494 group.addModule("rotacf");
495 group.addModule("rotmat");
496 group.addModule("sans");
497 group.addModule("saxs");
498 group.addModule("traj");
499 group.addModule("vanhove");
502 gmx::CommandLineModuleGroup group =
503 manager->addModuleGroup("Analyzing bonded interactions");
504 group.addModule("angle");
505 group.addModule("mk_angndx");
508 gmx::CommandLineModuleGroup group =
509 manager->addModuleGroup("Structural properties");
510 group.addModule("anadock");
511 group.addModule("bundle");
512 group.addModule("clustsize");
513 group.addModule("disre");
514 group.addModule("hbond");
515 group.addModule("order");
516 group.addModule("principal");
517 group.addModule("rdf");
518 group.addModule("saltbr");
519 group.addModule("sorient");
520 group.addModule("spol");
523 gmx::CommandLineModuleGroup group =
524 manager->addModuleGroup("Kinetic properties");
525 group.addModule("bar");
526 group.addModule("current");
527 group.addModule("dos");
528 group.addModule("dyecoupl");
529 group.addModule("principal");
530 group.addModule("tcaf");
531 group.addModule("traj");
532 group.addModule("vanhove");
533 group.addModule("velacc");
536 gmx::CommandLineModuleGroup group =
537 manager->addModuleGroup("Electrostatic properties");
538 group.addModule("current");
539 group.addModule("dielectric");
540 group.addModule("dipoles");
541 group.addModule("potential");
542 group.addModule("spol");
543 group.addModule("genion");
546 gmx::CommandLineModuleGroup group =
547 manager->addModuleGroup("Protein-specific analysis");
548 group.addModule("do_dssp");
549 group.addModule("chi");
550 group.addModule("helix");
551 group.addModule("helixorient");
552 group.addModule("rama");
553 group.addModule("wheel");
556 gmx::CommandLineModuleGroup group =
557 manager->addModuleGroup("Interfaces");
558 group.addModule("bundle");
559 group.addModule("density");
560 group.addModule("densmap");
561 group.addModule("densorder");
562 group.addModule("h2order");
563 group.addModule("hydorder");
564 group.addModule("order");
565 group.addModule("potential");
568 gmx::CommandLineModuleGroup group =
569 manager->addModuleGroup("Covariance analysis");
570 group.addModuleWithDescription("anaeig", "Analyze the eigenvectors");
571 group.addModule("covar");
572 group.addModule("make_edi");
575 gmx::CommandLineModuleGroup group =
576 manager->addModuleGroup("Normal modes");
577 group.addModuleWithDescription("anaeig", "Analyze the normal modes");
578 group.addModule("nmeig");
579 group.addModule("nmtraj");
580 group.addModule("nmens");
581 group.addModule("grompp");
582 group.addModuleWithDescription("mdrun", "Find a potential energy minimum and calculate the Hessian");