Fix tune_pme
[gromacs.git] / src / gromacs / trajectoryanalysis / tests / sasa.cpp
blob742ba2a399cadd6819c270044877999510806aed
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015, 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.
35 /*! \internal \file
36 * \brief
37 * Tests for functionality of the "sasa" trajectory analysis module.
39 * These tests test the basic functionality of the tool itself, but currently
40 * the tests related to -odg output are missing. This would require a full tpr
41 * file, and some investigation on what kind of tpr it should be to produce
42 * reasonable output.
44 * The actual surface area algorithm is tested separately in surfacearea.cpp.
46 * \author Teemu Murtola <teemu.murtola@gmail.com>
47 * \ingroup module_trajectoryanalysis
49 #include "gmxpre.h"
51 #include "gromacs/trajectoryanalysis/modules/sasa.h"
53 #include <gtest/gtest.h>
55 #include "testutils/cmdlinetest.h"
56 #include "testutils/testasserts.h"
57 #include "testutils/textblockmatchers.h"
58 #include "testutils/xvgtest.h"
60 #include "moduletest.h"
62 namespace
65 using gmx::test::CommandLine;
66 using gmx::test::ExactTextMatch;
67 using gmx::test::NoTextMatch;
68 using gmx::test::XvgMatch;
70 /********************************************************************
71 * Tests for gmx::analysismodules::Sasa.
74 //! Test fixture for the `sasa` analysis module.
75 typedef gmx::test::TrajectoryAnalysisModuleTestFixture<gmx::analysismodules::SasaInfo>
76 SasaModuleTest;
78 TEST_F(SasaModuleTest, BasicTest)
80 const char *const cmdline[] = {
81 "sasa",
82 "-surface", "all",
83 "-output", "name N CA C O H"
85 setTopology("lysozyme.gro");
86 setOutputFile("-o", ".xvg", XvgMatch().testData(false));
87 setOutputFile("-or", ".xvg", XvgMatch());
88 setOutputFile("-oa", ".xvg", XvgMatch());
89 setOutputFile("-tv", ".xvg", XvgMatch().testData(false));
90 excludeDataset("dgsolv");
91 setDatasetTolerance("area", gmx::test::ulpTolerance(8));
92 setDatasetTolerance("volume", gmx::test::ulpTolerance(8));
93 runTest(CommandLine(cmdline));
96 TEST_F(SasaModuleTest, HandlesSelectedResidues)
98 const char *const cmdline[] = {
99 "sasa",
100 "-surface", "resnr 2 4 to 5 8"
102 setTopology("lysozyme.gro");
103 setOutputFile("-o", ".xvg", XvgMatch().testData(false));
104 setOutputFile("-or", ".xvg", XvgMatch());
105 setOutputFile("-oa", ".xvg", XvgMatch());
106 excludeDataset("dgsolv");
107 excludeDataset("volume");
108 setDatasetTolerance("area", gmx::test::ulpTolerance(8));
109 runTest(CommandLine(cmdline));
112 TEST_F(SasaModuleTest, WritesConnollySurfaceWithSolute)
114 const char *const cmdline[] = {
115 "sasa",
116 "-surface", "atomnr 1"
118 setTopology("lysozyme.gro");
119 setOutputFile("-o", ".xvg", NoTextMatch());
120 setOutputFile("-q", "connolly.pdb", ExactTextMatch());
121 includeDataset("area");
122 runTest(CommandLine(cmdline));
125 // The CONECT records written to the output make this very difficult to test
126 // without parsing the output file, since by construction, there are a lot of
127 // dot pairs that are at exactly the same distance from each other in exact
128 // arithmetic, and depending on rounding etc., different pairs get picked into
129 // the output for single and double precision.
130 #if 0
131 TEST_F(SasaModuleTest, WritesConnollySurfaceWithoutSolute)
133 const char *const cmdline[] = {
134 "sasa",
135 "-surface", "atomnr 1",
136 "-noprot"
138 setTopology("lysozyme.gro");
139 setOutputFileNoTest("-o", "xvg");
140 setOutputFile("-q", "connolly.pdb");
141 includeDataset("area");
142 runTest(CommandLine(cmdline));
144 #endif
146 TEST_F(SasaModuleTest, HandlesDynamicOutputGroup)
148 const char *const cmdline[] = {
149 "sasa",
150 "-surface", "all",
151 "-output", "y > 1.5"
153 setTopology("lysozyme.gro");
154 setOutputFile("-o", ".xvg", NoTextMatch());
155 setOutputFile("-or", ".xvg", NoTextMatch());
156 setOutputFile("-oa", ".xvg", NoTextMatch());
157 excludeDataset("volume");
158 excludeDataset("dgsolv");
159 setDatasetTolerance("area", gmx::test::ulpTolerance(8));
160 runTest(CommandLine(cmdline));
163 TEST_F(SasaModuleTest, HandlesDynamicCalculationGroup)
165 const char *const cmdline[] = {
166 "sasa",
167 "-surface", "y > 1.5",
168 "-output", "y > 1.5 and z > 0"
170 setTopology("lysozyme.gro");
171 setOutputFile("-o", ".xvg", NoTextMatch());
172 setOutputFile("-or", ".xvg", NoTextMatch());
173 setOutputFile("-oa", ".xvg", NoTextMatch());
174 excludeDataset("volume");
175 excludeDataset("dgsolv");
176 setDatasetTolerance("area", gmx::test::ulpTolerance(8));
177 runTest(CommandLine(cmdline));
180 } // namespace