SSAGES  0.1
A MetaDynamics Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SSAGES::AlphaRMSDCV Class Reference

Collective variable to measure alpha helix secondary structure. More...

#include <AlphaRMSDCV.h>

Inheritance diagram for SSAGES::AlphaRMSDCV:
Inheritance graph
[legend]

Public Member Functions

 AlphaRMSDCV (std::vector< int > resids, std::string refpdb, double unitconv)
 Constructor. More...
 
void Initialize (const Snapshot &snapshot) override
 Initialize necessary variables. More...
 
void Evaluate (const Snapshot &snapshot) override
 Evaluate the CV. More...
 
- Public Member Functions inherited from SSAGES::CollectiveVariable
 CollectiveVariable ()
 Constructor.
 
double GetValue () const
 Get current value of the CV. More...
 
virtual double GetMinimumImage (double) const
 Returns the minimum image of a CV based on the input location. More...
 
virtual double GetPeriodicValue (double location) const
 Apply periodic boundaries to a given value. More...
 
const std::vector< Vector3 > & GetGradient () const
 Get current gradient of the CV. More...
 
const Matrix3GetBoxGradient () const
 Get gradient contribution to box.
 
const std::array< double, 2 > & GetBoundaries ()
 Get CV boundaries. More...
 
virtual double GetDifference (double location) const
 

Static Public Member Functions

static AlphaRMSDCVBuild (const Json::Value &json, const std::string &path)
 Set up collective variable. More...
 
- Static Public Member Functions inherited from SSAGES::CollectiveVariable
static CollectiveVariableBuildCV (const Json::Value &json, const std::string &path)
 Set up collective variable. More...
 

Private Attributes

std::vector< int > resids_
 Residue IDs for secondary structure calculation.
 
std::vector< std::vector
< std::string > > 
atomids_
 Atom IDs for secondary structure calculation: backbone of resids_.
 
std::string refpdb_
 Name of pdb reference for system.
 
std::vector< Vector3refalpha_
 Coordinates for reference structure.
 
double unitconv_
 Length unit conversion: convert 1 nm to your internal MD units (ex. if using angstroms use 10)
 

Additional Inherited Members

- Protected Attributes inherited from SSAGES::CollectiveVariable
std::vector< Vector3grad_
 Gradient vector dCv/dxi.
 
Matrix3 boxgrad_
 Gradient w.r.t box vectors dCv/dHij.
 
double val_
 Current value of CV.
 
std::array< double, 2 > bounds_
 Bounds on CV.
 

Detailed Description

Collective variable to measure alpha helix secondary structure.

Following treatment in Pietrucci and Laio, "A Collective Variable for the Efficient Exploration of Protein Beta-Sheet Structures: Application to SH3 and GB1", JCTC, 2009, 5(9): 2197-2201.

Check blocks of six consecutive protein residues for RMSD from reference "ideal" alpha helix structure.

Definition at line 43 of file AlphaRMSDCV.h.

Constructor & Destructor Documentation

SSAGES::AlphaRMSDCV::AlphaRMSDCV ( std::vector< int >  resids,
std::string  refpdb,
double  unitconv 
)
inline

Constructor.

Parameters
residsIDs of residues for calculating secondary structure
refpdbString of pdb filename with atom and residue indices.
unitconvConversion for internal MD length unit: 1 nm is equal to unitconv internal units

Construct an AlphaRMSD CV – calculates alpha helix character by summing pairwise RMSD to an ideal helix structure for all possible 6 residue segments.

Definition at line 74 of file AlphaRMSDCV.h.

References resids_.

Referenced by Build().

74  :
75  resids_(resids), refpdb_(refpdb), unitconv_(unitconv)
76  {
77  if(resids_.size() != 2 ){
78  throw std::invalid_argument("AlphaRMSDCV: Input must designate range of residues with 2 residue numbers.");
79  }
80 
81  resids_.clear();
82 
83  if(resids[0] >= resids[1]){
84  throw std::invalid_argument("AlphaRMSDCV: Input must list lower residue index first: please reverse residue range.");
85  } else if(resids[1] - resids[0] < 5) {
86  throw std::invalid_argument("AlphaRMSDCV: Residue range must span at least 6 residues for alpha helix calculation.");
87  }
88 
89  std::cout << "AlphaRMSDCV: Calculating alpha helix character from residue " << resids[0] << " to " << resids[1] << "." << std::endl;
90 
91  for(unsigned int i = resids[0]; i <= resids[1]; i++){
92  resids_.push_back(i);
93  }
94  }
double unitconv_
Length unit conversion: convert 1 nm to your internal MD units (ex. if using angstroms use 10) ...
Definition: AlphaRMSDCV.h:60
std::vector< int > resids_
Residue IDs for secondary structure calculation.
Definition: AlphaRMSDCV.h:48
std::string refpdb_
Name of pdb reference for system.
Definition: AlphaRMSDCV.h:54

Here is the caller graph for this function:

Member Function Documentation

static AlphaRMSDCV* SSAGES::AlphaRMSDCV::Build ( const Json::Value &  json,
const std::string &  path 
)
inlinestatic

Set up collective variable.

Parameters
jsonJSON input value.
pathPath for JSON path specification.
Returns
Pointer to the CV built by this function. nullptr in case of unknown error.

Builds a CV from a JSON node. Returns a pointer to the built cv. If an unknown error is encountered, this function will return a nullptr, but generally it will throw a BuildException on failure.

Warning
Object lifetime is the caller's responsibility.

Definition at line 205 of file AlphaRMSDCV.h.

References AlphaRMSDCV(), Json::Requirement::GetErrors(), Json::Requirement::HasErrors(), Json::ObjectRequirement::Parse(), and Json::ObjectRequirement::Validate().

Referenced by SSAGES::CollectiveVariable::BuildCV().

206  {
207  Json::ObjectRequirement validator;
208  Json::Value schema;
209  Json::Reader reader;
210 
211  reader.parse(JsonSchema::AlphaRMSDCV, schema);
212  validator.Parse(schema, path);
213 
214  //Validate inputs
215  validator.Validate(json, path);
216  if(validator.HasErrors())
217  throw BuildException(validator.GetErrors());
218 
219  std::vector<int> resids;
220  for(auto& s : json["residue_ids"])
221  resids.push_back(s.asInt());
222  auto reference = json["reference"].asString();
223 
224  double unitconv = json.get("length_unit", 1).asDouble();
225 
226  return new AlphaRMSDCV(resids, reference, unitconv);
227  }
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
Requirements on an object.
AlphaRMSDCV(std::vector< int > resids, std::string refpdb, double unitconv)
Constructor.
Definition: AlphaRMSDCV.h:74
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.

Here is the call graph for this function:

Here is the caller graph for this function:

void SSAGES::AlphaRMSDCV::Evaluate ( const Snapshot snapshot)
inlineoverride

Evaluate the CV.

Parameters
snapshotCurrent simulation snapshot.

Definition at line 142 of file AlphaRMSDCV.h.

References atomids_, SSAGES::Snapshot::GetLocalIndices(), SSAGES::Snapshot::GetNumAtoms(), SSAGES::Snapshot::GetPositions(), SSAGES::CollectiveVariable::grad_, refalpha_, resids_, and SSAGES::CollectiveVariable::val_.

143  {
144  // need atom positions for all atoms in atomids_
145  const auto& pos = snapshot.GetPositions();
146  //const auto& image_flags = snapshot.GetImageFlags();
147  std::vector<int> groupidx;
148  std::vector<int> double_atomids(atomids_[0].size());
149  std::transform(atomids_[0].begin(), atomids_[0].end(), double_atomids.begin(), [](std::string val) {return std::stod(val);});
150  snapshot.GetLocalIndices(double_atomids, &groupidx); // get correct local atom indices
151 
152  double rmsd, dist_norm, dxgrouprmsd;
153  Vector3 dist_xyz, dist_ref;
154  std::vector<Vector3> refxyz;
155  std::vector< std::vector< Vector3 > > deriv(30, std::vector<Vector3>(30, Vector3{0,0,0}));
156 
157  std::fill(grad_.begin(), grad_.end(), Vector3{0,0,0});
158  grad_.resize(snapshot.GetNumAtoms(), Vector3{0,0,0});
159  val_ = 0.0;
160 
161  unsigned int resgroups = resids_.size() - 5;
162 
163  // for each set of 6 residues
164  for(size_t i = 0; i < resgroups; i++){
165 
166  // clear temp rmsd calculation
167  rmsd = 0.0;
168 
169  // load refxyz with the correct 30 reference atoms
170  std::fill(refxyz.begin(), refxyz.end(), Vector3{0,0,0});
171  refxyz.resize(30, Vector3{0,0,0});
172  for(size_t j = 0; j < 30; j++){
173  refxyz[j] = pos[groupidx[5 * i + j]];
174  }
175 
176  // sum over 435 pairs in refxyz and refalpha_ to calculate CV
177  for(size_t j = 0; j < 29; j++){
178  for(size_t k = j + 1; k < 30; k++){
179  dist_xyz = refxyz[j] - refxyz[k];
180  dist_ref = refalpha_[j] - refalpha_[k]; // could be precalculated
181  dist_norm = dist_xyz.norm() - dist_ref.norm();
182  rmsd += dist_norm * dist_norm;
183  deriv[j][k] = dist_xyz * dist_norm / dist_xyz.norm();
184  }
185  }
186 
187  rmsd = pow(rmsd / 435, 0.5) / 0.1;
188  val_ += (1 - pow(rmsd, 8.0)) / (1 - pow(rmsd, 12.0));
189 
190  dxgrouprmsd = pow(rmsd, 11.0) + pow(rmsd, 7.0);
191  dxgrouprmsd /= pow(rmsd, 8.0) + pow(rmsd, 4.0) + 1;
192  dxgrouprmsd /= pow(rmsd, 8.0) + pow(rmsd, 4.0) + 1;
193  dxgrouprmsd *= -40. / 435;
194 
195  for(size_t j = 0; j < 29; j++){
196  for(size_t k = j + 1; k < 30; k++){
197  grad_[groupidx[5 * i + j]] += dxgrouprmsd * deriv[j][k];
198  grad_[groupidx[5 * i + k]] -= dxgrouprmsd * deriv[j][k];
199  }
200  }
201  }
202  }
std::vector< std::vector< std::string > > atomids_
Atom IDs for secondary structure calculation: backbone of resids_.
Definition: AlphaRMSDCV.h:51
std::vector< int > resids_
Residue IDs for secondary structure calculation.
Definition: AlphaRMSDCV.h:48
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
std::vector< Vector3 > refalpha_
Coordinates for reference structure.
Definition: AlphaRMSDCV.h:57
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33
double val_
Current value of CV.

Here is the call graph for this function:

void SSAGES::AlphaRMSDCV::Initialize ( const Snapshot snapshot)
inlineoverride

Initialize necessary variables.

Parameters
snapshotCurrent simulation snapshot.

Definition at line 100 of file AlphaRMSDCV.h.

References atomids_, SSAGES::ReadBackbone::GetPdbBackbone(), refalpha_, refpdb_, resids_, and unitconv_.

101  {
103 
104  // reference 'ideal' alpha helix structure, in nanometers
105  // Reference structure taken from values used in Plumed 2.2.0
106  refalpha_.push_back(unitconv_ * Vector3{ .0733, .0519, .5298 }); // N
107  refalpha_.push_back(unitconv_ * Vector3{ .1763, .0810, .4301 }); // CA
108  refalpha_.push_back(unitconv_ * Vector3{ .3166, .0543, .4881 }); // CB
109  refalpha_.push_back(unitconv_ * Vector3{ .1527, -.0045, .3053 }); // C
110  refalpha_.push_back(unitconv_ * Vector3{ .1646, .0436, .1928 }); // O
111  refalpha_.push_back(unitconv_ * Vector3{ .1180, -.1312, .3254 }); // N
112  refalpha_.push_back(unitconv_ * Vector3{ .0924, -.2203, .2126 }); // CA
113  refalpha_.push_back(unitconv_ * Vector3{ .0650, -.3626, .2626 }); // CB
114  refalpha_.push_back(unitconv_ * Vector3{-.0239, -.1711, .1261 }); // C
115  refalpha_.push_back(unitconv_ * Vector3{-.0190, -.1815, .0032 }); // O
116  refalpha_.push_back(unitconv_ * Vector3{-.1280, -.1172, .1891 }); // N
117  refalpha_.push_back(unitconv_ * Vector3{-.2416, -.0661, .1127 }); // CA
118  refalpha_.push_back(unitconv_ * Vector3{-.3548, -.0217, .2056 }); // CB
119  refalpha_.push_back(unitconv_ * Vector3{-.1964, .0529, .0276 }); // C
120  refalpha_.push_back(unitconv_ * Vector3{-.2364, .0659, -.0880 }); // O
121  refalpha_.push_back(unitconv_ * Vector3{-.1130, .1391, .0856 }); // N
122  refalpha_.push_back(unitconv_ * Vector3{-.0620, .2565, .0148 }); // CA
123  refalpha_.push_back(unitconv_ * Vector3{ .0228, .3439, .1077 }); // CB
124  refalpha_.push_back(unitconv_ * Vector3{ .0231, .2129, -.1032 }); // C
125  refalpha_.push_back(unitconv_ * Vector3{ .0179, .2733, -.2099 }); // O
126  refalpha_.push_back(unitconv_ * Vector3{ .1028, .1084, -.0833 }); // N
127  refalpha_.push_back(unitconv_ * Vector3{ .1872, .0593, -.1919 }); // CA
128  refalpha_.push_back(unitconv_ * Vector3{ .2850, -.0462, -.1397 }); // CB
129  refalpha_.push_back(unitconv_ * Vector3{ .1020, .0020, -.3049 }); // C
130  refalpha_.push_back(unitconv_ * Vector3{ .1317, .0227, -.4224 }); // O
131  refalpha_.push_back(unitconv_ * Vector3{-.0051, -.0684, -.2696 }); // N
132  refalpha_.push_back(unitconv_ * Vector3{-.0927, -.1261, -.3713 }); // CA
133  refalpha_.push_back(unitconv_ * Vector3{-.1933, -.2219, -.3074 }); // CB
134  refalpha_.push_back(unitconv_ * Vector3{-.1663, -.0171, -.4475 }); // C
135  refalpha_.push_back(unitconv_ * Vector3{-.1916, -.0296, -.5673 }); // O
136  }
std::vector< std::vector< std::string > > atomids_
Atom IDs for secondary structure calculation: backbone of resids_.
Definition: AlphaRMSDCV.h:51
double unitconv_
Length unit conversion: convert 1 nm to your internal MD units (ex. if using angstroms use 10) ...
Definition: AlphaRMSDCV.h:60
std::vector< int > resids_
Residue IDs for secondary structure calculation.
Definition: AlphaRMSDCV.h:48
std::string refpdb_
Name of pdb reference for system.
Definition: AlphaRMSDCV.h:54
std::vector< Vector3 > refalpha_
Coordinates for reference structure.
Definition: AlphaRMSDCV.h:57
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33
static std::vector< std::vector< std::string > > GetPdbBackbone(std::string refpdb, std::vector< int > resids)
Read protein backbone atoms from reference PDB file.
Definition: ReadBackbone.h:57

Here is the call graph for this function:


The documentation for this class was generated from the following file: