- added index into corrType as internal data
authorAnatoly <Titov_AI@pnpi.nrcki.ru>
Tue, 28 Jul 2020 12:23:31 +0000 (15:23 +0300)
committerAnatoly <Titov_AI@pnpi.nrcki.ru>
Tue, 28 Jul 2020 12:23:31 +0000 (15:23 +0300)
- fixed functions to accept index
- changed some names in main function to look better
- implemented test for setDefaults

src/corrtype.cpp
src/corrtype.h
src/spacetimecorr.cpp
src/spacetimecorrtests.cpp

index 1a6c3d41ce4c7077b28f7fb73c72061fd6389934..feafe11fc1d725ba5c9bd874281b9945bc14a925 100644 (file)
@@ -6,11 +6,11 @@ correlationType::~correlationType() {}
 // конструктор класса для инициализации
 correlationType::correlationType() {}
 
-correlationType::correlationType(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames) {
-    setDefaults(ref, wnd, taau, tau_st, crlUp, effRad, mod, out, sels, rsNames);
+correlationType::correlationType(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< int > indx, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames) {
+    setDefaults(ref, wnd, taau, tau_st, crlUp, effRad, mod, out, indx, sels, rsNames);
 }
 
-void correlationType::setDefaults(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames) {
+void correlationType::setDefaults(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< int > indx, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames) {
     if (ref.size() != 0) {reference = ref;}
     if (wnd != -1) {window = wnd;}
     if (taau != -1) {tau = taau;}
@@ -21,6 +21,7 @@ void correlationType::setDefaults(std::vector< RVec > ref, int wnd, int taau, in
     if (out != "") {outputName = out;}
     if (sels.size() != 0) {selections = sels;}
     if (rsNames.size() > 0) {resNames = rsNames;}
+    if (indx.size() > 0) {index = indx;}
     subGraphRouts.resize(0);
     trajectoryPartition();
 }
index 1a2f8123ee898d2ef169209d65a9630e400afa69..f3766f6f215ec50d0bf7144573867c414a2041e1 100644 (file)
@@ -29,9 +29,9 @@ class correlationType {
         // конструктор класса для инициализации
         correlationType();
 
-        correlationType(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames);
+        correlationType(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< int > indx, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames);
 
-        void setDefaults(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames);
+        void setDefaults(std::vector< RVec > ref, int wnd, int taau, int tau_st, float crlUp, float effRad, int mod, std::string out, std::vector< int > indx, std::vector< std::vector < std::vector < unsigned int > > > sels, std::vector< std::string > rsNames);
 
         void update(int frame, std::vector< RVec > curFrame);
 
index 0fb749fc4932ceb06986eba2f280761d0fc56779..8974eecf28148a68439596a9e9bbd245c04f0095 100644 (file)
@@ -101,13 +101,13 @@ class SpaceTimeCorr : public TrajectoryAnalysisModule
 
 
         int                                                         frames              = 0;
-        int                                                         tau_jump            = 100;
+        int                                                         tauJump            = 100;  // selectable
 
         int                                                         window              = 1000; // selectable
         int                                                         tau                 = 500;  // selectable
-        float                                                       crl_border          = 0.5;  // selectable
-        float                                                       eff_rad             = 1.5;  // selectable
-        std::string                                                 OutPutName;                 // selectable
+        float                                                       crlBorder          = 0.5;  // selectable
+        float                                                       effRad             = 1.5;  // selectable
+        std::string                                                 outPutName;                 // selectable
         int                                                         mode                = 0;    // selectable
 
         correlationType                                             corrs;
@@ -150,11 +150,11 @@ SpaceTimeCorr::initOptions(IOptionsContainer          *options,
                             .description("size of window in frames that correlation evaluation based on"));
     // Add option for crl_border constant
     options->addOption(FloatOption("crl")
-                            .store(&crl_border)
+                            .store(&crlBorder)
                             .description("make graphs based on corrs > crl const"));
-    // Add option for eff_rad constant
+    // Add option for effRad constant
     options->addOption(FloatOption("efRad")
-                            .store(&eff_rad)
+                            .store(&effRad)
                             .description("effective radius for atoms to see each other to evaluate corrs"));
     // Add option for selection list
     options->addOption(SelectionOption("selRaDs").storeVector(&sel_)
@@ -162,11 +162,11 @@ SpaceTimeCorr::initOptions(IOptionsContainer          *options,
                            .description("select residue and domains to form a rigid skeleton"));
     // Add option for output file names
     options->addOption(StringOption("outPut")
-                            .store(&OutPutName)
+                            .store(&outPutName)
                             .description("<your name here> + <local file tag>.txt"));
     // Add option for time step between windows' starts
     options->addOption(gmx::IntegerOption("twStep")
-                            .store(&tau_jump)
+                            .store(&tauJump)
                             .description("time step between windows' starting positions."));
     // Control input settings
     settings->setFlags(TrajectoryAnalysisSettings::efNoUserPBC);
@@ -191,7 +191,7 @@ SpaceTimeCorr::initAnalysis(const TrajectoryAnalysisSettings &settings, const To
     }
 
     std::string str(sel_.back().name());
-    unsigned long tempSize = std::stoul(str.substr(13, 6)) / static_cast< unsigned long >(tau_jump);
+    unsigned long tempSize = std::stoul(str.substr(13, 6)) / static_cast< unsigned long >(tauJump);
 
     sels.resize(tempSize);
 
@@ -200,9 +200,9 @@ SpaceTimeCorr::initAnalysis(const TrajectoryAnalysisSettings &settings, const To
         atomind = sel_[i].atomIndices();
         std::vector< unsigned int > a;
         a.resize(0);
-        sels[std::stoul(str.substr(13, 6)) / static_cast< unsigned long >(tau_jump)].push_back(a);
+        sels[std::stoul(str.substr(13, 6)) / static_cast< unsigned long >(tauJump)].push_back(a);
         for (ArrayRef< const int >::iterator ai = atomind.begin(); (ai < atomind.end()); ai++) {
-            sels[std::stoul(str.substr(13, 6)) / static_cast< unsigned long >(tau_jump)].back().push_back(static_cast< unsigned int >(*ai));
+            sels[std::stoul(str.substr(13, 6)) / static_cast< unsigned long >(tauJump)].back().push_back(static_cast< unsigned int >(*ai));
         }
     }
 
@@ -213,7 +213,7 @@ SpaceTimeCorr::initAnalysis(const TrajectoryAnalysisSettings &settings, const To
         }
     }
 
-    corrs.setDefaults(reference, window, tau, tau_jump, crl_border, eff_rad, 0, OutPutName, sels, resNms);
+    corrs.setDefaults(reference, window, tau, tauJump, crlBorder, effRad, 0, outPutName, index, sels, resNms);
 }
 
 void
index d2077c73c3aeaab53d6408c1af47f7e898b1ad5b..21a05d540a4b7fb54c3da29d0b01c53b8a580186 100644 (file)
@@ -1,34 +1,87 @@
+#include <vector>
+#include <cfloat>
 #include <iostream>
+
 #include "gtest/gtest.h"
+#include <gromacs/trajectoryanalysis.h>
+// #include <gromacs/trajectoryanalysis/topologyinformation.h>
+#include "/home/titov_ai/Develop/gromacs-original/src/gromacs/trajectoryanalysis/topologyinformation.h"
+
+#include "newfit.h"
+#include "corrtype.h"
 
 TEST( corrTests, corrTests_setDefaults )
 {
-    // проверка создания класса
-}
+    std::vector< std::string >                                  testResNms;
+    testResNms.resize(0);
+    std::vector< RVec >                                         testReference;
+    testReference.resize(0);
+    std::vector< std::vector < std::vector < unsigned int > > > testSels;
+    testSels.resize(0);
 
-TEST( corrTests, corrTests_update )
-{
-    // основная работа программы
+    int                                                         testTau_jump            = 100;
+    int                                                         testWindow              = 1000;
+    int                                                         testTau                 = 500;
+    float                                                       testCrl_border          = 0.5;
+    float                                                       testEff_rad             = 1.5;
+    std::string                                                 testOutPutName          = "testString";
+    RVec                                                        a; a[0] = 1; a[1] = 2; a[2] = 3;
+    correlationType                                             testCorrs;
+    std::vector< int >                                          testIndex;
+    testIndex.resize(0);
+
+    testSels.resize(1);
+    testSels[0].resize(1);
+    testSels[0][0].resize(0);
+    for (unsigned int i = 0; i < 100; i++) {
+        testReference.push_back(a);
+        testResNms.push_back(std::to_string(i));
+        testSels[0][0].push_back(i);
+        testIndex.push_back(i);
+    }
+
+    testCorrs.setDefaults(testReference, testWindow, testTau, testTau_jump, testCrl_border, testEff_rad, 0, testOutPutName, testIndex, testSels, testResNms);
+
+    ASSERT_EQ(testCorrs.window, testWindow);
+    ASSERT_EQ(testCorrs.tau, testTau);
+    ASSERT_EQ(testCorrs.tauStep, testTau_jump);
+    ASSERT_EQ(testCorrs.crlUpBorder, testCrl_border);
+    ASSERT_EQ(testCorrs.effRadius, testEff_rad);
+    ASSERT_EQ(testCorrs.mode, 0);
+    ASSERT_EQ(testCorrs.outputName, testOutPutName);
+    for (unsigned int i = 0; i < 100; i++) {
+        ASSERT_EQ(testCorrs.reference[i][0], testReference[i][0]);
+        ASSERT_EQ(testCorrs.reference[i][1], testReference[i][1]);
+        ASSERT_EQ(testCorrs.reference[i][2], testReference[i][2]);
+        ASSERT_EQ(testCorrs.index[i], testIndex[i]);
+        ASSERT_EQ(testCorrs.selections[0][0][i], testSels[0][0][i]);
+        ASSERT_EQ(testCorrs.resNames[i], testResNms[i]);
+    }
 }
 
 TEST( corrTests, corrTests_trajectoryPartition )
 {
-    // разб��рка траектории
+    // разб��ение молекулы на куски исходя из доменов и распределение невошедшей части к доменам
 }
 
 TEST( corrTests, corrTests_correlationEval )
 {
-    // вычисление корреляци�
+    // вычисление корреляци��нных матриц на основе траектории
 }
 
 TEST( corrTests, corrTests_graphCalculations )
 {
-    // создание графа
+    // создание графа на основе посчитанных матриц
 }
 
 TEST( corrTests, corrTests_graphBackBoneEvaluation )
 {
-    // выделение остовного(?) графа
+    // выделение остовного(?) графа на базе полного графа
+}
+
+TEST( corrTests, corrTests_update )
+{
+    // основная работа программы целиком
 }
 
 int main(int argc, char *argv[]) {