diff --git a/regtest/analysis/rt-read-dissims2/Makefile b/regtest/analysis/rt-read-dissims2/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee --- /dev/null +++ b/regtest/analysis/rt-read-dissims2/Makefile @@ -0,0 +1 @@ +include ../../scripts/test.make diff --git a/regtest/analysis/rt-read-dissims2/config b/regtest/analysis/rt-read-dissims2/config new file mode 100644 index 0000000000000000000000000000000000000000..4804b7f2a86c1dcb06f52d08f8dff331e318192f --- /dev/null +++ b/regtest/analysis/rt-read-dissims2/config @@ -0,0 +1,4 @@ +type=driver +# this is to test a different name +arg="--plumed plumed.dat --trajectory-stride 10 --timestep 0.005 --ixyz trajectory.xyz --dump-forces forces --dump-forces-fmt=%8.4f" +extra_files="../../trajectories/trajectory.xyz" diff --git a/regtest/analysis/rt-read-dissims2/configs-stride.pdb.reference b/regtest/analysis/rt-read-dissims2/configs-stride.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..21925e4d814064ba08fc05134b9572f4a6da0d39 --- /dev/null +++ b/regtest/analysis/rt-read-dissims2/configs-stride.pdb.reference @@ -0,0 +1,115 @@ +DESCRIPTION: analysis data from calculation done at time 0.200000 +REMARK WEIGHT=1.0000 TYPE=OPTIMAL +ATOM 1 X RES 0 -4.506 -11.060 -17.545 0.05 0.05 +ATOM 2 X RES 1 4.963 -11.182 -9.194 0.05 0.05 +ATOM 3 X RES 2 4.162 -2.540 -17.207 0.05 0.05 +ATOM 4 X RES 3 -3.809 -2.069 -9.681 0.05 0.05 +ATOM 5 X RES 4 -4.180 -10.584 -1.418 0.05 0.05 +ATOM 6 X RES 5 4.447 -10.620 7.264 0.05 0.05 +ATOM 7 X RES 6 4.385 -2.599 -0.952 0.05 0.05 +ATOM 8 X RES 7 -4.264 -2.879 7.660 0.05 0.05 +ATOM 9 X RES 8 -5.027 -10.867 15.899 0.05 0.05 +ATOM 10 X RES 9 3.620 -10.890 24.529 0.05 0.05 +ATOM 11 X RES 10 4.490 -2.292 15.828 0.05 0.05 +ATOM 12 X RES 11 -4.496 -2.174 24.340 0.05 0.05 +ATOM 13 X RES 12 -3.720 5.418 -17.405 0.05 0.05 +ATOM 14 X RES 13 3.623 5.966 -9.542 0.05 0.05 +ATOM 15 X RES 14 4.401 14.249 -18.015 0.05 0.05 +ATOM 16 X RES 15 -3.820 14.172 -9.591 0.05 0.05 +ATOM 17 X RES 16 -4.504 5.758 -0.036 0.05 0.05 +ATOM 18 X RES 17 3.305 5.096 7.190 0.05 0.05 +ATOM 19 X RES 18 4.331 14.345 0.009 0.05 0.05 +ATOM 20 X RES 19 -3.402 14.752 7.866 0.05 0.05 +END +DESCRIPTION: analysis data from calculation done at time 0.200000 +REMARK WEIGHT=1.0000 TYPE=OPTIMAL +ATOM 1 X RES 0 -4.670 -11.130 -17.511 0.05 0.05 +ATOM 2 X RES 1 5.583 -11.209 -9.235 0.05 0.05 +ATOM 3 X RES 2 4.301 -2.482 -16.840 0.05 0.05 +ATOM 4 X RES 3 -3.760 -1.929 -9.998 0.05 0.05 +ATOM 5 X RES 4 -4.201 -10.212 -1.856 0.05 0.05 +ATOM 6 X RES 5 4.506 -10.293 7.185 0.05 0.05 +ATOM 7 X RES 6 4.647 -2.750 -1.114 0.05 0.05 +ATOM 8 X RES 7 -4.477 -3.337 7.694 0.05 0.05 +ATOM 9 X RES 8 -5.755 -10.773 16.018 0.05 0.05 +ATOM 10 X RES 9 3.124 -11.030 24.688 0.05 0.05 +ATOM 11 X RES 10 4.814 -2.000 15.677 0.05 0.05 +ATOM 12 X RES 11 -4.491 -1.806 24.342 0.05 0.05 +ATOM 13 X RES 12 -3.379 5.315 -17.527 0.05 0.05 +ATOM 14 X RES 13 3.257 6.072 -9.818 0.05 0.05 +ATOM 15 X RES 14 4.689 14.018 -18.419 0.05 0.05 +ATOM 16 X RES 15 -3.518 14.143 -9.834 0.05 0.05 +ATOM 17 X RES 16 -4.862 5.640 0.653 0.05 0.05 +ATOM 18 X RES 17 2.779 4.548 6.887 0.05 0.05 +ATOM 19 X RES 18 4.460 14.224 0.649 0.05 0.05 +ATOM 20 X RES 19 -3.049 14.991 8.360 0.05 0.05 +END +DESCRIPTION: analysis data from calculation done at time 0.200000 +REMARK WEIGHT=1.0000 TYPE=OPTIMAL +ATOM 1 X RES 0 -4.797 -10.892 -17.524 0.05 0.05 +ATOM 2 X RES 1 6.238 -10.978 -9.016 0.05 0.05 +ATOM 3 X RES 2 4.510 -2.450 -16.757 0.05 0.05 +ATOM 4 X RES 3 -4.186 -2.197 -10.094 0.05 0.05 +ATOM 5 X RES 4 -4.154 -9.504 -2.049 0.05 0.05 +ATOM 6 X RES 5 4.557 -9.886 7.278 0.05 0.05 +ATOM 7 X RES 6 4.879 -2.888 -1.227 0.05 0.05 +ATOM 8 X RES 7 -4.895 -3.556 7.522 0.05 0.05 +ATOM 9 X RES 8 -6.393 -11.011 16.310 0.05 0.05 +ATOM 10 X RES 9 2.498 -11.182 24.664 0.05 0.05 +ATOM 11 X RES 10 5.288 -1.860 15.693 0.05 0.05 +ATOM 12 X RES 11 -3.861 -1.562 24.588 0.05 0.05 +ATOM 13 X RES 12 -3.013 5.578 -18.094 0.05 0.05 +ATOM 14 X RES 13 3.214 6.210 -9.768 0.05 0.05 +ATOM 15 X RES 14 5.034 13.706 -18.661 0.05 0.05 +ATOM 16 X RES 15 -3.380 14.173 -10.000 0.05 0.05 +ATOM 17 X RES 16 -5.496 5.677 0.663 0.05 0.05 +ATOM 18 X RES 17 2.962 4.118 6.770 0.05 0.05 +ATOM 19 X RES 18 4.381 13.795 0.873 0.05 0.05 +ATOM 20 X RES 19 -3.386 14.709 8.831 0.05 0.05 +END +DESCRIPTION: analysis data from calculation done at time 0.200000 +REMARK WEIGHT=1.0000 TYPE=OPTIMAL +ATOM 1 X RES 0 -4.972 -10.651 -17.468 0.05 0.05 +ATOM 2 X RES 1 6.834 -10.601 -8.619 0.05 0.05 +ATOM 3 X RES 2 4.839 -2.454 -16.913 0.05 0.05 +ATOM 4 X RES 3 -4.685 -2.410 -10.241 0.05 0.05 +ATOM 5 X RES 4 -4.184 -8.718 -1.928 0.05 0.05 +ATOM 6 X RES 5 4.622 -9.418 7.529 0.05 0.05 +ATOM 7 X RES 6 5.110 -2.972 -1.473 0.05 0.05 +ATOM 8 X RES 7 -5.319 -3.420 7.484 0.05 0.05 +ATOM 9 X RES 8 -7.099 -11.271 16.457 0.05 0.05 +ATOM 10 X RES 9 1.795 -11.424 24.536 0.05 0.05 +ATOM 11 X RES 10 6.011 -2.234 15.660 0.05 0.05 +ATOM 12 X RES 11 -3.246 -1.671 24.754 0.05 0.05 +ATOM 13 X RES 12 -2.534 5.845 -18.557 0.05 0.05 +ATOM 14 X RES 13 3.368 6.364 -9.489 0.05 0.05 +ATOM 15 X RES 14 5.174 13.639 -18.574 0.05 0.05 +ATOM 16 X RES 15 -3.367 14.132 -10.036 0.05 0.05 +ATOM 17 X RES 16 -6.083 5.704 0.149 0.05 0.05 +ATOM 18 X RES 17 3.390 3.801 6.837 0.05 0.05 +ATOM 19 X RES 18 4.216 13.533 0.747 0.05 0.05 +ATOM 20 X RES 19 -3.871 14.225 9.145 0.05 0.05 +END +DESCRIPTION: analysis data from calculation done at time 0.200000 +REMARK WEIGHT=1.0000 TYPE=OPTIMAL +ATOM 1 X RES 0 -5.103 -10.424 -17.164 0.05 0.05 +ATOM 2 X RES 1 7.050 -10.389 -8.531 0.05 0.05 +ATOM 3 X RES 2 5.143 -2.344 -17.090 0.05 0.05 +ATOM 4 X RES 3 -5.107 -2.193 -10.548 0.05 0.05 +ATOM 5 X RES 4 -4.327 -8.390 -1.659 0.05 0.05 +ATOM 6 X RES 5 4.658 -8.831 7.681 0.05 0.05 +ATOM 7 X RES 6 5.148 -2.700 -1.836 0.05 0.05 +ATOM 8 X RES 7 -5.562 -2.969 7.578 0.05 0.05 +ATOM 9 X RES 8 -7.494 -11.552 16.355 0.05 0.05 +ATOM 10 X RES 9 1.117 -11.563 24.384 0.05 0.05 +ATOM 11 X RES 10 6.514 -2.686 15.870 0.05 0.05 +ATOM 12 X RES 11 -2.790 -2.003 24.821 0.05 0.05 +ATOM 13 X RES 12 -1.938 5.998 -18.490 0.05 0.05 +ATOM 14 X RES 13 3.749 6.279 -9.026 0.05 0.05 +ATOM 15 X RES 14 5.216 13.612 -18.212 0.05 0.05 +ATOM 16 X RES 15 -3.250 14.142 -9.905 0.05 0.05 +ATOM 17 X RES 16 -6.457 5.381 -0.665 0.05 0.05 +ATOM 18 X RES 17 3.858 3.517 6.807 0.05 0.05 +ATOM 19 X RES 18 3.999 13.370 0.561 0.05 0.05 +ATOM 20 X RES 19 -4.422 13.745 9.068 0.05 0.05 +END diff --git a/regtest/analysis/rt-read-dissims2/mymatrix.dat b/regtest/analysis/rt-read-dissims2/mymatrix.dat new file mode 100644 index 0000000000000000000000000000000000000000..e26db230a9ca85f11de378f39b9b6e989b87498d --- /dev/null +++ b/regtest/analysis/rt-read-dissims2/mymatrix.dat @@ -0,0 +1,5 @@ + 0.0000 1.0000 1.0000 4.0000 9.0000 + 1.0000 0.0000 1.0000 4.0000 9.0000 + 1.0000 1.0000 0.0000 1.0000 4.0000 + 4.0000 4.0000 1.0000 0.0000 1.0000 + 9.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-read-dissims2/mymatrix_stride.dat.reference b/regtest/analysis/rt-read-dissims2/mymatrix_stride.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..6871b4a6dd78d38831fb479a2a6cec68a0166eb8 --- /dev/null +++ b/regtest/analysis/rt-read-dissims2/mymatrix_stride.dat.reference @@ -0,0 +1,5 @@ + 0.0000 1.0000 1.0000 4.0000 9.0000 + 1.0000 0.0000 1.0000 4.0000 9.0000 + 1.0000 1.0000 0.0000 1.0000 4.0000 + 4.0000 4.0000 1.0000 0.0000 1.0000 + 9.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-read-dissims2/plumed.dat b/regtest/analysis/rt-read-dissims2/plumed.dat new file mode 100644 index 0000000000000000000000000000000000000000..313bb905b96ec1038f252569c07f7570ec9cee88 --- /dev/null +++ b/regtest/analysis/rt-read-dissims2/plumed.dat @@ -0,0 +1,8 @@ +c1: READ_ANALYSIS_FRAMES ATOMS=1-20 STRIDE=1 + +r1: READ_DISSIMILARITY_MATRIX TRAJ=c1 FILE=mymatrix.dat +PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=r1 FILE=mymatrix_out.dat FMT=%8.4f + +l1: LANDMARK_SELECT_STRIDE USE_OUTPUT_DATA_FROM=r1 NLANDMARKS=5 +PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=l1 FILE=mymatrix_stride.dat FMT=%8.4f +OUTPUT_ANALYSIS_DATA_TO_PDB USE_OUTPUT_DATA_FROM=l1 FILE=configs-stride.pdb FMT=%8.4f diff --git a/src/analysis/AnalysisBase.cpp b/src/analysis/AnalysisBase.cpp index 8e3a3413793ddea9d64e5622f59c24ec5e34627b..deda1e0ca0b9180473a1801e1a82401d26a607ac 100644 --- a/src/analysis/AnalysisBase.cpp +++ b/src/analysis/AnalysisBase.cpp @@ -20,6 +20,7 @@ along with plumed. If not, see <http://www.gnu.org/licenses/>. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "AnalysisBase.h" +#include "ReadAnalysisFrames.h" #include "core/PlumedMain.h" #include "core/ActionSet.h" @@ -50,6 +51,8 @@ mydata(NULL) !keywords.exists("REUSE_INPUT_DATA_FROM") ) error("input analysis action was not specified use USE_OUTPUT_DATA_FROM"); if( datastr.length()>0 ){ mydata=plumed.getActionSet().selectWithLabel<AnalysisBase*>( datastr ); + ReadAnalysisFrames* checkt = dynamic_cast<ReadAnalysisFrames*>( mydata ); + if( checkt ) error("READ_ANALYSIS_FRAMES should only be used in association with READ_DISSSIMILARITY_MATRIX"); log.printf(" performing analysis on output from %s \n",datastr.c_str() ); if( !mydata ) error("could not find analysis action named " + datastr ); freq=mydata->freq; use_all_data=mydata->use_all_data; diff --git a/src/analysis/AnalysisWithDataCollection.cpp b/src/analysis/AnalysisWithDataCollection.cpp index efb2ae8face9ebdbfb725ffa4c0ca3f69503d6f6..71afb441dc52e6791b57d990457579bcf6a772c5 100644 --- a/src/analysis/AnalysisWithDataCollection.cpp +++ b/src/analysis/AnalysisWithDataCollection.cpp @@ -20,6 +20,7 @@ along with plumed. If not, see <http://www.gnu.org/licenses/>. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "AnalysisWithDataCollection.h" +#include "ReadAnalysisFrames.h" #include "reference/ReferenceConfiguration.h" #include "reference/ReferenceArguments.h" #include "reference/ReferenceAtoms.h" @@ -71,6 +72,8 @@ old_norm(0.0) if( datastr.length()>0 ) { AnalysisWithDataCollection* checkd = plumed.getActionSet().selectWithLabel<AnalysisWithDataCollection*>( datastr ); if( !checkd) error("cannot reuse input data from action with label " + datastr + " as this does not store data"); + ReadAnalysisFrames* checkt = dynamic_cast<ReadAnalysisFrames*>( checkd ); + if( checkt ) error("READ_ANALYSIS_FRAMES should only be used in association with READ_DISSSIMILARITY_MATRIX"); mydata=dynamic_cast<AnalysisBase*>( checkd ); log.printf(" performing analysis on input data stored in from %s \n",datastr.c_str() ); freq=mydata->freq; use_all_data=mydata->use_all_data; @@ -86,7 +89,8 @@ old_norm(0.0) if( keywords.exists("METRIC") ){ std::string metrictmp; parse("METRIC",metrictmp); if( metrictmp.length()==0 ){ - metricname="EUCLIDEAN"; + if( keywords.exists("ARG") ) metricname="EUCLIDEAN"; + else metricname="OPTIMAL"; } else { std::vector<std::string> metricwords = Tools::getWords( metrictmp ); metricname=metricwords[0]; metricwords.erase(metricwords.begin()); @@ -126,7 +130,10 @@ old_norm(0.0) } // Read in the information about how often to run the analysis (storage is read in in ActionPilot.cpp) - if( keywords.exists("USE_ALL_DATA") ) parseFlag("USE_ALL_DATA",use_all_data); + if( keywords.exists("USE_ALL_DATA") ){ + if( !keywords.exists("RUN") ) use_all_data=true; + else parseFlag("USE_ALL_DATA",use_all_data); + } if(!use_all_data){ if( keywords.exists("RUN") ) parse("RUN",freq); // Setup everything given the ammount of data that we will have in each analysis @@ -268,7 +275,6 @@ ReferenceConfiguration* AnalysisWithDataCollection::getInputReferenceConfigurati void AnalysisWithDataCollection::update(){ if( mydata ){ AnalysisBase::update(); return; } - // Ignore first bit of data if we are not using all data - this is a weird choice - I am not sure I understand GAT (perhaps this should be changed)? if( !use_all_data && getStep()==0 ) return ; diff --git a/src/analysis/ReadAnalysisFrames.cpp b/src/analysis/ReadAnalysisFrames.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6afb86f0163846ac9951de2bc73c80fe58c2ed5 --- /dev/null +++ b/src/analysis/ReadAnalysisFrames.cpp @@ -0,0 +1,57 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013,2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "ReadAnalysisFrames.h" +#include "core/PlumedMain.h" +#include "core/ActionSet.h" +#include "core/ActionRegister.h" + +//+PLUMEDOC ANALYSIS READ_ANALYSIS_FRAMES +/* +This allows you to convert a trajectory and a dissimilarity matrix into a dissimilarity object + +\par Examples + +*/ +//+ENDPLUMEDOC + +namespace PLMD { +namespace analysis { + +PLUMED_REGISTER_ACTION(ReadAnalysisFrames,"READ_ANALYSIS_FRAMES") + +void ReadAnalysisFrames::registerKeywords( Keywords& keys ){ + AnalysisWithDataCollection::registerKeywords( keys ); + keys.reset_style("USE_ALL_DATA","hidden"); keys.remove("RUN"); keys.remove("REWEIGHT_BIAS"); keys.remove("REWEIGHT_TEMP"); + keys.remove("TEMP"); keys.remove("WRITE_CHECKPOINT"); keys.remove("NOMEMORY"); keys.remove("RESTART"); + keys.remove("UPDATE_FROM"); keys.remove("UPDATE_UNTIL"); keys.remove("USE_OUTPUT_DATA_FROM"); + keys.remove("ARG"); keys.remove("SERIAL"); keys.remove("REUSE_INPUT_DATA_FROM"); +} + +ReadAnalysisFrames::ReadAnalysisFrames( const ActionOptions& ao ): +Action(ao), +AnalysisWithDataCollection(ao) +{ + if( plumed.getActionSet().size()!=0 ) error("read analysis frames command must be at top of input file"); +} + +} +} diff --git a/src/analysis/ReadAnalysisFrames.h b/src/analysis/ReadAnalysisFrames.h new file mode 100644 index 0000000000000000000000000000000000000000..11f43740cb1b1a3cff9739442e653e32c7252b8e --- /dev/null +++ b/src/analysis/ReadAnalysisFrames.h @@ -0,0 +1,42 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013,2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#ifndef __PLUMED_analysis_ReadAnalysisFrames_h +#define __PLUMED_analysis_ReadAnalysisFrames_h + +#include "AnalysisWithDataCollection.h" + +namespace PLMD { +namespace analysis { + +class ReadAnalysisFrames : public AnalysisWithDataCollection { +public: + static void registerKeywords( Keywords& keys ); + ReadAnalysisFrames( const ActionOptions& ao ); +/// Select landmark configurations + void performAnalysis(){} +/// This does nothing - it just ensures the final class is not abstract + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } +}; + +} +} +#endif diff --git a/src/analysis/ReadDissimilarityMatrix.cpp b/src/analysis/ReadDissimilarityMatrix.cpp index 7dec6c1ddd1171dcadd447d32f52569fd9c6a0e2..41905756f697d465c9b5886cd9019128a9dcc839 100644 --- a/src/analysis/ReadDissimilarityMatrix.cpp +++ b/src/analysis/ReadDissimilarityMatrix.cpp @@ -20,6 +20,7 @@ along with plumed. If not, see <http://www.gnu.org/licenses/>. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "AnalysisBase.h" +#include "ReadAnalysisFrames.h" #include "core/PlumedMain.h" #include "core/ActionSet.h" #include "core/ActionRegister.h" @@ -46,7 +47,7 @@ private: public: static void registerKeywords( Keywords& keys ); ReadDissimilarityMatrix( const ActionOptions& ao ); - unsigned getNumberOfDataPoints() const { return nnodes; } + unsigned getNumberOfDataPoints() const ; /// This gives an error as if we read in the matrix we dont have the coordinates ReferenceConfiguration* getReferenceConfiguration( const unsigned& idata ); ReferenceConfiguration* getInputReferenceConfiguration( const unsigned& idata ); @@ -71,6 +72,7 @@ PLUMED_REGISTER_ACTION(ReadDissimilarityMatrix,"READ_DISSIMILARITY_MATRIX") void ReadDissimilarityMatrix::registerKeywords( Keywords& keys ){ AnalysisBase::registerKeywords( keys ); keys.remove("USE_OUTPUT_DATA_FROM"); keys.add("compulsory","FILE","an input file containing the matrix of dissimilarities"); + keys.add("optional","TRAJ","the label for a READ_ANALYSIS_FRAMES action that stores the trajectory"); keys.add("optional","WFILE","input file containing weights of points"); } @@ -79,11 +81,20 @@ Action(ao), AnalysisBase(ao), nnodes(1) { - if( plumed.getActionSet().size()!=0 ) error("read dissimilarity matrix command must be at top of input file"); + std::string mytraj; parse("TRAJ",mytraj); + if( mytraj.length()>0 ){ + ReadAnalysisFrames* mtraj = plumed.getActionSet().selectWithLabel<ReadAnalysisFrames*>( mytraj ); + if( !mtraj ) error(mytraj + " is not the label of a READ_ANALYSIS_FRAMES object"); + mydata = dynamic_cast<AnalysisBase*>( mtraj ); + } + + if( mytraj.length()>0 && plumed.getActionSet().size()!=1 ) error("should only be this action and the READ_ANALYSIS_FRAMES command in the input file"); + if( mytraj.length()==0 && plumed.getActionSet().size()!=0 ) error("read dissimilarity matrix command must be at top of input file"); parse("FILE",fname); log.printf(" reading dissimilarity matrix from file %s \n",fname.c_str() ); parse("WFILE",wfile); + if( wfile.length()>0 ) log.printf(" reading weights of nodes from file named %s \n",wfile.c_str() ); else log.printf(" setting weights of all nodes equal to one\n"); @@ -92,7 +103,7 @@ nnodes(1) use_all_data=true; freq=1; setStride(1); } -void ReadDissimilarityMatrix::update(){ plumed.stop(); } +void ReadDissimilarityMatrix::update(){ if(!mydata) plumed.stop(); } void ReadDissimilarityMatrix::performAnalysis(){ IFile mfile; mfile.open(fname); @@ -107,6 +118,7 @@ void ReadDissimilarityMatrix::performAnalysis(){ for(unsigned j=0;j<nnodes;++j) Tools::convert( words[j], dissimilarities(i,j) ); } mfile.close(); + if( mydata && nnodes!=getNumberOfDataPoints() ) error("mismatch between number of data points in trajectory and the dimensions of the dissimilarity matrix"); weights.resize( nnodes ); if( wfile.length()>0 ){ @@ -120,21 +132,29 @@ void ReadDissimilarityMatrix::performAnalysis(){ } } +unsigned ReadDissimilarityMatrix::getNumberOfDataPoints() const { + if( mydata ) return AnalysisBase::getNumberOfDataPoints(); + return nnodes; +} + double ReadDissimilarityMatrix::getDissimilarity( const unsigned& iframe, const unsigned& jframe ){ return dissimilarities( iframe, jframe ); } ReferenceConfiguration* ReadDissimilarityMatrix::getReferenceConfiguration( const unsigned& idata ){ + if( mydata ) return AnalysisBase::getReferenceConfiguration( idata ); plumed_merror("cannot get reference configurations from read in dissimilarity matrix"); return NULL; } ReferenceConfiguration* ReadDissimilarityMatrix::getInputReferenceConfiguration( const unsigned& idata ){ + if( mydata ) return AnalysisBase::getInputReferenceConfiguration( idata ); plumed_merror("cannot get reference configurations from read in dissimilarity matrix"); return NULL; } void ReadDissimilarityMatrix::getDataPoint( const unsigned& idata, std::vector<double>& point, double& weight ) const { + if( mydata ){ AnalysisBase::getDataPoint( idata, point, weight ); return; } plumed_merror("cannot get data points from read in dissmimilarity matrix"); } diff --git a/user-doc/Analysis.txt b/user-doc/Analysis.txt index b00dadfaea938600232f220c13312ed80233da4a..0491904070a9dc790b2463f763be726f4775107b 100644 --- a/user-doc/Analysis.txt +++ b/user-doc/Analysis.txt @@ -122,7 +122,9 @@ external file <tr> <td width=5%> \subpage READ_DISSIMILARITY_MATRIX </td> <td> Read a matrix of dissimilarities between a trajectory of atomic configurations from a file. </td> </tr> </table> -N.B. You can only use the \ref READ_DISSIMILARITY_MATRIX command when you are doing post-processing. +N.B. You can only use the \ref READ_DISSIMILARITY_MATRIX command when you are doing post-processing. If you have a +trajectory that contains the configurations you read in the configurations from the trajectory using +\ref READ_ANALYSIS_FRAMES \ref landmarks Landmark Selection