23 #include "core/PlumedMain.h"
24 #include "core/ActionSet.h"
25 #include "core/SetupMolInfo.h"
26 #include "core/Atoms.h"
27 #include "vesselbase/Vessel.h"
28 #include "tools/DRMSD.h"
29 #include "tools/RMSD.h"
32 namespace secondarystructure{
38 keys.
add(
"residues",
"RESIDUES",
"this command is used to specify the set of residues that could conceivably form part of the secondary structure. "
39 "It is possible to use residues numbers as the various chains and residues should have been identified else using an instance of the "
40 "\\ref MOLINFO action. If you wish to use all the residues from all the chains in your system you can do so by "
41 "specifying all. Alternatively, if you wish to use a subset of the residues you can specify the particular residues "
42 "you are interested in as a list of numbers. Please be aware that to form secondary structure elements your chain "
43 "must contain at least N residues, where N is dependent on the particular secondary structure you are interested in. "
44 "As such if you define portions of the chain with fewer than N residues the code will crash.");
45 keys.
add(
"compulsory",
"TYPE",
"DRMSD",
"the manner in which RMSD alignment is performed. Should be OPTIMAL, SIMPLE or DRMSD. "
46 "For more details on the OPTIMAL and SIMPLE methods see \\ref RMSD. For more details on the "
47 "DRMSD method see \\ref DRMSD.");
48 keys.
add(
"compulsory",
"R_0",
"The r_0 parameter of the switching function.");
49 keys.
add(
"compulsory",
"D_0",
"0.0",
"The d_0 parameter of the switching function");
50 keys.
add(
"compulsory",
"NN",
"8",
"The n parameter of the switching function");
51 keys.
add(
"compulsory",
"MM",
"12",
"The m parameter of the switching function");
52 keys.
reserve(
"optional",
"STRANDS_CUTOFF",
"If in a segment of protein the two strands are further apart then the calculation "
53 "of the actual RMSD is skipped as the structure is very far from being beta-sheet like. "
54 "This keyword speeds up the calculation enormously when you are using the LESS_THAN option. "
55 "However, if you are using some other option, then this cannot be used");
56 keys.
addFlag(
"NOPBC",
false,
"ignore the periodic boundary conditions when calculating distances");
57 keys.
addFlag(
"VERBOSE",
false,
"write a more detailed output");
58 keys.
add(
"hidden",
"NL_STRIDE",
"the frequency with which the neighbor list should be updated. Between neighbour list update steps all quantities "
59 "that contributed less than TOL at the previous neighbor list update step are ignored.");
60 ActionWithVessel::registerKeywords( keys );
61 keys.
setComponentsIntroduction(
"By default this Action calculates the number of structural units that are within a certain "
62 "distance of a idealised secondary structure element. This quantity can then be referenced "
63 "elsewhere in the input by using the label of the action. However, thes Action can also be used to "
64 "calculate the following quantities by using the keywords as described below. The quantities then "
65 "calculated can be referened using the label of the action followed by a dot and then the name "
66 "from the table below.");
67 keys.
use(
"LESS_THAN"); keys.
use(
"MIN");
77 reduceAtNextStep(false),
84 log.
printf(
" distances from secondary structure elements are calculated using %s algorithm\n",
alignType.c_str() );
85 log<<
" Bibliography "<<
plumed.cite(
"Pietrucci and Laio, J. Chem. Theory Comput. 5, 2197 (2009)");
log<<
"\n";
92 else log.
printf(
" Updating contributors every step.\n");
111 if( moldat.size()==0 )
error(
"Unable to find MOLINFO in input");
113 std::vector<std::string> resstrings;
parseVector(
"RESIDUES", resstrings );
115 if(resstrings[0]==
"all"){
116 log.
printf(
" examining all possible secondary structure combinations");
118 log.
printf(
" examining secondary struture in residue poritions : %s ",resstrings[0].c_str() );
119 for(
unsigned i=1;i<resstrings.size();++i)
log.
printf(
", %s",resstrings[i].c_str() );
123 std::vector< std::vector<AtomNumber> > backatoms;
124 moldat[0]->getBackbone( resstrings, backnames, backatoms );
126 chain_lengths.resize( backatoms.size() );
127 for(
unsigned i=0;i<backatoms.size();++i){
128 chain_lengths[i]=backatoms[i].size();
129 for(
unsigned j=0;j<backatoms[i].size();++j)
all_atoms.addIndexToList( backatoms[i][j] );
146 if(
plumed.getAtoms().usingNaturalUnits() ){
147 error(
"cannot use this collective variable when using natural units");
152 for(
unsigned i=0;i<structure.size();++i){
153 structure[i][0]*=units; structure[i][1]*=units; structure[i][2]*=units;
167 double r0;
parse(
"R_0",r0);
double d0;
parse(
"D_0",d0);
168 int nn;
parse(
"NN",nn);
int mm;
parse(
"MM",mm);
169 std::ostringstream ostr;
170 ostr<<
"RATIONAL R_0="<<r0<<
" D_0="<<d0<<
" NN="<<nn<<
" MM="<<mm;
171 std::string input=ostr.str();
addVessel(
"LESS_THAN", input, -1 );
177 std::vector<Vector> tmp( structure.size() );
der.push_back( tmp );
183 std::vector<double> align( structure.size(), 1.0 );
199 bool updatetime=
false;
241 for(
unsigned i=15;i<30;++i){
242 pos[i]+=( origin_new - origin_old );
268 plumed_dbg_assert( ider==0 );
void setComponentsIntroduction(const std::string &instr)
Set the text that introduces how the components for this action are introduced.
const Vector & getPosition(int) const
Get position of i-th atom.
static void registerKeywords(Keywords &keys)
Register all the relevant keywords for the action.
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
unsigned current
The numerical index of the task we are curently performing.
void setSecondaryStructure(std::vector< Vector > &structure, double bondlength, double units)
Set a reference configuration.
Log & log
Reference to the log stream.
static void registerKeywords(Keywords &keys)
double modulo() const
Compute the modulo.
std::vector< double > forcesToApply
void apply()
Apply an Action.
bool pbcon
Are we using pbc.
Class implementing fixed size vectors of doubles.
void error(const std::string &msg) const
Crash calculation and print documentation.
std::vector< Vector > pos
Tempory variables for getting positions of atoms and applying forces.
int updateFreq
Everything for controlling the updating of neighbor lists.
static void registerKeywords(Keywords &keys)
void add(const std::string &t, const std::string &k, const std::string &d)
Add a new keyword of type t with name k and description d.
void addVessel(const std::string &name, const std::string &input, const int numlab=0, const std::string thislab="")
Add a vessel to the list of vessels.
void readBackboneAtoms(const std::vector< std::string > &backnames, std::vector< unsigned > &chain_lengths)
Get the atoms in the backbone.
std::string alignType
The type of rmsd we are calculating.
void runAllTasks()
Calculate the values of all the vessels.
A class that implements RMSD calculations This is a class that implements the various infrastructure ...
bool getForcesFromVessels(std::vector< double > &forcesToApply)
Retrieve the forces from all the vessels (used in apply)
std::vector< std::vector< Vector > > der
Stuff for derivatives.
void readVesselKeywords()
Complete the setup of this object (this routine must be called after construction of ActionWithValue)...
const Pbc & getPbc() const
Get reference to Pbc.
void addColvar(const std::vector< unsigned > &newatoms)
Add a set of atoms to calculat ethe rmsd from.
unsigned getAtomIndex(const unsigned &iatom)
Get the index of an atom.
Used to create a PLMD::Action that has some scalar or vectorial output that may or may not have some ...
DynamicList< AtomNumber > all_atoms
List of all the atoms we require.
std::vector< Tensor > vir
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
This class holds the keywords and their documentation.
This class is used to bring the relevant information to the Action constructor.
Action used to create objects that access the positions of the atoms from the MD code.
void addIndexToList(const T &ii)
Add something to the active list.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
void setElementValue(const unsigned &, const double &)
Set the value of the element.
unsigned getNumberOfDerivatives()
Base class for all the input Actions.
static void registerKeywords(Keywords &keys)
Register all the relevant keywords for the action.
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
void accumulateDerivative(const unsigned &ider, const double &df)
This is used to accumulate the derivatives when we merge using chainRuleForElementDerivatives.
void reserve(const std::string &t, const std::string &k, const std::string &d, const bool isvessel=false)
Reserve a keyword.
void use(const std::string &k)
Use one of the reserved keywords.
void calculate()
Calculate an Action.
DynamicList< unsigned > taskList
The list of tasks we have to perform.
A class that implements DRMSD calculations.
unsigned getNumberOfVessels() const
Get the number of vessels.
SecondaryStructureRMSD(const ActionOptions &)
bool align_strands
Variables for strands cutoff.
long int getStep() const
Return the present timestep.
bool exists(const std::string &k) const
Check if there is a keyword with name k.
friend void mpi_gatherActiveMembers(Communicator &, std::vector< DynamicList< U > > &)
This gathers data split across nodes list of Dynamic lists.
Vector pbcDistance(const Vector &, const Vector &) const
Compute the pbc distance between two positions.
void requestAtoms(const std::vector< AtomNumber > &a)
Request an array of atoms.
void performTask(const unsigned &j)
Calculate one of the functions in the distribution.
void mergeDerivatives(const unsigned &, const double &)
bool serial
Do all calculations in serial.
void setForcesOnAtoms(const std::vector< double > &forcesToApply, unsigned ind=0)
Add the forces to the atoms.
unsigned getNumberOfAtoms() const
Get number of available atoms.
void setAtomsFromStrands(const unsigned &atom1, const unsigned &atom2)
Setup a pair of atoms to use for strands cutoff.
std::vector< RMSD * > secondary_rmsd
The reference configurations.
const Keywords & keywords
void resizeFunctions()
Resize all the functions when the number of derivatives change.
void activateAll()
Make everything in the list active.
unsigned closest
Tempory integer to say which refernce configuration is the closest.
std::vector< std::vector< unsigned > > colvar_atoms
The atoms involved in each of the secondary structure segments.
std::vector< DRMSD * > secondary_drmsd
unsigned getNumberActive() const
Return the number of elements that are currently active.
void prepare()
Prepare an Action for calculation This can be used by Action if they need some special preparation be...
void addFlag(const std::string &k, const bool def, const std::string &d)
Add a falg with name k that is by default on if def is true and off if def is false. d should provide a description of the flag.
virtual ~SecondaryStructureRMSD()