SYCL: Avoid using no_init read accessor in rocFFT
[alexxy/gromacs.git] / src / gromacs / trajectoryanalysis / tests / sasa.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2014,2015,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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 /*! \internal \file
36  * \brief
37  * Tests for functionality of the "sasa" trajectory analysis module.
38  *
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.
43  *
44  * The actual surface area algorithm is tested separately in surfacearea.cpp.
45  *
46  * \author Teemu Murtola <teemu.murtola@gmail.com>
47  * \ingroup module_trajectoryanalysis
48  */
49 #include "gmxpre.h"
50
51 #include "gromacs/trajectoryanalysis/modules/sasa.h"
52
53 #include <gtest/gtest.h>
54
55 #include "testutils/cmdlinetest.h"
56 #include "testutils/testasserts.h"
57 #include "testutils/textblockmatchers.h"
58 #include "testutils/xvgtest.h"
59
60 #include "moduletest.h"
61
62 namespace
63 {
64
65 using gmx::test::CommandLine;
66 using gmx::test::ExactTextMatch;
67 using gmx::test::NoTextMatch;
68 using gmx::test::XvgMatch;
69
70 /********************************************************************
71  * Tests for gmx::analysismodules::Sasa.
72  */
73
74 //! Test fixture for the `sasa` analysis module.
75 typedef gmx::test::TrajectoryAnalysisModuleTestFixture<gmx::analysismodules::SasaInfo> SasaModuleTest;
76
77 TEST_F(SasaModuleTest, BasicTest)
78 {
79     const char* const cmdline[] = { "sasa", "-surface", "all", "-output", "name N CA C O H" };
80     setTopology("lysozyme.gro");
81     setOutputFile("-o", ".xvg", XvgMatch().testData(false));
82     setOutputFile("-or", ".xvg", XvgMatch());
83     setOutputFile("-oa", ".xvg", XvgMatch());
84     setOutputFile("-tv", ".xvg", XvgMatch().testData(false));
85     excludeDataset("dgsolv");
86     setDatasetTolerance("area", gmx::test::ulpTolerance(8));
87     setDatasetTolerance("volume", gmx::test::ulpTolerance(8));
88     runTest(CommandLine(cmdline));
89 }
90
91 TEST_F(SasaModuleTest, HandlesSelectedResidues)
92 {
93     const char* const cmdline[] = { "sasa", "-surface", "resnr 2 4 to 5 8" };
94     setTopology("lysozyme.gro");
95     setOutputFile("-o", ".xvg", XvgMatch().testData(false));
96     setOutputFile("-or", ".xvg", XvgMatch());
97     setOutputFile("-oa", ".xvg", XvgMatch());
98     excludeDataset("dgsolv");
99     excludeDataset("volume");
100     setDatasetTolerance("area", gmx::test::ulpTolerance(8));
101     runTest(CommandLine(cmdline));
102 }
103
104 TEST_F(SasaModuleTest, WritesConnollySurfaceWithSolute)
105 {
106     const char* const cmdline[] = { "sasa", "-surface", "atomnr 1" };
107     setTopology("lysozyme.gro");
108     setOutputFile("-o", ".xvg", NoTextMatch());
109     setOutputFile("-q", "connolly.pdb", ExactTextMatch());
110     includeDataset("area");
111     runTest(CommandLine(cmdline));
112 }
113
114 // The CONECT records written to the output make this very difficult to test
115 // without parsing the output file, since by construction, there are a lot of
116 // dot pairs that are at exactly the same distance from each other in exact
117 // arithmetic, and depending on rounding etc., different pairs get picked into
118 // the output for single and double precision.
119 #if 0
120 TEST_F(SasaModuleTest, WritesConnollySurfaceWithoutSolute)
121 {
122     const char *const cmdline[] = {
123         "sasa",
124         "-surface", "atomnr 1",
125         "-noprot"
126     };
127     setTopology("lysozyme.gro");
128     setOutputFileNoTest("-o", "xvg");
129     setOutputFile("-q", "connolly.pdb");
130     includeDataset("area");
131     runTest(CommandLine(cmdline));
132 }
133 #endif
134
135 TEST_F(SasaModuleTest, HandlesDynamicOutputGroup)
136 {
137     const char* const cmdline[] = { "sasa", "-surface", "all", "-output", "y > 1.5" };
138     setTopology("lysozyme.gro");
139     setOutputFile("-o", ".xvg", NoTextMatch());
140     setOutputFile("-or", ".xvg", NoTextMatch());
141     setOutputFile("-oa", ".xvg", NoTextMatch());
142     excludeDataset("volume");
143     excludeDataset("dgsolv");
144     setDatasetTolerance("area", gmx::test::ulpTolerance(8));
145     runTest(CommandLine(cmdline));
146 }
147
148 TEST_F(SasaModuleTest, HandlesDynamicCalculationGroup)
149 {
150     const char* const cmdline[] = { "sasa", "-surface", "y > 1.5", "-output", "y > 1.5 and z > 0" };
151     setTopology("lysozyme.gro");
152     setOutputFile("-o", ".xvg", NoTextMatch());
153     setOutputFile("-or", ".xvg", NoTextMatch());
154     setOutputFile("-oa", ".xvg", NoTextMatch());
155     excludeDataset("volume");
156     excludeDataset("dgsolv");
157     setDatasetTolerance("area", gmx::test::ulpTolerance(8));
158     runTest(CommandLine(cmdline));
159 }
160
161 } // namespace