2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,2019,2020, 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.
37 * Tests for functionality of the "pairdist" trajectory analysis module.
39 * These tests test the basic functionality of the tool itself, but currently
40 * the following are missing:
41 * - Tests related to -odg output. This would require a full tpr file, and
42 * some investigation on what kind of tpr it should be to produce reasonable
44 * - Tests for the X axes in the area per atom/residue plots. These could be
45 * added once better X axes are implemented.
46 * - Tests for XVG labels. This is a limitation of the current testing
49 * \author Teemu Murtola <teemu.murtola@gmail.com>
50 * \ingroup module_trajectoryanalysis
54 #include "gromacs/trajectoryanalysis/modules/pairdist.h"
56 #include <gtest/gtest.h>
58 #include "testutils/cmdlinetest.h"
59 #include "testutils/testasserts.h"
60 #include "testutils/textblockmatchers.h"
62 #include "moduletest.h"
67 using gmx::test::CommandLine
;
68 using gmx::test::NoTextMatch
;
70 /********************************************************************
71 * Tests for gmx::analysismodules::PairDistance.
74 //! Test fixture for the select analysis module.
75 typedef gmx::test::TrajectoryAnalysisModuleTestFixture
<gmx::analysismodules::PairDistanceInfo
> PairDistanceModuleTest
;
77 TEST_F(PairDistanceModuleTest
, ComputesAllDistances
)
79 const char* const cmdline
[] = { "pairdist", "-ref", "resindex 1",
80 "-refgrouping", "none", "-sel",
81 "resindex 3", "-selgrouping", "none" };
82 setTopology("simple.gro");
83 setOutputFile("-o", ".xvg", NoTextMatch());
84 runTest(CommandLine(cmdline
));
87 TEST_F(PairDistanceModuleTest
, ComputesAllDistancesWithCutoff
)
89 const char* const cmdline
[] = { "pairdist", "-ref", "resindex 1", "-refgrouping",
90 "none", "-sel", "resindex 3", "-selgrouping",
91 "none", "-cutoff", "1.5" };
92 setTopology("simple.gro");
93 setOutputFile("-o", ".xvg", NoTextMatch());
94 runTest(CommandLine(cmdline
));
97 TEST_F(PairDistanceModuleTest
, ComputesMinDistanceWithCutoff
)
99 const char* const cmdline
[] = { "pairdist", "-ref", "resindex 1", "-sel",
100 "resindex 3", "-cutoff", "1.5" };
101 setTopology("simple.gro");
102 setOutputFile("-o", ".xvg", NoTextMatch());
103 runTest(CommandLine(cmdline
));
106 TEST_F(PairDistanceModuleTest
, ComputesMaxDistance
)
108 const char* const cmdline
[] = { "pairdist", "-ref", "resindex 1", "-sel",
109 "resindex 3", "-type", "max" };
110 setTopology("simple.gro");
111 setOutputFile("-o", ".xvg", NoTextMatch());
112 runTest(CommandLine(cmdline
));
115 TEST_F(PairDistanceModuleTest
, ComputesMaxDistanceWithCutoff
)
117 const char* const cmdline
[] = { "pairdist", "-ref", "resindex 1", "-sel", "resindex 3",
118 "-cutoff", "1.5", "-type", "max" };
119 setTopology("simple.gro");
120 setOutputFile("-o", ".xvg", NoTextMatch());
121 runTest(CommandLine(cmdline
));
124 TEST_F(PairDistanceModuleTest
, ComputesGroupedMinDistanceWithCutoff
)
126 const char* const cmdline
[] = { "pairdist", "-ref", "resindex 1 to 2",
127 "-refgrouping", "res", "-sel",
128 "resindex 3 to 5", "-selgrouping", "res",
130 setTopology("simple.gro");
131 setOutputFile("-o", ".xvg", NoTextMatch());
132 runTest(CommandLine(cmdline
));
135 TEST_F(PairDistanceModuleTest
, ComputesGroupedMaxDistanceWithCutoff
)
137 const char* const cmdline
[] = { "pairdist",
150 setTopology("simple.gro");
151 setOutputFile("-o", ".xvg", NoTextMatch());
152 runTest(CommandLine(cmdline
));
155 TEST_F(PairDistanceModuleTest
, CoordinateSelectionIsNotOverwritten
)
157 const char* const cmdline
[] = { "pairdist", "-ref", "[0.0, 1.5, 2.9]", "-sel", "resindex 3",
159 setTopology("simple.gro");
160 setOutputFile("-o", ".xvg", NoTextMatch());
161 runTest(CommandLine(cmdline
));
164 TEST_F(PairDistanceModuleTest
, CoordinateSelectionIsNotOverwrittenWithExplicitGroup
)
166 const char* const cmdline
[] = { "pairdist", "-ref", "[0.0, 1.5, 2.9]", "-sel", "resindex 3",
167 "-type", "max", "-refgrouping", "res" };
168 setTopology("simple.gro");
169 setOutputFile("-o", ".xvg", NoTextMatch());
170 runTest(CommandLine(cmdline
));