Sort includes outside src/gromacs
[alexxy/gromacs.git] / src / programs / legacymodules.cpp
index 490651c35be136f120d9a0a8235220e943b38760..720122cba70ab45d8a5adc810d0a9b18a2d087df 100644 (file)
  *
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  */
+#include "gmxpre.h"
+
 #include "legacymodules.h"
 
 #include <cstdio>
 
 #include "gromacs/commandline/cmdlinemodule.h"
 #include "gromacs/commandline/cmdlinemodulemanager.h"
-
 #include "gromacs/gmxana/gmx_ana.h"
+#include "gromacs/gmxpreprocess/genconf.h"
 #include "gromacs/gmxpreprocess/grompp.h"
+#include "gromacs/gmxpreprocess/insert-molecules.h"
 #include "gromacs/gmxpreprocess/pdb2gmx.h"
 #include "gromacs/gmxpreprocess/protonate.h"
+#include "gromacs/gmxpreprocess/solvate.h"
 #include "gromacs/gmxpreprocess/x2top.h"
 #include "gromacs/tools/check.h"
-#include "gromacs/tools/dump.h"
 #include "gromacs/tools/convert_tpr.h"
+#include "gromacs/tools/dump.h"
 
 #include "mdrun/mdrun_main.h"
 #include "view/view.h"
@@ -83,6 +87,9 @@ class ObsoleteToolModule : public gmx::CommandLineModuleInterface
             return NULL;
         }
 
+        virtual void init(gmx::CommandLineModuleSettings * /*settings*/)
+        {
+        }
         virtual int run(int /*argc*/, char * /*argv*/[])
         {
             printMessage();
@@ -104,7 +111,58 @@ class ObsoleteToolModule : public gmx::CommandLineModuleInterface
         }
 
         const char             *name_;
+};
+
+// TODO: Consider removing duplication with CMainCommandLineModule from
+// cmdlinemodulemanager.cpp.
+class NoNiceModule : public gmx::CommandLineModuleInterface
+{
+    public:
+        //! \copydoc gmx::CommandLineModuleManager::CMainFunction
+        typedef gmx::CommandLineModuleManager::CMainFunction CMainFunction;
+
+        /*! \brief
+         * Creates a wrapper module for the given main function.
+         *
+         * \param[in] name             Name for the module.
+         * \param[in] shortDescription One-line description for the module.
+         * \param[in] mainFunction     Main function to wrap.
+         *
+         * Does not throw.
+         */
+        NoNiceModule(const char *name, const char *shortDescription,
+                     CMainFunction mainFunction)
+            : name_(name), shortDescription_(shortDescription),
+              mainFunction_(mainFunction)
+        {
+        }
+
+        virtual const char *name() const
+        {
+            return name_;
+        }
+        virtual const char *shortDescription() const
+        {
+            return shortDescription_;
+        }
 
+        virtual void init(gmx::CommandLineModuleSettings *settings)
+        {
+            settings->setDefaultNiceLevel(0);
+        }
+        virtual int run(int argc, char *argv[])
+        {
+            return mainFunction_(argc, argv);
+        }
+        virtual void writeHelp(const gmx::CommandLineHelpContext &context) const
+        {
+            writeCommandLineHelpCMain(context, name_, mainFunction_);
+        }
+
+    private:
+        const char             *name_;
+        const char             *shortDescription_;
+        CMainFunction           mainFunction_;
 };
 
 /*! \brief
@@ -122,6 +180,24 @@ void registerModule(gmx::CommandLineModuleManager                *manager,
     manager->addModuleCMain(name, shortDescription, mainFunction);
 }
 
+/*! \brief
+ * Convenience function for creating and registering a module that defaults to
+ * -nice 0.
+ *
+ * \param[in] manager          Module manager to which to register the module.
+ * \param[in] mainFunction     Main function to wrap.
+ * \param[in] name             Name for the new module.
+ * \param[in] shortDescription One-line description for the new module.
+ */
+void registerModuleNoNice(gmx::CommandLineModuleManager                *manager,
+                          gmx::CommandLineModuleManager::CMainFunction  mainFunction,
+                          const char *name, const char *shortDescription)
+{
+    gmx::CommandLineModulePointer module(
+            new NoNiceModule(name, shortDescription, mainFunction));
+    manager->addModule(move(module));
+}
+
 /*! \brief
  * Convenience function for registering a module for an obsolete tool.
  *
@@ -150,14 +226,15 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                    "Convert coordinate files to topology and FF-compliant coordinate files");
     registerModule(manager, &gmx_convert_tpr, "convert-tpr",
                    "Make a modifed run-input file");
+    registerObsoleteTool(manager, "tpbconv");
 
     registerModule(manager, &gmx_protonate, "protonate",
                    "Protonate structures");
     registerModule(manager, &gmx_x2top, "x2top",
                    "Generate a primitive topology from coordinates");
 
-    registerModule(manager, &gmx_mdrun, "mdrun",
-                   "Perform a simulation, do a normal mode analysis or an energy minimization");
+    registerModuleNoNice(manager, &gmx_mdrun, "mdrun",
+                         "Perform a simulation, do a normal mode analysis or an energy minimization");
 
     // Modules from gmx_ana.h.
     registerModule(manager, &gmx_do_dssp, "do_dssp",
@@ -166,8 +243,11 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                    "Convert and manipulates structure files");
     registerModule(manager, &gmx_eneconv, "eneconv",
                    "Convert energy files");
-    registerModule(manager, &gmx_genbox, "genbox",
+    registerModule(manager, &gmx_solvate, "solvate",
                    "Solvate a system");
+    registerModule(manager, &gmx_insert_molecules, "insert-molecules",
+                   "Insert molecules into existing vacancies");
+    registerObsoleteTool(manager, "genbox");
     registerModule(manager, &gmx_genconf, "genconf",
                    "Multiply a conformation in 'random' orientations");
     registerModule(manager, &gmx_genion, "genion",
@@ -201,6 +281,7 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                    "Calculate free energy difference estimates through Bennett's acceptance ratio");
     registerObsoleteTool(manager, "bond");
     registerObsoleteTool(manager, "dist");
+    registerObsoleteTool(manager, "sas");
     registerObsoleteTool(manager, "sgangle");
 
     registerModule(manager, &gmx_bundle, "bundle",
@@ -253,8 +334,6 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                    "Calculate local pitch/bending/rotation/orientation inside helices");
     registerModule(manager, &gmx_hydorder, "hydorder",
                    "Compute tetrahedrality parameters around a given atom");
-    registerModule(manager, &gmx_kinetics, "kinetics",
-                   "Analyze kinetic constants from properties based on the Eyring model");
     registerModule(manager, &gmx_lie, "lie",
                    "Estimate free energy from linear combinations");
     registerModule(manager, &gmx_mdmat, "mdmat",
@@ -300,8 +379,6 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                    "Compute salt bridges");
     registerModule(manager, &gmx_sans, "sans",
                    "Compute small angle neutron scattering spectra");
-    registerModule(manager, &gmx_sas, "sas",
-                   "Compute solvent accessible surface area");
     registerModule(manager, &gmx_saxs, "saxs",
                    "Compute small angle X-ray scattering spectra");
     registerModule(manager, &gmx_sham, "sham",
@@ -319,7 +396,7 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
     registerModule(manager, &gmx_traj, "traj",
                    "Plot x, v, f, box, temperature and rotational energy from trajectories");
     registerModule(manager, &gmx_tune_pme, "tune_pme",
-                   "Time mdrun as a function of PME nodes to optimize settings");
+                   "Time mdrun as a function of PME ranks to optimize settings");
     registerModule(manager, &gmx_vanhove, "vanhove",
                    "Compute Van Hove displacement and correlation functions");
     registerModule(manager, &gmx_velacc, "velacc",
@@ -328,8 +405,8 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                    "Perform weighted histogram analysis after umbrella sampling");
     registerModule(manager, &gmx_wheel, "wheel",
                    "Plot helical wheels");
-    registerModule(manager, &gmx_view, "view",
-                   "View a trajectory on an X-Windows terminal");
+    registerModuleNoNice(manager, &gmx_view, "view",
+                         "View a trajectory on an X-Windows terminal");
 
     {
         gmx::CommandLineModuleGroup group =
@@ -337,7 +414,8 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
         group.addModuleWithDescription("editconf", "Edit the box and write subgroups");
         group.addModule("protonate");
         group.addModule("x2top");
-        group.addModule("genbox");
+        group.addModule("solvate");
+        group.addModule("insert-molecules");
         group.addModule("genconf");
         group.addModule("genion");
         group.addModule("genrestr");
@@ -442,7 +520,6 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
         group.addModule("principal");
         group.addModule("rdf");
         group.addModule("saltbr");
-        group.addModule("sas");
         group.addModule("sorient");
         group.addModule("spol");
     }
@@ -453,7 +530,6 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
         group.addModule("current");
         group.addModule("dos");
         group.addModule("dyecoupl");
-        group.addModule("kinetics");
         group.addModule("principal");
         group.addModule("tcaf");
         group.addModule("traj");