fdee1f8a65c8712dd63cb058dcfbd62bcf11c010
[alexxy/gromacs-colorvec.git] / src / colorvec.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
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  * Implements gmx::analysismodules::Freevolume.
38  *
39  * \author Titov Anatoly <Wapuk-cobaka@yandex.ru>
40  * \ingroup module_trajectoryanalysis
41  */
42
43 #include <gromacs/trajectoryanalysis.h>
44 #include <gromacs/trajectoryanalysis/topologyinformation.h>
45 #include <gromacs/selection/nbsearch.h>
46
47 #include <iostream>
48 #include <fstream>
49 //#include <chrono>
50 #include <cfloat>
51 #include <omp.h>
52 #include <vector>
53 #include <cstdio>
54 #include <iomanip>
55
56 // структура углов для одной краски
57 struct colorLocalAngles {
58     gmx::RVec   a1, a2;
59     gmx::RVec   b1, b2;
60     gmx::RVec   n1, n2;
61     double      a12, b12, n12;
62     std::vector< double > betaAngles;
63 };
64
65 // хрен пойми почему, но захотелось рекурсивно сделать | можно сделать и через вайл
66 long long returnBetaEnd(const std::string &currentLine, long long pos) {
67     switch (currentLine[pos]) {
68         case 'B' :
69             returnBetaEnd(currentLine, pos + 1);
70             break;
71         case 'E' :
72             returnBetaEnd(currentLine, pos + 1);
73             break;
74         default :
75             return (pos - 1);
76             break;
77     }
78     return (pos - 1); // формально логически лишняя строчка, но Qt ругается
79 }
80
81 // функция парсинга одной строки
82 void parseBetaListDATLine(const std::string &currentLine, std::vector< std::vector< unsigned int > > &localInputBL) {
83     size_t                      equalCount = 0;
84     std::vector< unsigned int > a;
85     a.resize(0);
86     for (size_t i = 0; i < currentLine.size(); ++i) {
87         if (currentLine[i] == '=') { // подсчитываем число "пустых" символов
88             ++equalCount;
89         } else {
90             long long temp = returnBetaEnd(currentLine, i);
91             if (temp - static_cast< long long >(i) > 3) {
92                 localInputBL.push_back(a);
93                 for (size_t j = i; j <= temp; ++j) {
94                     localInputBL.back().push_back(j - equalCount);
95                 }
96                 i = temp;
97             }
98         }
99     }
100 }
101
102 // функция нахождения бета-листов в структуре по файлу ДССП
103 void betaListDigestion(const std::string &inputFile, std::vector< std::vector< std::vector< unsigned int > > > &inputBL) {
104     inputBL.resize(0);
105     std::ifstream   file(inputFile);
106     std::string     line;
107     getline(file, line); // считываем число в первой строке - кол-во осмысленных элементов в строках - нам не нужно
108     getline(file, line);
109     if (line.size() > 3) {
110         do {
111             inputBL.resize(inputBL.size() + 1);
112             parseBetaListDATLine(line, inputBL.back());
113             line = "";
114             getline(file, line);
115         } while (line.size() > 3);
116     } else {
117         throw "DSSP DAT FILE IS EMPTY";
118     }
119     file.close();
120 }
121
122 // функция выделения индексов для бэталистов
123 inline void aminoacidsIndexation(const std::vector< size_t > &inputIndex, const gmx::TopologyInformation &top, std::vector< std::vector< size_t > > &aminoacidsIndex) {
124     aminoacidsIndex.resize(0);
125     for (size_t i = 0; i < inputIndex.size(); ++i) {
126         aminoacidsIndex.resize(std::max(aminoacidsIndex.size(), static_cast< size_t >(top.atoms()->atom[inputIndex[i]].resind + 1)));
127         aminoacidsIndex[top.atoms()->atom[inputIndex[i]].resind].push_back(inputIndex[i]);
128     }
129 }
130
131 // функция поиска RVec в кадре по имени->индексу
132 gmx::RVec returnRVec(const std::vector< gmx::RVec > &frame, const std::vector< std::pair< std::string, size_t > > &colorsIndex, const std::string &toFind) {
133     for (auto &i : colorsIndex) {
134         if (i.first == toFind) {
135             return frame[i.second];
136         }
137     }
138     throw "WRONG COLOR ATOM NAME TO EVALUATE VECTORS";
139 }
140
141 // функция векторного произведения двух RVec'ов
142 inline void RVecVecMultiply(gmx::RVec &n, const gmx::RVec &a, const gmx::RVec &b) {
143     n[0] = a[1] * b[2] - a[2] * b[1];
144     n[1] = a[2] * b[0] - a[0] * b[2];
145     n[2] = a[0] * b[1] - a[2] * b[0];
146 }
147
148 // поиск угла между двумя RVec'ами
149 inline double RVecAngle(const gmx::RVec &a, const gmx::RVec &b) {
150     return std::acos((a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) / (a.norm() * b.norm()));
151 }
152
153 // вычисление внутренних углов в краске
154 void colorsAnglesEvaluation(const std::vector< gmx::RVec > &frame, const std::vector< std::vector< std::pair< std::string, size_t > > > &colorsIndex,
155                             std::vector< colorLocalAngles > &colorStruct) {
156     colorStruct.resize(colorsIndex.size());
157     #pragma omp parallel for ordered schedule(dynamic)
158     for (size_t i = 0; i < colorsIndex.size(); ++i) {
159         colorStruct[i].betaAngles.resize(0);
160         // "левый" блок
161         colorStruct[i].a1 = returnRVec(frame, colorsIndex[i], "CAF") - returnRVec(frame, colorsIndex[i], "CAJ") + returnRVec(frame, colorsIndex[i], "CAK") - returnRVec(frame, colorsIndex[i], "CAO");
162         colorStruct[i].a1 /= colorStruct[i].a1.norm();
163         colorStruct[i].b1 = returnRVec(frame, colorsIndex[i], "CAO") - returnRVec(frame, colorsIndex[i], "CAJ") + returnRVec(frame, colorsIndex[i], "CAM") - returnRVec(frame, colorsIndex[i], "CAH") + returnRVec(frame, colorsIndex[i], "CAK") - returnRVec(frame, colorsIndex[i], "CAF");
164         colorStruct[i].b1 /= colorStruct[i].b1.norm();
165         RVecVecMultiply(colorStruct[i].n1, colorStruct[i].a1, colorStruct[i].b1);
166         colorStruct[i].n1 /= colorStruct[i].n1.norm();
167         // "правый" блок
168         colorStruct[i].a2 = returnRVec(frame, colorsIndex[i], "CAB") - returnRVec(frame, colorsIndex[i], "CBQ") + returnRVec(frame, colorsIndex[i], "CBP") - returnRVec(frame, colorsIndex[i], "CBL");
169         colorStruct[i].a2 /= colorStruct[i].a2.norm();
170         colorStruct[i].b2 = returnRVec(frame, colorsIndex[i], "CBL") - returnRVec(frame, colorsIndex[i], "CBQ") + returnRVec(frame, colorsIndex[i], "CBN") - returnRVec(frame, colorsIndex[i], "CBS") + returnRVec(frame, colorsIndex[i], "CBP") - returnRVec(frame, colorsIndex[i], "CAB");
171         colorStruct[i].b2 /= colorStruct[i].b2.norm();
172         RVecVecMultiply(colorStruct[i].n2, colorStruct[i].a2, colorStruct[i].b2);
173         colorStruct[i].n2 *= -1; // для "сонаправленности" векторов нормали
174         colorStruct[i].n2 /= colorStruct[i].n2.norm();
175         colorStruct[i].a12 = RVecAngle(colorStruct[i].a1, colorStruct[i].a2);
176         colorStruct[i].b12 = RVecAngle(colorStruct[i].b1, colorStruct[i].b2);
177         colorStruct[i].n12 = RVecAngle(colorStruct[i].n1, colorStruct[i].n2);
178     }
179     #pragma omp barrier
180 }
181
182 // вычисление направляющего вектора в бэта-листе
183 inline void betaListsRVecsEvaluation(const std::vector< gmx::RVec > &frame, const std::vector< std::vector< unsigned int > > &inputBetaLists,
184                                      std::vector< gmx::RVec > &temp, const std::vector< size_t > &inputCA) {
185     temp.resize(0);
186     gmx::RVec tempA;
187     for (const auto &i : inputBetaLists) {
188         tempA = frame[inputCA[i[i.size() - 1]]] + frame[inputCA[i[i.size() - 2]]] - frame[inputCA[i[1]]] - frame[inputCA[i[0]]];
189         tempA /= tempA.norm();
190         temp.push_back(tempA);
191     }
192 }
193
194 //// определение близко ли к белку находится краска
195 //bool isNearPeptide(const t_trxframe &fr, const t_pbc *pbc, const std::vector< gmx::RVec > &inputFrame,
196 //                          /*gmx::AnalysisNeighborhood &nbhood, */const std::vector< size_t > &inputIndex,
197 //                          const std::vector< std::pair< std::string, size_t > > &inputColor) {
198 //    /*gmx::AnalysisNeighborhoodSearch     nbsearch = nbhood.initSearch(pbc, gmx::AnalysisNeighborhoodPositions(fr.x, fr.natoms));
199 //    gmx::AnalysisNeighborhoodPair       pair;*/
200
201 //    for (size_t i = 0; i < inputColor.size(); ++i) {
202 //        std::cout << inputColor[i].first << " " << i << " / "  << inputColor.size() << std::endl;
203 //        gmx::AnalysisNeighborhood           nbhood;
204 //        nbhood.setCutoff(0.8);
205 //        gmx::AnalysisNeighborhoodSearch     nbsearch = nbhood.initSearch(pbc, gmx::AnalysisNeighborhoodPositions(fr.x, fr.natoms));
206 //        gmx::AnalysisNeighborhoodPair       pair;
207 //        gmx::AnalysisNeighborhoodPairSearch pairSearch = nbsearch.startPairSearch(inputFrame[inputColor[i].second].as_vec());
208 //        int count1 {0};
209 //        while (pairSearch.findNextPair(&pair)) {
210 //            std::cout << ++count1 << " ";
211 //            for (size_t j = 0; j < inputIndex.size(); ++j) {
212 //                if (pair.refIndex() == inputIndex[j]) {
213 //                    return true;
214 //                }
215 //            }
216 //        }
217 //        std::cout << inputColor[i].first << " atom done" << std::endl;
218 //    }
219 //    return false;
220 //}
221
222 // определение близко ли к белку находится краска
223 bool isNearPeptide(const std::vector< gmx::RVec > &inputFrame, const std::vector< size_t > &inputIndex,
224                           const std::vector< std::pair< std::string, size_t > > &inputColor, const double cutOff) {
225     for (size_t i {0}; i < inputColor.size(); ++i) {
226         while (pairSearch.findNextPair(&pair)) {
227             for (size_t j {0}; j < inputIndex.size(); ++j) {
228                 if ((inputFrame[inputIndex[j]] - inputFrame[inputColor[i].second]).norm() <= cutOff) {
229                     return true;
230                 }
231             }
232         }
233     }
234     return false;
235 }
236
237 // поиск ближайших к краске бэта-листов
238 inline void searchNearBetaLists(const t_trxframe &fr, const t_pbc *pbc, const std::vector< gmx::RVec > &inputFrame,
239                                 gmx::AnalysisNeighborhood &nbhood,
240                                 const std::vector< std::vector< unsigned int > > &inputBLists,
241                                 const std::vector< std::pair< std::string, size_t > > &inputColor,
242                                 std::vector< bool > &outputList, const std::vector< std::vector< size_t > > &inputAminoacids) {
243     outputList.resize(0);
244     outputList.resize(inputBLists.size(), false);
245     gmx::AnalysisNeighborhoodSearch      nbsearch = nbhood.initSearch(pbc, gmx::AnalysisNeighborhoodPositions(fr.x, fr.natoms));
246     gmx::AnalysisNeighborhoodPair        pair;
247     for (const auto &i : inputColor) {
248         while (nbsearch.startPairSearch(inputFrame[i.second].as_vec()).findNextPair(&pair)) {
249             for (size_t j = 0; j < inputBLists.size(); ++j) {
250                 for (size_t k = 0; k < inputBLists[j].size(); ++k) {
251                     for (size_t m = 0; m < inputAminoacids[inputBLists[j][k]].size(); ++m) {
252                         if (pair.testIndex() == inputAminoacids[inputBLists[j][k]][m]) {
253                             outputList[j] = true;
254                         }
255                     }
256                 }
257             }
258         }
259     }
260 }
261
262 // определение углов между краской и направляющим вектором бэта-листа
263 inline void computeAnglesColorsVsBeta(const gmx::RVec &inputBetaRVec, colorLocalAngles &colorFormation) {
264     colorFormation.betaAngles.push_back(RVecAngle(inputBetaRVec, colorFormation.a1));
265     colorFormation.betaAngles.push_back(RVecAngle(inputBetaRVec, colorFormation.b1));
266     colorFormation.betaAngles.push_back(RVecAngle(inputBetaRVec, colorFormation.n1));
267     colorFormation.betaAngles.push_back(RVecAngle(inputBetaRVec, colorFormation.a2));
268     colorFormation.betaAngles.push_back(RVecAngle(inputBetaRVec, colorFormation.b2));
269     colorFormation.betaAngles.push_back(RVecAngle(inputBetaRVec, colorFormation.n2));
270 }
271
272 // функция записи в файл значений углов для кадра
273 void anglesFileDump(const int frameNum, const std::string &output, const std::vector< bool > &toPeptide, const std::vector< colorLocalAngles > &colorFormation) {
274     std::ofstream   file(output);
275     int temp = 0;
276     std::vector< double > betaTemp;
277     betaTemp.resize(0);
278     file << "frame =" << std::setw(8) << frameNum << std::endl;
279     for (size_t i = 0; i < colorFormation.size(); ++i) {
280         file << "color #" << std::setw(3) << i;
281         if (toPeptide[i]) {
282             file << std::setw(4) << "yes";
283         } else {
284             file << std::setw(4) << "no";
285         }
286         file << std::setw(7) << std::setprecision(2) << colorFormation[i].a12 << colorFormation[i].b12 << colorFormation[i].n12;
287         temp = colorFormation[i].betaAngles.size() / 6;
288         if (temp == 0) {
289             file << std::setw(4) << 0;
290         } else {
291             betaTemp.resize(6, 0.); // magic number, meh
292             for (size_t j = 0; j < colorFormation[i].betaAngles.size(); ++j) {
293                 betaTemp[j % 6] += colorFormation[i].betaAngles[j];
294             }
295             for (size_t j = 0; j < betaTemp.size(); ++j) {
296                 betaTemp[j] /= temp;
297             }
298             file << std::setw(4) << temp;
299             for (size_t j = 0; j < betaTemp.size(); ++j) {
300                 file << std::setw(7) << std::setprecision(2) << betaTemp[j];
301             }
302             for (size_t j = 0; j < colorFormation[i].betaAngles.size(); ++j) {
303                 file << std::setw(7) << std::setprecision(2) << colorFormation[i].betaAngles[j];
304             }
305         }
306     }
307     file.close();
308 }
309
310 /*! \brief
311  * \ingroup module_trajectoryanalysis
312  */
313 class colorVec : public gmx::TrajectoryAnalysisModule
314 {
315     public:
316
317         colorVec();
318         virtual ~colorVec();
319
320         //! Set the options and setting
321         virtual void initOptions(gmx::IOptionsContainer          *options,
322                                  gmx::TrajectoryAnalysisSettings *settings);
323
324         //! First routine called by the analysis framework
325         // virtual void initAnalysis(const t_trxframe &fr, t_pbc *pbc);
326         virtual void initAnalysis(const gmx::TrajectoryAnalysisSettings &settings,
327                                   const gmx::TopologyInformation        &top);
328
329         //! Call for each frame of the trajectory
330         // virtual void analyzeFrame(const t_trxframe &fr, t_pbc *pbc);
331         virtual void analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
332                                   gmx::TrajectoryAnalysisModuleData *pdata);
333
334         //! Last routine called by the analysis framework
335         // virtual void finishAnalysis(t_pbc *pbc);
336         virtual void finishAnalysis(int nframes);
337
338         //! Routine to write output, that is additional over the built-in
339         virtual void writeOutput();
340
341     private:
342
343         gmx::SelectionList                                              sel_;
344         std::string                                                     fnOut           {"name"};   // selectable
345         std::string                                                     fnBetaListsDat;             // selectable
346         float                                                           effRad          {0.8};      // selectable
347         std::vector< size_t >                                           index;
348         std::vector< size_t >                                           indexCA;
349         std::vector< std::vector< size_t > >                            aminoacidsIndex;
350         std::vector< std::vector< std::pair< std::string, size_t > > >  colorsNames;
351         std::vector< std::vector< std::vector< unsigned int > > >       betaLists;
352         gmx::AnalysisNeighborhood                                       nb_;
353
354         // Copy and assign disallowed by base.
355 };
356
357 colorVec::colorVec(): TrajectoryAnalysisModule()
358 {
359 }
360
361 colorVec::~colorVec()
362 {
363 }
364
365 /*
366  * ndx:
367  * [peptide]
368  * [CA]
369  * [color_{i}]
370  *
371  */
372
373 void
374 colorVec::initOptions(  gmx::IOptionsContainer          *options,
375                         gmx::TrajectoryAnalysisSettings *settings)
376 {
377     static const char *const desc[] = {
378         "[THISMODULE] to be done"
379     };
380     // Add the descriptive text (program help text) to the options
381     settings->setHelpText(desc);
382     // Add option for selection list
383     options->addOption(gmx::SelectionOption("sel")
384                             .storeVector(&sel_)
385                             .required().dynamicMask().multiValue()
386                             .description("select pepride and colors / -sf"));
387     // Add option for input file names
388     options->addOption(gmx::StringOption("dat")
389                             .store(&fnBetaListsDat)
390                             .description("a file to make dynamic beta lists"));
391     // Add option for output file name
392     options->addOption(gmx::StringOption("out")
393                             .store(&fnOut)
394                             .description("Index file for the algorithm output."));
395     // Add option for effRad constant
396     options->addOption(gmx::FloatOption("efRad")
397                             .store(&effRad)
398                             .description("max distance from colors to peptide in nm to consider to be \"near\""));
399     // Control input settings
400     settings->setFlags(gmx::TrajectoryAnalysisSettings::efNoUserPBC);
401     settings->setFlag(gmx::TrajectoryAnalysisSettings::efUseTopX);
402     //settings->setFlag(TrajectoryAnalysisSettings::efRequireTop);
403     settings->setPBC(true);
404 }
405
406 void
407 colorVec::initAnalysis( const gmx::TrajectoryAnalysisSettings   &settings,
408                         const gmx::TopologyInformation          &top)
409 {
410     // считывание индекса
411     index.resize(0);
412     for (gmx::ArrayRef< const int >::iterator ai {sel_.front().atomIndices().begin()}; (ai < sel_.front().atomIndices().end()); ai++) {
413         index.push_back(static_cast< size_t >(*ai));
414     }
415     // считывание индекса
416     indexCA.resize(0);
417     for (gmx::ArrayRef< const int >::iterator ai {sel_[1].atomIndices().begin()}; (ai < sel_[2].atomIndices().end()); ai++) {
418         index.push_back(static_cast< size_t >(*ai));
419     }
420     // считывание красок
421     colorsNames.resize(sel_.size() - 2);
422     for (size_t i = 2; i < sel_.size(); ++i) {
423         for (gmx::ArrayRef< const int >::iterator ai {sel_[i].atomIndices().begin()}; (ai < sel_[i].atomIndices().end()); ai++) {
424             colorsNames[i - 2].push_back(std::make_pair(*(top.atoms()->atomname[*ai]), static_cast< size_t >(*ai)));
425         }
426     }
427     // разбор dat файла для создания бэта листов
428     betaListDigestion(fnBetaListsDat, betaLists);
429     // разбор топологии для индексации бета листов
430     aminoacidsIndexation(index, top, aminoacidsIndex);
431     // задание радиуса рассматриваемых соседей
432     nb_.setCutoff(effRad);
433     /*
434      * формально можно сделать:
435      * найти соотношение между именами для углов и индексными номерами
436      * заполнить std::vector< std::vector< size_t > > nameToIndex;
437      * и в последствии считать:
438      * a1 = frame[nameToIndex[0][1] + ... - ... - ...
439      * b1 a2 b2 по аналогии только для [@<-[1, 2, 3]]
440      *
441      */
442 }
443
444 void
445 colorVec::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc, gmx::TrajectoryAnalysisModuleData *pdata)
446 {
447     std::cout << "\tFrame analisis start ..." << std::endl;
448     std::vector< gmx::RVec > trajectoryFrame;
449     trajectoryFrame.resize(0);
450     // считывания текущего фрейма траектории
451     for (size_t i {0}; i < index.size(); ++i) {
452         trajectoryFrame.push_back(fr.x[index[i]]);
453     }
454     // подсчёт углов в красках
455     std::vector< colorLocalAngles > colorFormation;
456     std::cout << "\t\tColors' angles evaluation." << std::endl;
457     colorsAnglesEvaluation(trajectoryFrame, colorsNames, colorFormation);
458     // рассчёт положения относительно белка
459     /*
460      * формально можно совместить определение близости с белком и определение ближайших бэта-листов
461      * для этого думаю нужно как-то соотнести или сделать соотношение между индексом и бэта-листами (т.е. хранить что бы за О(1) делать)
462      *
463      */
464
465     std::vector< bool >     colorsToPeptide;
466     colorsToPeptide.resize(0);
467     colorsToPeptide.resize(colorsNames.size(), false);
468     std::cout << "\t\tWhich colors are \"near\" the pepride mass." << std::endl;
469     for (size_t i = 0; i < colorsNames.size(); ++i) {
470         colorsToPeptide[i] = isNearPeptide(fr, pbc, trajectoryFrame, /*nb_, */index, colorsNames[i]);
471     }
472     // расчёт угла и среднего угла с ближайшими бета листами
473     std::vector< std::vector< bool > > colorsToBeta;
474     colorsToBeta.resize(0);
475     colorsToBeta.resize(colorsNames.size());
476     std::vector< std::vector< double > > colorsToBetaAngles;
477     colorsToBetaAngles.resize(0);
478     std::vector< gmx::RVec > betaListsRVecs;
479     std::cout << "\t\tBeta-lists' RVecs search." << std::endl;
480     betaListsRVecsEvaluation(trajectoryFrame, betaLists[frnr], betaListsRVecs, indexCA);
481     std::cout << "\t\tSearching nearby beta-lists." << std::endl;
482     for (size_t i = 0; i < colorsToPeptide.size(); ++i) {
483         if (colorsToPeptide[i]) {
484             searchNearBetaLists(fr, pbc, trajectoryFrame, nb_, betaLists[frnr], colorsNames[i], colorsToBeta[i], aminoacidsIndex);
485         }
486     }
487     std::cout << "\t\tComputing angles colors vs betas." << std::endl;
488     for (size_t i = 0; i < colorsToBeta.size(); ++i) {
489         for (size_t j = 0; j < colorsToBeta[i].size(); ++j) {
490             if (colorsToBeta[i][j]) {
491                 computeAnglesColorsVsBeta(betaListsRVecs[j], colorFormation[i]);
492             }
493         }
494     }
495     // вывод в файл(ы) информацию для фрейма
496     std::cout << "\t\tDumping data." << std::endl;
497     anglesFileDump(frnr, fnOut, colorsToPeptide, colorFormation);
498     std::cout << "\tFrame analysed." << std::endl;
499 }
500
501 void
502 colorVec::finishAnalysis(int nframes)
503 {
504
505 }
506
507 void
508 colorVec::writeOutput()
509 {
510     /*
511      *
512      * frame #<current frame number>
513      * color #<color number> <yes/no for "close" to peptide> a12 b12 n12 <number of beta lists> <6 avg beta angles> [<6 angles for each beta list>]
514      *
515      */
516     std::cout << "\n\t colorAngles finished successfully" << std::endl;
517 }
518
519 /*! \brief
520  * The main function for the analysis template.
521  */
522 int
523 main(int argc, char *argv[])
524 {
525     return gmx::TrajectoryAnalysisCommandLineRunner::runAsMain<colorVec>(argc, argv);
526 }