2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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 "select" trajectory analysis module.
39 * These tests test most of the functionality of the module, but currently
41 * - Tests related to -oc output. This would require a more complex input
42 * structure for reasonable testing (the same structure could also be used
43 * in selection unit tests for 'insolidangle' keyword).
44 * - Tests for XVG labels. This is a limitation of the current testing
47 * \author Teemu Murtola <teemu.murtola@gmail.com>
48 * \ingroup module_trajectoryanalysis
52 #include <gtest/gtest.h>
54 #include "gromacs/trajectoryanalysis/modules/select.h"
56 #include "testutils/cmdlinetest.h"
58 #include "moduletest.h"
63 using gmx::test::CommandLine;
65 /********************************************************************
66 * Tests for gmx::analysismodules::Select.
69 //! Test fixture for the select analysis module.
70 typedef gmx::test::TrajectoryAnalysisModuleTestFixture<gmx::analysismodules::SelectInfo>
73 TEST_F(SelectModuleTest, BasicTest)
75 const char *const cmdline[] = {
77 "-select", "y < 2.5", "resname RA"
79 setTopology("simple.gro");
80 setTrajectory("simple.gro");
81 setOutputFile("-oi", "index.dat");
82 setOutputFile("-on", "index.ndx");
83 excludeDataset("cfrac");
84 runTest(CommandLine(cmdline));
87 TEST_F(SelectModuleTest, HandlesPDBOutputWithNonPDBInput)
89 const char *const cmdline[] = {
91 "-select", "resname RA RD and y < 2.5"
93 setTopology("simple.gro");
94 setTrajectory("simple.gro");
95 includeDataset("occupancy");
96 setOutputFile("-ofpdb", "occupancy.pdb");
97 runTest(CommandLine(cmdline));
100 TEST_F(SelectModuleTest, HandlesPDBOutputWithPDBInput)
102 const char *const cmdline[] = {
104 "-select", "resname RA RD and y < 2.5"
106 setTopology("simple.pdb");
107 setTrajectory("simple.gro");
108 includeDataset("occupancy");
109 setOutputFile("-ofpdb", "occupancy.pdb");
110 runTest(CommandLine(cmdline));
113 TEST_F(SelectModuleTest, HandlesMaxPDBOutput)
115 const char *const cmdline[] = {
117 "-select", "resname RA RD and y < 2.5", "resname RA RB",
118 "-pdbatoms", "maxsel"
120 setTopology("simple.pdb");
121 setTrajectory("simple.gro");
122 includeDataset("occupancy");
123 setOutputFile("-ofpdb", "occupancy.pdb");
124 runTest(CommandLine(cmdline));
127 TEST_F(SelectModuleTest, HandlesSelectedPDBOutput)
129 const char *const cmdline[] = {
131 "-select", "resname RA RD and y < 2.5", "resname RA RB",
132 "-pdbatoms", "selected"
134 setTopology("simple.pdb");
135 setTrajectory("simple.gro");
136 includeDataset("occupancy");
137 setOutputFile("-ofpdb", "occupancy.pdb");
138 runTest(CommandLine(cmdline));
141 TEST_F(SelectModuleTest, NormalizesSizes)
143 const char *const cmdline[] = {
145 "-select", "y < 2.5", "resname RA and y < 2.5", "resname RA",
148 setTopology("simple.gro");
149 includeDataset("size");
150 runTest(CommandLine(cmdline));
153 TEST_F(SelectModuleTest, WritesResidueNumbers)
155 const char *const cmdline[] = {
157 "-select", "res_com of resname RA RD"
159 setTopology("simple.gro");
160 includeDataset("index");
161 runTest(CommandLine(cmdline));
164 TEST_F(SelectModuleTest, WritesResidueIndices)
166 const char *const cmdline[] = {
168 "-select", "res_com of resname RA RD",
171 setTopology("simple.gro");
172 includeDataset("index");
173 runTest(CommandLine(cmdline));