2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018, 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.
39 * \author Mark Abraham <mark.j.abraham@gmail.com>
44 #include "gromacs/gmxpreprocess/pdb2gmx.h"
46 #include "gromacs/utility/futil.h"
47 #include "gromacs/utility/textreader.h"
49 #include "testutils/cmdlinetest.h"
50 #include "testutils/conftest.h"
51 #include "testutils/filematchers.h"
52 #include "testutils/refdata.h"
53 #include "testutils/testfilemanager.h"
54 #include "testutils/textblockmatchers.h"
63 using gmx::test::CommandLine;
64 using gmx::test::ConfMatch;
66 //! Test parameter struct.
67 using CommandLineOptionParams = std::tuple<std::string, std::string, std::string, std::string,
68 std::string, std::string>;
70 class Pdb2gmxTest : public gmx::test::CommandLineTestBase,
71 public ::testing::WithParamInterface<CommandLineOptionParams>
76 // TODO It would be preferable to just scrub the content
77 // that actually varies, but we don't have enough regular
78 // expression support for that yet.
80 // Note that the "\n" are needed so these regular
81 // expressions match Windows line endings.
82 textMatcher_.addRegexToSkip("^;[[:blank:]] *File '.*' was generated.*\n");
83 textMatcher_.addRegexToSkip("^;[[:blank:]]*By user:.*\n");
84 textMatcher_.addRegexToSkip("^;[[:blank:]]*On host:.*\n");
85 textMatcher_.addRegexToSkip("^;[[:blank:]]*At date:.*\n");
86 textMatcher_.addRegexToSkip("^;[[:blank:]]*:-\\).*\\(-:.*\n");
87 textMatcher_.addRegexToSkip("^;[[:blank:]]*Executable:.*\n");
88 textMatcher_.addRegexToSkip("^;[[:blank:]]*Data prefix:.*\n");
89 textMatcher_.addRegexToSkip("^;[[:blank:]]*Working dir:.*\n");
90 textMatcher_.addRegexToSkip("^;[[:blank:]]*pdb2gmx-test.*\n");
91 setOutputFile("-o", "conf.gro", ConfMatch());
92 setOutputFile("-p", "topol.top", TextFileMatch(textMatcher_));
95 void runTest(const CommandLine &args)
97 CommandLine &cmdline = commandLine();
100 ASSERT_EQ(0, gmx_pdb2gmx(cmdline.argc(), cmdline.argv()));
103 FilteringExactTextMatch textMatcher_;
106 TEST_P(Pdb2gmxTest, ProducesMatchingTopology)
108 const auto ¶ms = GetParam();
109 std::string cmdline[] = {
110 "pdb2gmx", "-ignh", "-ff", std::get<0>(params), "-water", std::get<1>(params), "-vsite", std::get<2>(params),
111 "-chainsep", std::get<3>(params), "-merge", std::get<4>(params)
113 setInputFile("-f", std::get<5>(params));
114 runTest(CommandLine(cmdline));
117 INSTANTIATE_TEST_CASE_P(ForOplsaa, Pdb2gmxTest,
119 (::testing::Values("oplsaa"),
120 ::testing::Values("tip3p", "tip4p", "tip5p"),
121 ::testing::Values("none", "h"),
122 ::testing::Values("id_or_ter"),
123 ::testing::Values("no"),
124 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"))
127 INSTANTIATE_TEST_CASE_P(ForGromos43a1, Pdb2gmxTest,
129 (::testing::Values("gromos43a1"),
130 ::testing::Values("spc", "spce"),
131 ::testing::Values("none", "h"),
132 ::testing::Values("id_or_ter"),
133 ::testing::Values("no"),
134 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"))
137 INSTANTIATE_TEST_CASE_P(ForGromos53a6, Pdb2gmxTest,
139 (::testing::Values("gromos53a6"),
140 ::testing::Values("spc", "spce"),
141 ::testing::Values("none", "h"),
142 ::testing::Values("id_or_ter"),
143 ::testing::Values("no"),
144 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"))
147 INSTANTIATE_TEST_CASE_P(ForAmber99sb_ildn, Pdb2gmxTest,
149 (::testing::Values("amber99sb-ildn"),
150 ::testing::Values("tip3p"),
151 ::testing::Values("none", "h"),
152 ::testing::Values("id_or_ter"),
153 ::testing::Values("no"),
154 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"))
157 INSTANTIATE_TEST_CASE_P(ForCharmm27, Pdb2gmxTest,
159 (::testing::Values("charmm27"),
160 ::testing::Values("tip3p"),
161 ::testing::Values("none", "h"),
162 ::testing::Values("id_or_ter"),
163 ::testing::Values("no"),
164 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"))
168 INSTANTIATE_TEST_CASE_P(ChainSep, Pdb2gmxTest,
170 (::testing::Values("charmm27"),
171 ::testing::Values("tip3p"),
172 ::testing::Values("none"),
173 ::testing::Values("id", "ter", "id_or_ter", "id_and_ter"),
174 ::testing::Values("all", "no"),
175 ::testing::Values("chainTer.pdb"))