3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
33 * Tests for functionality of the "select" trajectory analysis module.
35 * These tests test most of the functionality of the module, but currently
37 * - Tests related to -oc output. This would require a more complex input
38 * structure for reasonable testing (the same structure could also be used
39 * in selection unit tests for 'insolidangle' keyword).
40 * - Tests for XVG labels. This is a limitation of the current testing
43 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
44 * \ingroup module_trajectoryanalysis
46 #include <gtest/gtest.h>
48 #include "gromacs/trajectoryanalysis/modules/select.h"
50 #include "testutils/cmdlinetest.h"
52 #include "moduletest.h"
57 using gmx::test::CommandLine;
59 /********************************************************************
60 * Tests for gmx::analysismodules::Select.
63 //! Test fixture for the select analysis module.
64 typedef gmx::test::TrajectoryAnalysisModuleTestFixture<gmx::analysismodules::Select>
67 TEST_F(SelectModuleTest, BasicTest)
69 const char *const cmdline[] = {
71 "-select", "y < 2.5", "resname RA"
73 setTopology("simple.gro");
74 setTrajectory("simple.gro");
75 setOutputFile("-oi", "index.dat");
76 setOutputFile("-on", "index.ndx");
77 excludeDataset("cfrac");
78 runTest(CommandLine::create(cmdline));
81 TEST_F(SelectModuleTest, HandlesPDBOutputWithNonPDBInput)
83 const char *const cmdline[] = {
85 "-select", "resname RA RD and y < 2.5"
87 setTopology("simple.gro");
88 setTrajectory("simple.gro");
89 includeDataset("occupancy");
90 setOutputFile("-ofpdb", "occupancy.pdb");
91 runTest(CommandLine::create(cmdline));
94 TEST_F(SelectModuleTest, HandlesPDBOutputWithPDBInput)
96 const char *const cmdline[] = {
98 "-select", "resname RA RD and y < 2.5"
100 setTopology("simple.pdb");
101 setTrajectory("simple.gro");
102 includeDataset("occupancy");
103 setOutputFile("-ofpdb", "occupancy.pdb");
104 runTest(CommandLine::create(cmdline));
107 TEST_F(SelectModuleTest, HandlesMaxPDBOutput)
109 const char *const cmdline[] = {
111 "-select", "resname RA RD and y < 2.5",
112 "-pdbatoms", "maxsel"
114 setTopology("simple.pdb");
115 setTrajectory("simple.gro");
116 includeDataset("occupancy");
117 setOutputFile("-ofpdb", "occupancy.pdb");
118 runTest(CommandLine::create(cmdline));
121 TEST_F(SelectModuleTest, HandlesSelectedPDBOutput)
123 const char *const cmdline[] = {
125 "-select", "resname RA RD and y < 2.5",
126 "-pdbatoms", "selected"
128 setTopology("simple.pdb");
129 setTrajectory("simple.gro");
130 includeDataset("occupancy");
131 setOutputFile("-ofpdb", "occupancy.pdb");
132 runTest(CommandLine::create(cmdline));
135 TEST_F(SelectModuleTest, HandlesDumpOption)
137 const char *const cmdline[] = {
139 "-select", "y < 2.5",
142 setTopology("simple.gro");
143 setOutputFile("-oi", "index.dat");
144 includeDataset("index");
145 runTest(CommandLine::create(cmdline));
148 TEST_F(SelectModuleTest, NormalizesSizes)
150 const char *const cmdline[] = {
152 "-select", "y < 2.5", "resname RA and y < 2.5", "resname RA",
155 setTopology("simple.gro");
156 includeDataset("size");
157 runTest(CommandLine::create(cmdline));
160 TEST_F(SelectModuleTest, WritesResidueNumbers)
162 const char *const cmdline[] = {
164 "-select", "res_com of resname RA RD"
166 setTopology("simple.gro");
167 includeDataset("index");
168 runTest(CommandLine::create(cmdline));
171 TEST_F(SelectModuleTest, WritesResidueIndices)
173 const char *const cmdline[] = {
175 "-select", "res_com of resname RA RD",
178 setTopology("simple.gro");
179 includeDataset("index");
180 runTest(CommandLine::create(cmdline));