2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019, 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/fileio/filetypes.h"
47 #include "gromacs/utility/futil.h"
48 #include "gromacs/utility/textreader.h"
50 #include "testutils/cmdlinetest.h"
51 #include "testutils/conftest.h"
52 #include "testutils/filematchers.h"
53 #include "testutils/refdata.h"
54 #include "testutils/testfilemanager.h"
55 #include "testutils/textblockmatchers.h"
64 using test::CommandLine
;
66 //! Test parameter struct.
67 using CommandLineOptionParams
= std::tuple
<std::string
, std::string
, std::string
, std::string
,
68 std::string
, std::string
, int>;
70 /*! \brief Strings containing regular expressions for lines to skip
73 * \todo It would be preferable to just scrub the content that actually
74 * varies, but we don't use enough regular expression support for that
77 * Note that the "\n" are needed so these regular expressions match
78 * Windows line endings. */
79 std::vector
<std::string
> c_regexStringsToSkip
=
81 "^;[[:blank:]] *File '.*' was generated.*\n",
82 "^;[[:blank:]]*By user:.*\n",
83 "^;[[:blank:]]*On host:.*\n",
84 "^;[[:blank:]]*At date:.*\n",
85 "^;[[:blank:]]*:-\\).*\\(-:.*\n",
86 "^;[[:blank:]]*Executable:.*\n",
87 "^;[[:blank:]]*Data prefix:.*\n",
88 "^;[[:blank:]]*Working dir:.*\n",
89 "^;[[:blank:]]*pdb2gmx.*-test.*\n"
91 //! Compiled regular expressions for lines to skip when matching.
92 FilteringExactTextMatch
c_textMatcher(c_regexStringsToSkip
);
94 class Pdb2gmxTest
: public test::CommandLineTestBase
,
95 public ::testing::WithParamInterface
<CommandLineOptionParams
>
100 int outputFileType
= std::get
<6>(GetParam());
101 if (outputFileType
== efPDB
)
103 // If we're writing PDB output, we are interested in
104 // testing things like TER records and chain IDs.
105 std::string outputfile
= "conf.";
106 outputfile
+= ftp2ext(outputFileType
);
107 ExactTextMatch settings
;
108 setOutputFile("-o", outputfile
.c_str(), TextFileMatch(settings
));
112 setOutputFile("-o", "conf.gro", ConfMatch());
114 setOutputFile("-p", "topol.top", TextFileMatch(c_textMatcher
));
117 void runTest(const CommandLine
&args
)
119 CommandLine
&cmdline
= commandLine();
122 TestReferenceChecker
rootChecker(this->rootChecker());
124 ASSERT_EQ(0, CommandLineTestHelper::runModuleFactory(&pdb2gmxInfo::create
, &cmdline
));
130 TEST_P(Pdb2gmxTest
, ProducesMatchingTopology
)
132 const auto ¶ms
= GetParam();
133 std::string cmdline
[] = {
134 "pdb2gmx", "-ignh", "-ff", std::get
<0>(params
), "-water", std::get
<1>(params
), "-vsite", std::get
<2>(params
),
135 "-chainsep", std::get
<3>(params
), "-merge", std::get
<4>(params
)
137 setInputFile("-f", std::get
<5>(params
));
138 runTest(CommandLine(cmdline
));
141 // These tests are still rather slow when run with TSAN, so in the
142 // CMakeLists.txt file we split them into separtae test binaries.
145 INSTANTIATE_TEST_CASE_P(ForOplsaa
, Pdb2gmxTest
,
147 (::testing::Values("oplsaa"),
148 ::testing::Values("tip3p", "tip4p", "tip5p"),
149 ::testing::Values("none", "h"),
150 ::testing::Values("id_or_ter"),
151 ::testing::Values("no"),
152 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"),
153 ::testing::Values(efGRO
))
158 INSTANTIATE_TEST_CASE_P(ForGromos43a1
, Pdb2gmxTest
,
160 (::testing::Values("gromos43a1"),
161 ::testing::Values("spc", "spce"),
162 ::testing::Values("none", "h"),
163 ::testing::Values("id_or_ter"),
164 ::testing::Values("no"),
165 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"),
166 ::testing::Values(efGRO
))
169 INSTANTIATE_TEST_CASE_P(ForGromos53a6
, Pdb2gmxTest
,
171 (::testing::Values("gromos53a6"),
172 ::testing::Values("spc", "spce"),
173 ::testing::Values("none", "h"),
174 ::testing::Values("id_or_ter"),
175 ::testing::Values("no"),
176 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"),
177 ::testing::Values(efGRO
))
182 INSTANTIATE_TEST_CASE_P(ForAmber99sb_ildn
, Pdb2gmxTest
,
184 (::testing::Values("amber99sb-ildn"),
185 ::testing::Values("tip3p"),
186 ::testing::Values("none", "h"),
187 ::testing::Values("id_or_ter"),
188 ::testing::Values("no"),
189 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"),
190 ::testing::Values(efGRO
))
195 INSTANTIATE_TEST_CASE_P(ForCharmm27
, Pdb2gmxTest
,
197 (::testing::Values("charmm27"),
198 ::testing::Values("tip3p"),
199 ::testing::Values("none", "h"),
200 ::testing::Values("id_or_ter"),
201 ::testing::Values("no"),
202 ::testing::Values("fragment1.pdb", "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"),
203 ::testing::Values(efGRO
))
207 INSTANTIATE_TEST_CASE_P(ChainSep
, Pdb2gmxTest
,
209 (::testing::Values("charmm27"),
210 ::testing::Values("tip3p"),
211 ::testing::Values("none"),
212 ::testing::Values("id", "ter", "id_or_ter", "id_and_ter"),
213 ::testing::Values("all", "no"),
214 ::testing::Values("chainTer.pdb"),
215 ::testing::Values(efGRO
))
218 INSTANTIATE_TEST_CASE_P(ChainChanges
, Pdb2gmxTest
,
220 (::testing::Values("charmm27"),
221 ::testing::Values("tip3p"),
222 ::testing::Values("none"),
223 ::testing::Values("id", "ter", "id_or_ter", "id_and_ter"),
224 ::testing::Values("no"),
225 ::testing::Values("two-fragments.pdb"),
226 ::testing::Values(efPDB
))