added a unit test for make_ndx to check generation of default protein index groups
authorThomas Ullmann <thomas.ullmann@mpibpc.mpg.de>
Wed, 6 Feb 2019 21:59:02 +0000 (22:59 +0100)
committerThomas Ullmann <thomas.ullmann@mpibpc.mpg.de>
Wed, 6 Feb 2019 21:59:02 +0000 (22:59 +0100)
Change-Id: I56b26a7eefeb818ec038696b8bb9e3a47e9ac536

src/gromacs/gmxana/tests/CMakeLists.txt
src/gromacs/gmxana/tests/gmx_make_ndx.cpp [new file with mode: 0644]
src/gromacs/gmxana/tests/refdata/GmxMakeNdx_WritesDefaultProteinIndexGroups.xml [new file with mode: 0644]

index 4738db4f77206b9f01356c5788caa20bfd38a63f..846e6aeb553f4a45b889d8050542ad0ac9111bea 100644 (file)
@@ -39,6 +39,7 @@ gmx_add_gtest_executable(
     entropy.cpp
     gmx_traj.cpp
     gmx_trjconv.cpp
+    gmx_make_ndx.cpp
     gmx_mindist.cpp
     gmx_msd.cpp
     )
diff --git a/src/gromacs/gmxana/tests/gmx_make_ndx.cpp b/src/gromacs/gmxana/tests/gmx_make_ndx.cpp
new file mode 100644 (file)
index 0000000..a8ec219
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2019, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Tests for gmx make_ndx.
+ *
+ * \author R. Thomas Ullmann <tullman@gwdg.de>
+ */
+#include "gmxpre.h"
+
+#include "gromacs/gmxana/gmx_ana.h"
+
+#include "testutils/cmdlinetest.h"
+#include "testutils/stdiohelper.h"
+#include "testutils/testfilemanager.h"
+#include "testutils/textblockmatchers.h"
+
+namespace
+{
+
+class GmxMakeNdx : public gmx::test::CommandLineTestBase
+{
+    public:
+        /*! \brief runs the test for the filename prefix \p sysName from the simulation data base
+            \param[in]   sysName   file name prefix sysName.g96 must be present in the simulation database
+         */
+        void runTest(const std::string &sysName)
+        {
+            auto       &cmdline     = commandLine();
+            auto        groFileName = sysName + ".g96";
+            std::string ndxFileName = sysName + ".ndx";
+            setInputFile("-f", groFileName);
+            setOutputFile("-o", ndxFileName.c_str(), gmx::test::ExactTextMatch());
+
+            gmx::test::StdioTestHelper stdioHelper(&fileManager());
+            stdioHelper.redirectStringToStdin("q\n");
+
+            ASSERT_EQ(0, gmx_make_ndx(cmdline.argc(), cmdline.argv()));
+            checkOutputFiles();
+        }
+};
+
+TEST_F(GmxMakeNdx, WritesDefaultProteinIndexGroups)
+{
+    std::string sysName("villin");
+    runTest(sysName);
+}
+
+} // namespace
diff --git a/src/gromacs/gmxana/tests/refdata/GmxMakeNdx_WritesDefaultProteinIndexGroups.xml b/src/gromacs/gmxana/tests/refdata/GmxMakeNdx_WritesDefaultProteinIndexGroups.xml
new file mode 100644 (file)
index 0000000..9763d9f
--- /dev/null
@@ -0,0 +1,107 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <OutputFiles Name="Files">
+    <File Name="-o">
+      <String Name="Contents"><![CDATA[
+[ System ]
+   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15
+  16   17   18   19   20   21   22   23   24   25   26   27   28   29   30
+  31   32   33   34   35   36   37   38   39   40   41   42   43   44   45
+  46   47   48   49   50   51   52   53   54   55   56   57   58   59   60
+  61   62   63   64   65   66   67   68   69   70   71   72   73   74   75
+  76   77   78   79   80   81   82   83   84   85   86   87   88   89   90
+  91   92   93   94   95   96   97   98   99  100  101  102  103  104  105
+ 106  107  108  109  110  111  112  113  114  115  116  117  118  119  120
+ 121  122  123  124  125  126  127  128  129  130  131  132  133  134  135
+ 136  137  138  139  140  141  142  143  144  145  146  147  148  149  150
+ 151  152  153  154  155  156  157  158  159  160  161  162  163  164  165
+ 166  167  168  169  170  171  172  173  174  175  176  177  178  179  180
+ 181  182  183  184  185  186  187  188  189  190  191  192  193  194  195
+ 196  197  198  199  200  201  202  203  204  205  206  207  208  209  210
+ 211  212  213  214  215  216  217  218  219  220  221  222  223  224  225
+ 226  227  228  229  230  231  232  233  234  235  236  237  238  239  240
+ 241  242  243  244  245  246  247  248  249  250  251  252  253  254  255
+ 256
+[ Protein ]
+   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15
+  16   17   18   19   20   21   22   23   24   25   26   27   28   29   30
+  31   32   33   34   35   36   37   38   39   40   41   42   43   44   45
+  46   47   48   49   50   51   52   53   54   55   56   57   58   59   60
+  61   62   63   64   65   66   67   68   69   70   71   72   73   74   75
+  76   77   78   79   80   81   82   83   84   85   86   87   88   89   90
+  91   92   93   94   95   96   97   98   99  100  101  102  103  104  105
+ 106  107  108  109  110  111  112  113  114  115  116  117  118  119  120
+ 121  122  123  124  125  126  127  128  129  130  131  132  133  134  135
+ 136  137  138  139  140  141  142  143  144  145  146  147  148  149  150
+ 151  152  153  154  155  156  157  158  159  160  161  162  163  164  165
+ 166  167  168  169  170  171  172  173  174  175  176  177  178  179  180
+ 181  182  183  184  185  186  187  188  189  190  191  192  193  194  195
+ 196  197  198  199  200  201  202  203  204  205  206  207  208  209  210
+ 211  212  213  214  215  216  217  218  219  220  221  222  223  224  225
+ 226  227  228  229  230  231  232  233  234  235  236  237  238  239  240
+ 241  242  243  244  245  246  247  248  249  250  251  252  253  254  255
+ 256
+[ Protein-H ]
+   1    5    7   10   11   12   13   14   15   17   19   23   24   25   27
+  29   32   35   36   37   38   39   40   42   44   47   48   50   52   54
+  56   58   59   60   62   64   67   70   73   75   76   79   82   83   84
+  86   88   91   92   93   95   97   99  100  101  103  105  108  109  110
+ 111  112  113  115  117  120  122  123  124  126  129  130  131  133  135
+ 138  139  141  143  144  146  148  150  151  152  154  156  159  162  163
+ 164  165  166  167  169  171  173  177  181  182  183  185  187  190  191
+ 192  194  196  198  199  200  202  204  207  208  209  211  213  215  216
+ 217  219  221  224  227  228  229  232  233  234  236  238  241  244  247
+ 250  254  255  256
+[ C-alpha ]
+   5   17   27   42   62   86  103  115  126  133  154  169  185  202  219
+ 236
+[ Backbone ]
+   1    5   13   15   17   23   25   27   38   40   42   58   60   62   82
+  84   86   99  101  103  111  113  115  122  124  126  129  131  133  150
+ 152  154  165  167  169  181  183  185  198  200  202  215  217  219  232
+ 234  236  254
+[ MainChain ]
+   1    5   13   14   15   17   23   24   25   27   38   39   40   42   58
+  59   60   62   82   83   84   86   99  100  101  103  111  112  113  115
+ 122  123  124  126  129  130  131  133  150  151  152  154  165  166  167
+ 169  181  182  183  185  198  199  200  202  215  216  217  219  232  233
+ 234  236  254
+[ MainChain+Cb ]
+   1    5    7   13   14   15   17   19   23   24   25   27   29   38   39
+  40   42   44   58   59   60   62   64   82   83   84   86   88   99  100
+ 101  103  105  111  112  113  115  117  122  123  124  126  129  130  131
+ 133  135  150  151  152  154  156  165  166  167  169  171  181  182  183
+ 185  187  198  199  200  202  204  215  216  217  219  221  232  233  234
+ 236  238  254
+[ MainChain+H ]
+   1    2    3    4    5   13   14   15   16   17   23   24   25   26   27
+  38   39   40   41   42   58   59   60   61   62   82   83   84   85   86
+  99  100  101  102  103  111  112  113  114  115  122  123  124  125  126
+ 129  130  131  132  133  150  151  152  153  154  165  166  167  168  169
+ 181  182  183  184  185  198  199  200  201  202  215  216  217  218  219
+ 232  233  234  235  236  254
+[ SideChain ]
+   6    7    8    9   10   11   12   18   19   20   21   22   28   29   30
+  31   32   33   34   35   36   37   43   44   45   46   47   48   49   50
+  51   52   53   54   55   56   57   63   64   65   66   67   68   69   70
+  71   72   73   74   75   76   77   78   79   80   81   87   88   89   90
+  91   92   93   94   95   96   97   98  104  105  106  107  108  109  110
+ 116  117  118  119  120  121  127  128  134  135  136  137  138  139  140
+ 141  142  143  144  145  146  147  148  149  155  156  157  158  159  160
+ 161  162  163  164  170  171  172  173  174  175  176  177  178  179  180
+ 186  187  188  189  190  191  192  193  194  195  196  197  203  204  205
+ 206  207  208  209  210  211  212  213  214  220  221  222  223  224  225
+ 226  227  228  229  230  231  237  238  239  240  241  242  243  244  245
+ 246  247  248  249  250  251  252  253  255  256
+[ SideChain-H ]
+   7   10   11   12   19   29   32   35   36   37   44   47   48   50   52
+  54   56   64   67   70   73   75   76   79   88   91   92   93   95   97
+ 105  108  109  110  117  120  135  138  139  141  143  144  146  148  156
+ 159  162  163  164  171  173  177  187  190  191  192  194  196  204  207
+ 208  209  211  213  221  224  227  228  229  238  241  244  247  250  255
+ 256
+]]></String>
+    </File>
+  </OutputFiles>
+</ReferenceData>