Skip to content
Snippets Groups Projects
Commit debe8341 authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Moved collection of data for analysis to separate action

Also tidied up how STRIDE and USE_ALL_DATA works for analysis
objects.  Now everything works in a manner similar to GRID
parent 1c998734
No related branches found
No related tags found
No related merge requests found
Showing
with 633 additions and 866 deletions
......@@ -2,7 +2,8 @@ d1: READ FILE=swiss.dat VALUES=c1
d2: READ FILE=swiss.dat VALUES=c2
d3: READ FILE=swiss.dat VALUES=c3
oo: EUCLIDEAN_DISSIMILARITIES ARG=d1,d2,d3 RUN=50
ff: COLLECT_FRAMES ARG=d1,d2,d3 CLEAR=50
oo: EUCLIDEAN_DISSIMILARITIES USE_OUTPUT_DATA_FROM=ff
CLASSICAL_MDS ...
USE_OUTPUT_DATA_FROM=oo
......@@ -17,4 +18,4 @@ SKETCHMAP_CONJGRAD ...
LABEL=smap
... SKETCHMAP_CONJGRAD
OUTPUT_ANALYSIS_DATA_TO_COLVAR USE_OUTPUT_DATA_FROM=smap FMT=%8.4f FILE=smap
OUTPUT_ANALYSIS_DATA_TO_COLVAR USE_OUTPUT_DATA_FROM=smap ARG=smap.* FMT=%8.4f FILE=smap STRIDE=50
......@@ -12,7 +12,7 @@ REMARK t1=-3.9129 t2=3.0809
END
REMARK TYPE=EUCLIDEAN
REMARK ARG=t1,t2
REMARK t1=-3.7022 t2=2.8851
REMARK t1=-3.7022 t2=2.8852
END
REMARK TYPE=EUCLIDEAN
REMARK ARG=t1,t2
......@@ -36,5 +36,5 @@ REMARK t1=-2.6482 t2=1.9062
END
REMARK TYPE=EUCLIDEAN
REMARK ARG=t1,t2
REMARK t1=-2.4375 t2=1.7105
REMARK t1=-2.4374 t2=1.7105
END
REMARK TYPE=OPTIMAL
ATOM 1 X RES 0 -3.056 0.015 1.034 0.08 0.08
ATOM 5 X RES 1 -1.704 -0.423 0.668 0.08 0.08
ATOM 6 X RES 2 -1.062 -1.169 1.390 0.08 0.08
ATOM 7 X RES 3 -1.198 0.061 -0.482 0.08 0.08
ATOM 8 X RES 4 -1.730 0.681 -1.022 0.08 0.08
ATOM 9 X RES 5 0.112 -0.299 -0.990 0.08 0.08
ATOM 10 X RES 6 0.320 -1.331 -0.752 0.08 0.08
ATOM 11 X RES 7 0.124 -0.145 -2.520 0.08 0.08
ATOM 15 X RES 8 1.236 0.519 -0.348 0.08 0.08
ATOM 16 X RES 9 1.838 1.389 -0.968 0.08 0.08
ATOM 17 X RES 10 1.538 0.239 0.930 0.08 0.08
ATOM 18 X RES 11 0.988 -0.441 1.402 0.08 0.08
ATOM 19 X RES 12 2.592 0.907 1.664 0.08 0.08
ATOM 1 X RES 0 -3.056 0.015 1.034 1.00 1.00
ATOM 5 X RES 1 -1.704 -0.423 0.668 1.00 1.00
ATOM 6 X RES 2 -1.062 -1.169 1.390 1.00 1.00
ATOM 7 X RES 3 -1.198 0.061 -0.482 1.00 1.00
ATOM 8 X RES 4 -1.730 0.681 -1.022 1.00 1.00
ATOM 9 X RES 5 0.112 -0.299 -0.990 1.00 1.00
ATOM 10 X RES 6 0.320 -1.331 -0.752 1.00 1.00
ATOM 11 X RES 7 0.124 -0.145 -2.520 1.00 1.00
ATOM 15 X RES 8 1.236 0.519 -0.348 1.00 1.00
ATOM 16 X RES 9 1.838 1.389 -0.968 1.00 1.00
ATOM 17 X RES 10 1.538 0.239 0.930 1.00 1.00
ATOM 18 X RES 11 0.988 -0.441 1.402 1.00 1.00
ATOM 19 X RES 12 2.592 0.907 1.664 1.00 1.00
END
REMARK TYPE=OPTIMAL
ATOM 1 X RES 0 -3.000 -0.093 1.118 0.08 0.08
ATOM 5 X RES 1 -1.666 -0.522 0.673 0.08 0.08
ATOM 6 X RES 2 -1.041 -1.366 1.283 0.08 0.08
ATOM 7 X RES 3 -1.163 0.068 -0.414 0.08 0.08
ATOM 8 X RES 4 -1.679 0.762 -0.868 0.08 0.08
ATOM 9 X RES 5 0.109 -0.283 -1.011 0.08 0.08
ATOM 10 X RES 6 0.264 -1.334 -0.902 0.08 0.08
ATOM 11 X RES 7 0.062 0.044 -2.505 0.08 0.08
ATOM 15 X RES 8 1.306 0.407 -0.366 0.08 0.08
ATOM 16 X RES 9 2.123 0.918 -0.994 0.08 0.08
ATOM 17 X RES 10 1.433 0.409 0.928 0.08 0.08
ATOM 18 X RES 11 0.735 -0.026 1.400 0.08 0.08
ATOM 19 X RES 12 2.517 1.016 1.660 0.08 0.08
ATOM 1 X RES 0 -3.000 -0.093 1.118 1.00 1.00
ATOM 5 X RES 1 -1.666 -0.522 0.673 1.00 1.00
ATOM 6 X RES 2 -1.041 -1.366 1.283 1.00 1.00
ATOM 7 X RES 3 -1.163 0.068 -0.414 1.00 1.00
ATOM 8 X RES 4 -1.679 0.762 -0.868 1.00 1.00
ATOM 9 X RES 5 0.109 -0.283 -1.011 1.00 1.00
ATOM 10 X RES 6 0.264 -1.334 -0.902 1.00 1.00
ATOM 11 X RES 7 0.062 0.044 -2.505 1.00 1.00
ATOM 15 X RES 8 1.306 0.407 -0.366 1.00 1.00
ATOM 16 X RES 9 2.123 0.918 -0.994 1.00 1.00
ATOM 17 X RES 10 1.433 0.409 0.928 1.00 1.00
ATOM 18 X RES 11 0.735 -0.026 1.400 1.00 1.00
ATOM 19 X RES 12 2.517 1.016 1.660 1.00 1.00
END
REMARK TYPE=OPTIMAL
ATOM 1 X RES 0 -2.889 1.336 0.142 0.08 0.08
ATOM 5 X RES 1 -1.789 0.382 0.387 0.08 0.08
ATOM 6 X RES 2 -1.618 -0.115 1.496 0.08 0.08
ATOM 7 X RES 3 -0.989 0.095 -0.643 0.08 0.08
ATOM 8 X RES 4 -1.135 0.526 -1.519 0.08 0.08
ATOM 9 X RES 5 0.077 -0.890 -0.589 0.08 0.08
ATOM 10 X RES 6 -0.227 -1.697 0.051 0.08 0.08
ATOM 11 X RES 7 0.279 -1.458 -2.013 0.08 0.08
ATOM 15 X RES 8 1.412 -0.364 -0.051 0.08 0.08
ATOM 16 X RES 9 2.470 -0.913 -0.310 0.08 0.08
ATOM 17 X RES 10 1.372 0.708 0.755 0.08 0.08
ATOM 18 X RES 11 0.483 1.079 0.970 0.08 0.08
ATOM 19 X RES 12 2.550 1.313 1.320 0.08 0.08
ATOM 1 X RES 0 -2.889 1.336 0.142 1.00 1.00
ATOM 5 X RES 1 -1.789 0.382 0.387 1.00 1.00
ATOM 6 X RES 2 -1.618 -0.115 1.496 1.00 1.00
ATOM 7 X RES 3 -0.989 0.095 -0.643 1.00 1.00
ATOM 8 X RES 4 -1.135 0.526 -1.519 1.00 1.00
ATOM 9 X RES 5 0.077 -0.890 -0.589 1.00 1.00
ATOM 10 X RES 6 -0.227 -1.697 0.051 1.00 1.00
ATOM 11 X RES 7 0.279 -1.458 -2.013 1.00 1.00
ATOM 15 X RES 8 1.412 -0.364 -0.051 1.00 1.00
ATOM 16 X RES 9 2.470 -0.913 -0.310 1.00 1.00
ATOM 17 X RES 10 1.372 0.708 0.755 1.00 1.00
ATOM 18 X RES 11 0.483 1.079 0.970 1.00 1.00
ATOM 19 X RES 12 2.550 1.313 1.320 1.00 1.00
END
This diff is collapsed.
......@@ -28,10 +28,9 @@ namespace PLMD {
namespace analysis {
void AnalysisBase::registerKeywords( Keywords& keys ){
Action::registerKeywords( keys );
ActionPilot::registerKeywords( keys );
ActionAtomistic::registerKeywords( keys );
ActionWithArguments::registerKeywords( keys );
Action::registerKeywords( keys ); ActionPilot::registerKeywords( keys );
ActionWithValue::registerKeywords( keys ); ActionAtomistic::registerKeywords( keys );
ActionWithArguments::registerKeywords( keys ); keys.remove("NUMERICAL_DERIVATIVES");
ActionWithVessel::registerKeywords( keys ); keys.remove("TOL"); keys.reset_style("TIMINGS","hidden"); keys.isAnalysis();
keys.add("atoms-2","USE_OUTPUT_DATA_FROM","use the ouput of the analysis performed by this object as input to your new analysis object");
}
......@@ -39,43 +38,44 @@ void AnalysisBase::registerKeywords( Keywords& keys ){
AnalysisBase::AnalysisBase(const ActionOptions&ao):
Action(ao),
ActionPilot(ao),
ActionWithValue(ao),
ActionAtomistic(ao),
ActionWithArguments(ao),
ActionWithVessel(ao),
my_input_data(NULL)
{
// We have an if statement here so that this doesn't break with READ_DISSIMILARITIES
std::string datastr; if( keywords.exists("USE_OUTPUT_DATA_FROM") ) parse("USE_OUTPUT_DATA_FROM",datastr);
if( keywords.exists("USE_OUTPUT_DATA_FROM") &&
datastr.length()==0 &&
!keywords.exists("REUSE_INPUT_DATA_FROM") ) error("input analysis action was not specified use USE_OUTPUT_DATA_FROM");
if( datastr.length()>0 ){
my_input_data=plumed.getActionSet().selectWithLabel<AnalysisBase*>( datastr );
ReadAnalysisFrames* checkt = dynamic_cast<ReadAnalysisFrames*>( my_input_data );
if( checkt ) error("READ_ANALYSIS_FRAMES should only be used in input to the FRAMES keyword");
log.printf(" performing analysis on output from %s \n",datastr.c_str() );
if( !my_input_data ) error("could not find analysis action named " + datastr );
freq=my_input_data->freq; use_all_data=my_input_data->use_all_data;
if( !use_all_data ) setStride( freq );
if( keywords.exists("USE_OUTPUT_DATA_FROM") ){
std::string datastr; parse("USE_OUTPUT_DATA_FROM",datastr);
if( keywords.style("USE_OUTPUT_DATA_FROM","atoms") && datastr.length()==0 ) error("input analysis action was not specified use USE_OUTPUT_DATA_FROM");
if( datastr.length()>0 ){
my_input_data=plumed.getActionSet().selectWithLabel<AnalysisBase*>( datastr );
log.printf(" performing analysis on output from %s \n",datastr.c_str() );
if( !my_input_data ) error("could not find analysis action named " + datastr );
addDependency( my_input_data );
}
}
}
std::vector<std::string> AnalysisBase::getArgumentNames(){
std::vector<Value*> arg_p( getArgumentList() );
std::vector<std::string> argn( arg_p.size() );
for(unsigned i=0;i<arg_p.size();++i){
plumed_assert( i<argn.size() && i<arg_p.size() );
argn[i]=arg_p[i]->getName();
}
return argn;
}
void AnalysisBase::update(){
// Do nothing if we are just analysing at the end of the calculation
if( use_all_data ) return ;
// Check that we are on step
plumed_dbg_assert( getStep()%freq==0 );
if( getStep()==0 || ( getStride()>0 && !onStep() ) ) return;
// And do the analysis
if( getStep()>0 ) performAnalysis();
performAnalysis();
}
void AnalysisBase::runFinalJobs(){
// Nothing to do if we are not analysing all the data in the trajectory
if( !use_all_data ) return;
// Erm ... user has done something weird
// if( getNumberOfDataPoints()==0 ) error("no data is available for analysis");
// And do the analysis
if( use_all_data ) performAnalysis();
if( getStride()>0 ) return;
performAnalysis();
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2012-2015 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 "DataCollectionObject.h"
#include "tools/PDB.h"
namespace PLMD {
namespace analysis {
void DataCollectionObject::setAtomNumbersAndArgumentNames( const std::vector<AtomNumber>& ind, const std::vector<std::string>& arg_names ){
indices.resize( ind.size() ); positions.resize( indices.size() );
for(unsigned i=0;i<ind.size();++i) indices[i]=ind[i];
for(unsigned i=0;i<arg_names.size();++i) args.insert( std::pair<std::string,double>( arg_names[i], 0.0 ) );
}
void DataCollectionObject::setAtomPositions( const std::vector<Vector>& pos ){
plumed_dbg_assert( pos.size()==positions.size() && pos.size()==indices.size() );
for(unsigned i=0;i<positions.size();++i) positions[i]=pos[i];
}
void DataCollectionObject::setArgument( const std::string& name, const double& value ){
std::map<std::string,double>::iterator it = args.find(name);
if( it!=args.end() ) it->second = value;
else args.insert( std::pair<std::string,double>( name, value ) );
}
bool DataCollectionObject::transferDataToPDB( PDB& mypdb ){
// Check if PDB contains argument names
std::vector<std::string> pdb_args( mypdb.getArgumentNames() );
// Now set the argument values
std::map<std::string,double>::iterator it;
for(unsigned i=0;i<pdb_args.size();++i){
it=args.find( pdb_args[i] );
if( it==args.end() ) return false;
mypdb.setArgumentValue( pdb_args[i], it->second );
}
// Now set the atomic positions
std::vector<AtomNumber> pdb_pos( mypdb.getAtomNumbers() );
if( pdb_pos.size()==positions.size() ) mypdb.setAtomPositions( positions );
else if( pdb_pos.size()>0 ) plumed_merror("This feature is currently not ready");
return true;
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -53,6 +53,7 @@ void PrintDissimilarityMatrix::registerKeywords( Keywords& keys ){
AnalysisBase::registerKeywords( keys );
keys.add("compulsory","FILE","name of file on which to output the data");
keys.add("optional","FMT","the format to use for the output of numbers");
keys.add("compulsory","STRIDE","0","the frequency with which to perform the required analysis and to output the data. The default value of 0 tells plumed to use all the data");
}
PrintDissimilarityMatrix::PrintDissimilarityMatrix( const ActionOptions& ao ):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -63,8 +63,7 @@ LandmarkSelectionBase(ao)
if( !mylandmarks ) error("input to LANDMARKS is not a landmark selection action");
nlandmarks = mylandmarks->nlandmarks;
if( (mylandmarks->my_input_data)->getNumberOfDataPoints()!=my_input_data->getNumberOfDataPoints() ||
mylandmarks->use_all_data!=my_input_data->use_all_data ) error("mismatch between ammount of landmark class and base class");
if( (mylandmarks->my_input_data)->getNumberOfDataPoints()!=my_input_data->getNumberOfDataPoints() ) error("mismatch between ammount of landmark class and base class");
}
void ReselectLandmarks::selectLandmarks(){
......
......@@ -148,7 +148,7 @@ PLUMED_COLVAR_INIT(ao), pbc_(true), myvals(1,0), mypack(0,0,myvals)
std::string type; parse("TYPE",type);
drmsd_= metricRegister().create<PLMD::DRMSD>( type );
drmsd_->setBoundsOnDistances( !nopbc, lcutoff, ucutoff );
drmsd_->set( pdb );
drmsd_->read( pdb );
checkRead();
std::vector<AtomNumber> atoms;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment