2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013,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.
37 * Implements gmx::analysismodules::Freevolume.
39 * \author Titov Anatoly <Wapuk-cobaka@yandex.ru>
40 * \ingroup module_trajectoryanalysis
47 #include <gromacs/trajectoryanalysis.h>
48 #include <gromacs/trajectoryanalysis/topologyinformation.h>
50 //#include "/home/titov_ai/Develop/gromacs-original/src/gromacs/trajectoryanalysis/topologyinformation.h"
60 * \ingroup module_trajectoryanalysis
63 class SpaceTimeCorr : public TrajectoryAnalysisModule
68 virtual ~SpaceTimeCorr();
70 //! Set the options and setting
71 virtual void initOptions(IOptionsContainer *options,
72 TrajectoryAnalysisSettings *settings);
74 //! First routine called by the analysis framework
75 // virtual void initAnalysis(const t_trxframe &fr, t_pbc *pbc);
76 virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
77 const TopologyInformation &top);
79 virtual void initAfterFirstFrame(const TrajectoryAnalysisSettings &settings,
80 const t_trxframe &fr);
82 //! Call for each frame of the trajectory
83 // virtual void analyzeFrame(const t_trxframe &fr, t_pbc *pbc);
84 virtual void analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
85 TrajectoryAnalysisModuleData *pdata);
87 //! Last routine called by the analysis framework
88 // virtual void finishAnalysis(t_pbc *pbc);
89 virtual void finishAnalysis(int nframes);
91 //! Routine to write output, that is additional over the built-in
92 virtual void writeOutput();
97 std::vector< RVec > trajectoryFrame;
99 std::vector< std::vector < std::vector < size_t > > > sels;
100 std::vector< int > index;
102 int tauJump {100}; // selectable
104 int window {1000}; // selectable
105 int tau {500}; // selectable
106 float crlBorder {0.5}; // selectable
107 float effRad {1.5}; // selectable
108 std::string outPutName; // selectable
109 // может лучше в виде enum?
110 int mode {1}; // selectable
112 correlationType corrs;
113 // Copy and assign disallowed by base.
116 SpaceTimeCorr::SpaceTimeCorr(): TrajectoryAnalysisModule()
120 SpaceTimeCorr::~SpaceTimeCorr()
125 SpaceTimeCorr::initOptions(IOptionsContainer *options,
126 TrajectoryAnalysisSettings *settings)
128 static const char *const desc[] = {
129 "[THISMODULE] to be done"
130 "-f trajectory.xtc -s structure.tpr -selRaDs residuePlusDomains.ndx -sf residuePlusDomains -mode 0/1 -tau 500 -window 1000 -crl 0.5 -efRad 1 -twStep 100 -outPut outputFilename"
132 // Add the descriptive text (program help text) to the options
133 settings->setHelpText(desc);
134 // Add option for output file name
135 //options->addOption(FileNameOption("on").filetype(eftIndex).outputFile()
136 // .store(&fnNdx_).defaultBasename("domains")
137 // .description("Index file from the domains"));
138 // Add option for working mode
139 options->addOption(gmx::IntegerOption("mode")
141 .description("default 0 - creation of sigle matrixes' file | 1 - reading prepared correlation file to make graphs and etc."));
142 // Add option for tau constant
143 options->addOption(gmx::IntegerOption("tau")
145 .description("max number of frames to shift to evaluate correlations | all starts from array [0 ; tau]"));
146 // Add option for window constant
147 options->addOption(gmx::IntegerOption("window")
149 .description("size of window in frames that correlation evaluation based on"));
150 // Add option for crl_border constant
151 options->addOption(FloatOption("crl")
153 .description("make graphs based on corrs > crl const"));
154 // Add option for effRad constant
155 options->addOption(FloatOption("efRad")
157 .description("effective radius for atoms to see each other to evaluate corrs"));
158 // Add option for selection list
159 options->addOption(SelectionOption("sel")
161 .required().dynamicMask().multiValue()
162 .description("select residue and domains to form a rigid skeleton"));
163 // Add option for output file names
164 options->addOption(StringOption("outPut")
166 .description("<your name here> + <local file tag>.txt"));
167 // Add option for time step between windows' starts
168 options->addOption(gmx::IntegerOption("twStep")
170 .description("time step between windows' starting positions."));
171 // Control input settings
172 settings->setFlags(TrajectoryAnalysisSettings::efNoUserPBC);
173 settings->setFlag(TrajectoryAnalysisSettings::efUseTopX);
174 settings->setPBC(true);
177 // -f trajectory.xtc -s structure.tpr -selRaDs residuePlusDomains.ndx -sf residuePlusDomains -mode 0/1 -tau 500 -window 1000 -crl 0.5 -efRad 1 -twStep 100 -outPut outputFilename
180 SpaceTimeCorr::initAnalysis(const TrajectoryAnalysisSettings &settings, const TopologyInformation &top)
182 std::cout << "initAnalysis - start\n";
183 std::vector< std::string > resNms;
184 std::vector< RVec > reference;
185 ArrayRef< const int > atomind {sel_.front().atomIndices()};
187 for (ArrayRef< const int >::iterator ai {atomind.begin()}; (ai < atomind.end()); ai++) {
188 index.push_back(*ai);
189 resNms.push_back(*(top.atoms()->resinfo[top.atoms()->atom[*ai].resind].name) + std::to_string((top.atoms()->atom[*ai].resind + 1)));
191 std::string str(sel_.back().name());
192 size_t tempSize {std::stoul(str.substr(13, 6)) / static_cast< size_t >(tauJump) + 1};
193 sels.resize(tempSize);
194 std::vector< size_t > a;
196 for (size_t i {1}; i < sel_.size(); i++) {
197 std::string str(sel_[i].name());
198 atomind = sel_[i].atomIndices();
199 sels[std::stoul(str.substr(13, 6)) / static_cast< size_t >(tauJump)].push_back(a);
200 for (ArrayRef< const int >::iterator ai {atomind.begin()}; (ai < atomind.end()); ai++) {
201 sels[std::stoul(str.substr(13, 6)) / static_cast< size_t >(tauJump)].back().push_back(static_cast< size_t >(*ai));
205 if (top.hasFullTopology()) {
206 for (const auto &i : index) {
207 reference.push_back(top.x().at(static_cast< size_t >(i)));
210 std::cout << "maybe ???\n";
211 corrs.setDefaults(reference, window, tau, tauJump, crlBorder, effRad, mode, outPutName, index, sels, resNms);
212 std::cout << "initAnalysis - finish\n";
216 SpaceTimeCorr::initAfterFirstFrame(const TrajectoryAnalysisSettings &settings, const t_trxframe &fr)
220 // -s *.tpr -f *.xtc -n *.ndx -sf 'name' -mode <> -tau <> -window <> -crl <> -ef_rad <> -out_put <>
223 SpaceTimeCorr::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc, TrajectoryAnalysisModuleData *pdata)
225 trajectoryFrame.resize(0);
226 trajectoryFrame.resize(index.size());
227 for (size_t i {0}; i < index.size(); i++) {
228 trajectoryFrame[i] = fr.x[index[i]];
230 corrs.update(frnr, trajectoryFrame);
231 std::cout << "\n\t\t" << frnr;
235 SpaceTimeCorr::finishAnalysis(int nframes)
237 std::vector< std::vector< std::vector< std::pair< size_t, size_t > > > > rout_new;
240 k = static_cast< size_t >(tau);
243 window = static_cast< int >(k * 2);
247 std::cout << "Finish Analysis - end\n\n";
251 SpaceTimeCorr::writeOutput()
257 * The main function for the analysis template.
260 main(int argc, char *argv[])
262 return gmx::TrajectoryAnalysisCommandLineRunner::runAsMain<SpaceTimeCorr>(argc, argv);