OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
topology.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 
20 #ifndef OST_MM_TOPOLOGY_HH
21 #define OST_MM_TOPOLOGY_HH
22 
23 #include <vector>
24 #include <map>
25 #include <set>
26 
27 #include <boost/shared_ptr.hpp>
28 
29 #include <ost/message.hh>
30 #include <ost/mol/atom_handle.hh>
32 #include <ost/mol/entity_handle.hh>
33 #include <ost/mol/mm/index.hh>
36 #include <ost/mol/mm/forcefield.hh>
37 #include <ost/mol/mm/index.hh>
38 #include <ost/mol/xcs_editor.hh>
39 #include <ost/mol/bond_handle.hh>
40 #include <ost/mol/residue_prop.hh>
41 
42 #include <time.h>
43 
44 
45 
46 namespace ost { namespace mol{ namespace mm{
47 
48 class Topology;
49 typedef boost::shared_ptr<Topology> TopologyPtr;
50 
51 
52 class Topology{
53 
54 public:
55 
56  Topology(const std::vector<Real>& masses);
57 
58  Topology() { } //should not be accessible from Python to avoid messing around
59  //with empty topology
60 
61  static TopologyPtr Load(const String& filename);
62 
63  void Save(const String& filename);
64 
65  uint AddHarmonicBond(uint index_one,
66  uint index_two,
67  Real bond_length,
68  Real force_constant);
69 
70  uint AddHarmonicAngle(uint index_one,
71  uint index_two,
72  uint index_three,
73  Real angle,
74  Real force_constant);
75 
76  uint AddUreyBradleyAngle(uint index_one,
77  uint index_two,
78  uint index_three,
79  Real angle,
80  Real angle_force_constant,
81  Real bond_length,
82  Real bond_force_constant);
83 
84  uint AddPeriodicDihedral(uint index_one,
85  uint index_two,
86  uint index_three,
87  uint index_four,
88  int multiplicity,
89  Real phase,
90  Real force_constant);
91 
92  uint AddPeriodicImproper(uint index_one,
93  uint index_two,
94  uint index_three,
95  uint index_four,
96  int multiplicity,
97  Real phase,
98  Real force_constant);
99 
100  uint AddHarmonicImproper(uint index_one,
101  uint index_two,
102  uint index_three,
103  uint index_four,
104  Real angle,
105  Real force_constant);
106 
107  uint AddCMap(uint index_one,
108  uint index_two,
109  uint index_three,
110  uint index_four,
111  uint index_five,
112  int dimension,
113  std::vector<Real> values);
114 
115  uint AddLJPair(uint index_one,
116  uint index_two,
117  Real sigma,
118  Real epsilon);
119 
120 
121  uint AddDistanceConstraint(uint index_one,
122  uint index_two,
123  Real distance);
124 
125  uint AddExclusion(uint index_one,
126  uint index_two);
127 
128  void AddPositionConstraint(uint index);
129 
130  void ResetPositionConstraints() { position_constraints_.clear(); }
131 
132  void ResetExclusions() { exclusions_.clear(); }
133 
134  uint AddHarmonicPositionRestraint(uint index, const geom::Vec3& ref_position, Real k,
135  Real x_scale = 1.0, Real y_scale = 1.0, Real z_scale = 1.0);
136 
137  uint AddHarmonicDistanceRestraint(uint index_one, uint index_two,
138  Real length, Real force_constant);
139 
140  uint AddFGMDHBondDonor(uint index_one, uint index_two,
141  Real length, Real k_length, Real alpha,
142  Real k_alpha, Real beta, Real k_beta);
143 
144  uint AddFGMDHBondAcceptor(uint index_one, uint index_two);
145 
146  //Single atom parameters are expected to be set at once...
147  void SetSigmas(const std::vector<Real>& sigmas);
148 
149  void SetSigma(uint index, Real sigma);
150 
151  void SetEpsilons(const std::vector<Real>& epsilons);
152 
153  void SetEpsilon(uint index, Real epsilon);
154 
155  void SetGBSARadii(const std::vector<Real>& gbsa_radii);
156 
157  void SetGBSARadius(uint index, Real radius);
158 
159  void SetOBCScalings(const std::vector<Real>& obc_scaling);
160 
161  void SetOBCScaling(uint index, Real scaling);
162 
163  void SetCharges(const std::vector<Real>& charges);
164 
165  void SetCharge(uint index, Real charge);
166 
167  void SetMasses(const std::vector<Real>& masses);
168 
169  void SetMass(uint index, Real mass);
170 
171  void SetFudgeQQ(Real fudge) { fudge_qq_ = fudge; }
172 
173  void SetFudgeLJ(Real fudge) { fudge_lj_ = fudge;}
174 
175 
176  void GetHarmonicBondParameters(uint index, uint& index_one, uint& index_two,
177  Real& bond_length, Real& force_constant) const;
178 
179  void GetHarmonicAngleParameters(uint index, uint& index_one, uint& index_two, uint& index_three,
180  Real& angle, Real& force_constant) const;
181 
182  void GetUreyBradleyAngleParameters(uint index, uint& index_one, uint& index_two, uint& index_three,
183  Real& angle, Real& angle_force_constant, Real& bond_length, Real& bond_force_constant) const;
184 
185  void GetPeriodicDihedralParameters(uint index, uint& index_one, uint& index_two, uint& index_three, uint& index_four,
186  int& multiplicity, Real& phase, Real& force_constant) const;
187 
188  void GetPeriodicImproperParameters(uint index, uint& index_one, uint& index_two, uint& index_three, uint& index_four,
189  int& multiplicity, Real& phase, Real& force_constant) const;
190 
191  void GetHarmonicImproperParameters(uint index, uint& index_one, uint& index_two, uint& index_three, uint& index_four,
192  Real& angle, Real& force_constant) const;
193 
194  void GetCMapParameters(uint index, uint& index_one, uint& index_two, uint& index_three, uint& index_four, uint& index_five,
195  int& dimension, std::vector<Real>& map) const;
196 
197  void GetLJPairParameters(uint index, uint& index_one, uint& index_two,
198  Real& sigma, Real& epsilon) const;
199 
200  void GetDistanceConstraintParameters(uint index, uint& index_one, uint& index_two,
201  Real& distance) const;
202 
203  void GetHarmonicPositionRestraintParameters(uint index, uint& atom_index, geom::Vec3& ref_position,
204  Real& k, Real& x_scale, Real& y_scale, Real& z_scale) const;
205 
206  void GetHarmonicDistanceRestraintParameters(uint index, uint& atom_one, uint& atom_two, Real& length,
207  Real& force_constant) const;
208 
209  void GetFGMDHBondDonorParameters(uint index, uint& index_one, uint& index_two,
210  Real& length, Real& k_length, Real& alpha,
211  Real& k_alpha, Real& beta, Real& k_beta) const;
212 
213  void GetFGMDHBondAcceptorParameters(uint index, uint& index_one, uint& index_two) const;
214 
215  void SetHarmonicBondParameters(uint index, const Real bond_length, const Real force_constant);
216 
217  void SetHarmonicAngleParameters(uint index, const Real angle, const Real force_constant);
218 
219  void SetUreyBradleyAngleParameters(uint index, const Real angle, const Real angle_force_constant,
220  const Real bond_length, const Real bond_force_constant);
221 
222  void SetPeriodicDihedralParameters(uint index, const int multiplicity,
223  const Real phase, const Real force_constant);
224 
225  void SetPeriodicImproperParameters(uint index, const int multiplicity, const Real phase,
226  const Real force_constant);
227 
228  void SetHarmonicImproperParameters(uint index, const Real angle, const Real force_constant);
229 
230  void SetCMapParameters(uint index, const int dimension, const std::vector<Real>& map);
231 
232  void SetLJPairParameters(uint index, const Real sigma, const Real epsilon);
233 
234  void SetDistanceConstraintParameters(uint index, const Real distance);
235 
236  void SetHarmonicPositionRestraintParameters(uint index, const geom::Vec3& ref_position, Real k,
237  Real x_scale = 1.0, Real y_scale = 1.0, Real z_scale = 1.0);
238 
239  void SetHarmonicDistanceRestraintParameters(uint index, Real length, Real force_constant);
240 
241  void SetFGMDHBondDonorParameters(uint index, Real length, Real k_length,
242  Real alpha, Real k_alpha, Real beta,
243  Real k_beta);
244 
245  const std::vector<std::pair<Index<2>, std::vector<Real> > >& GetHarmonicBonds() const { return harmonic_bonds_; }
246 
247  const std::vector<std::pair<Index<3>, std::vector<Real> > >& GetHarmonicAngles() const { return harmonic_angles_; }
248 
249  const std::vector<std::pair<Index<3>, std::vector<Real> > >& GetUreyBradleyAngles() const { return urey_bradley_angles_; }
250 
251  const std::vector<std::pair<Index<4>, std::vector<Real> > >& GetPeriodicDihedrals() const { return periodic_dihedrals_; }
252 
253  const std::vector<std::pair<Index<4>, std::vector<Real> > >& GetPeriodicImpropers() const { return periodic_impropers_; }
254 
255  const std::vector<std::pair<Index<4>, std::vector<Real> > >& GetHarmonicImpropers() const { return harmonic_impropers_; }
256 
257  const std::vector<std::pair<Index<5>, std::vector<Real> > >& GetCMaps() const { return cmaps_; }
258 
259  const std::vector<std::pair<Index<2>, std::vector<Real> > >& GetLJPairs() const { return lj_pairs_; }
260 
261  const std::vector<std::pair<Index<2>, std::vector<Real> > >& GetDistanceConstraints() const { return distance_constraints_; }
262 
263  const std::vector<std::pair<Index<1>, std::vector<Real> > >& GetHarmonicPositionRestraints() const { return harmonic_position_restraints_; }
264 
265  const std::vector<std::pair<Index<2>, std::vector<Real> > >& GetHarmonicDistanceRestraints() const{ return harmonic_distance_restraints_; }
266 
267  const std::vector<Index<2> >& GetExclusions() const { return exclusions_; }
268 
269  const std::vector<uint>& GetPositionConstraints() const { return position_constraints_; }
270 
271  const std::vector<std::pair<Index<2>, std::vector<Real> > >& GetFGMDHBondDonors() const { return fgmd_hbond_donors_; }
272 
273  const std::vector<Index<2> >& GetFGMDHBondAcceptors() const { return fgmd_hbond_acceptors_; }
274 
275 
276  std::vector<Real> GetSigmas() const { return sigmas_; }
277 
278  std::vector<Real> GetEpsilons() const { return epsilons_; }
279 
280  std::vector<Real> GetGBSARadii() const { return gbsa_radii_; }
281 
282  std::vector<Real> GetOBCScalings() const { return obc_scaling_; }
283 
284  std::vector<Real> GetCharges() const { return charges_; }
285 
286  Real GetCharge(uint index) const;
287 
288  Real GetMass(uint index) const;
289 
290  Real GetSigma(uint index) const;
291 
292  Real GetEpsilon(uint index) const;
293 
294  Real GetGBSARadius(uint index) const;
295 
296  Real GetOBCScaling(uint index) const;
297 
298  std::vector<Real> GetMasses() const { return atom_masses_; }
299 
300  Real GetFudgeQQ() const { return fudge_qq_; }
301 
302  Real GetFudgeLJ() const { return fudge_lj_; }
303 
304  std::vector<uint> GetHarmonicBondIndices(uint index_one,
305  uint index_two) const;
306 
307  std::vector<uint> GetHarmonicAngleIndices(uint index_one,
308  uint index_two,
309  uint index_three) const;
310 
311  std::vector<uint> GetUreyBradleyAngleIndices(uint index_one,
312  uint index_two,
313  uint index_three) const;
314 
315  std::vector<uint> GetPeriodicDihedralIndices(uint index_one,
316  uint index_two,
317  uint index_three,
318  uint index_four) const;
319 
320  std::vector<uint> GetPeriodicImproperIndices(uint index_one,
321  uint index_two,
322  uint index_three,
323  uint index_four) const;
324 
325  std::vector<uint> GetHarmonicImproperIndices(uint index_one,
326  uint index_two,
327  uint index_three,
328  uint index_four) const;
329 
330  std::vector<uint> GetCMapIndices(uint index_one,
331  uint index_two,
332  uint index_three,
333  uint index_four,
334  uint index_five) const;
335 
336  int GetLJPairIndex(uint index_one,
337  uint index_two) const;
338 
339  int GetDistanceConstraintIndex(uint index_one,
340  uint index_two) const;
341 
342 
343 
344  std::vector<uint> GetHarmonicDistanceRestraintIndices(uint index_one,
345  uint index_two) const;
346 
347  std::vector<uint> GetFGMDHBondDonorIndices(uint index_one,
348  uint index_two) const;
349 
350  std::vector<uint> GetFGMDHBondAcceptorIndices(uint index_one,
351  uint index_two) const;
352 
353  std::vector<uint> GetHarmonicBondIndices(uint atom_index) const;
354 
355  std::vector<uint> GetHarmonicAngleIndices(uint atom_index) const;
356 
357  std::vector<uint> GetUreyBradleyAngleIndices(uint atom_index) const;
358 
359  std::vector<uint> GetPeriodicDihedralIndices(uint atom_index) const;
360 
361  std::vector<uint> GetPeriodicImproperIndices(uint atom_index) const;
362 
363  std::vector<uint> GetHarmonicImproperIndices(uint atom_index) const;
364 
365  std::vector<uint> GetCMapIndices(uint atom_index) const;
366 
367  std::vector<uint> GetLJPairIndices(uint atom_index) const;
368 
369  std::vector<uint> GetDistanceConstraintIndices(uint atom_index) const;
370 
371  std::vector<uint> GetHarmonicPositionRestraintIndices(uint atom_index) const;
372 
373  std::vector<uint> GetHarmonicDistanceRestraintIndices(uint atom_index) const;
374 
375  std::vector<uint> GetFGMDHBondDonorIndices(uint atom_index) const;
376 
377  std::vector<uint> GetFGMDHBondAcceptorIndices(uint atom_index) const;
378 
379  uint GetNumParticles() { return num_particles_; }
380 
381  uint GetNumHarmonicBonds() { return harmonic_bonds_.size(); }
382 
383  uint GetNumHarmonicAngles() { return harmonic_angles_.size(); }
384 
385  uint GetNumUreyBradleyAngles() { return urey_bradley_angles_.size(); }
386 
387  uint GetNumPeriodicDihedrals() { return periodic_dihedrals_.size(); }
388 
389  uint GetNumPeriodicImpropers() { return periodic_impropers_.size(); }
390 
391  uint GetNumHarmonicImpropers() { return harmonic_impropers_.size(); }
392 
393  uint GetNumCMaps() { return cmaps_.size(); }
394 
395  uint GetNumLJPairs() { return lj_pairs_.size(); }
396 
397  uint GetNumDistanceConstraints() { return distance_constraints_.size(); }
398 
399  uint GetNumPositionConstraints() { return position_constraints_.size(); }
400 
401  uint GetNumHarmonicPositionRestraints() { return harmonic_position_restraints_.size(); }
402 
403  uint GetNumHarmonicDistanceRestraints() { return harmonic_distance_restraints_.size();}
404 
405  uint GetNumExclusions() { return exclusions_.size(); }
406 
407  uint GetNumFGMDHBondDonors() { return fgmd_hbond_donors_.size(); }
408 
409  uint GetNumFGMDHBondAcceptors() { return fgmd_hbond_acceptors_.size(); }
410 
411  void Merge(ost::mol::EntityHandle& ent, TopologyPtr other, const ost::mol::EntityHandle& other_ent);
412 
413  void Merge(TopologyPtr other);
414 
415  template <typename DS>
416  void Serialize(DS& ds){
417 
418 
419  uint num_items = 0;
420  Index<2> actual_index;
421 
422  ds & num_particles_;
423  ds & fudge_qq_;
424  ds & fudge_lj_;
425 
426  if(ds.IsSource()){
427  ds & num_items;
428  atom_masses_ = std::vector<Real>(num_items);
429  ds & num_items;
430  sigmas_ = std::vector<Real>(num_items);
431  ds & num_items;
432  epsilons_ = std::vector<Real>(num_items);
433  ds & num_items;
434  gbsa_radii_ = std::vector<Real>(num_items);
435  ds & num_items;
436  obc_scaling_ = std::vector<Real>(num_items);
437  ds & num_items;
438  charges_ = std::vector<Real>(num_items);
439  ds & num_items;
440  position_constraints_ = std::vector<uint>(num_items);
441  }
442  else{
443  num_items = atom_masses_.size();
444  ds & num_items;
445  num_items = sigmas_.size();
446  ds & num_items;
447  num_items = epsilons_.size();
448  ds & num_items;
449  num_items = gbsa_radii_.size();
450  ds & num_items;
451  num_items = obc_scaling_.size();
452  ds & num_items;
453  num_items = charges_.size();
454  ds & num_items;
455  num_items = position_constraints_.size();
456  ds & num_items;
457  }
458 
459  for(std::vector<Real>::iterator i = atom_masses_.begin();
460  i != atom_masses_.end(); ++i){
461  ds & *i;
462  }
463 
464  for(std::vector<Real>::iterator i = sigmas_.begin();
465  i != sigmas_.end(); ++i){
466  ds & *i;
467  }
468 
469  for(std::vector<Real>::iterator i = epsilons_.begin();
470  i != epsilons_.end(); ++i){
471  ds & *i;
472  }
473 
474  for(std::vector<Real>::iterator i = gbsa_radii_.begin();
475  i != gbsa_radii_.end(); ++i){
476  ds & *i;
477  }
478 
479  for(std::vector<Real>::iterator i = obc_scaling_.begin();
480  i != obc_scaling_.end(); ++i){
481  ds & *i;
482  }
483 
484  for(std::vector<Real>::iterator i = charges_.begin();
485  i != charges_.end(); ++i){
486  ds & *i;
487  }
488 
489  for(std::vector<uint>::iterator i = position_constraints_.begin();
490  i != position_constraints_.end(); ++i){
491  ds & *i;
492  }
493 
494  if(ds.IsSource()){
495  ds & num_items;
496  for(uint i = 0; i < num_items; ++i){
497  harmonic_bonds_.push_back(std::make_pair(Index<2>(),std::vector<Real>(2)));
498  }
499 
500  ds & num_items;
501  for(uint i = 0; i < num_items; ++i){
502  harmonic_angles_.push_back(std::make_pair(Index<3>(),std::vector<Real>(2)));
503  }
504 
505  ds & num_items;
506  for(uint i = 0; i < num_items; ++i){
507  urey_bradley_angles_.push_back(std::make_pair(Index<3>(),std::vector<Real>(4)));
508  }
509 
510  ds & num_items;
511  for(uint i = 0; i < num_items; ++i){
512  periodic_dihedrals_.push_back(std::make_pair(Index<4>(),std::vector<Real>(3)));
513  }
514 
515  ds & num_items;
516  for(uint i = 0; i < num_items; ++i){
517  periodic_impropers_.push_back(std::make_pair(Index<4>(),std::vector<Real>(3)));
518  }
519 
520  ds & num_items;
521  for(uint i = 0; i < num_items; ++i){
522  harmonic_impropers_.push_back(std::make_pair(Index<4>(),std::vector<Real>(2)));
523  }
524 
525  ds & num_items;
526  for(uint i = 0; i < num_items; ++i){
527  uint num_values = 0;
528  ds & num_values;
529  cmaps_.push_back(std::make_pair(Index<5>(),std::vector<Real>(num_values)));
530  }
531 
532  ds & num_items;
533  for(uint i = 0; i < num_items; ++i){
534  lj_pairs_.push_back(std::make_pair(Index<2>(),std::vector<Real>(2)));
535  }
536 
537  ds & num_items;
538  for(uint i = 0; i < num_items; ++i){
539  distance_constraints_.push_back(std::make_pair(Index<2>(),std::vector<Real>(1)));
540  }
541 
542  ds & num_items;
543  exclusions_ = std::vector<Index<2> >(num_items);
544 
545  ds & num_items;
546  for(uint i = 0; i < num_items; ++i){
547  harmonic_position_restraints_.push_back(std::make_pair(Index<1>(),std::vector<Real>(7)));
548  }
549 
550  ds & num_items;
551  for(uint i = 0; i < num_items; ++i){
552  harmonic_distance_restraints_.push_back(std::make_pair(Index<2>(),std::vector<Real>(2)));
553  }
554 
555  ds & num_items;
556  for(uint i = 0; i < num_items; ++i){
557  fgmd_hbond_donors_.push_back(std::make_pair(Index<2>(),std::vector<Real>(6)));
558  }
559 
560  ds & num_items;
561  for(uint i = 0; i < num_items; ++i){
562  fgmd_hbond_acceptors_.push_back(Index<2>());
563  }
564  }
565  else{
566  num_items = harmonic_bonds_.size();
567  ds & num_items;
568  num_items = harmonic_angles_.size();
569  ds & num_items;
570  num_items = urey_bradley_angles_.size();
571  ds & num_items;
572  num_items = periodic_dihedrals_.size();
573  ds & num_items;
574  num_items = periodic_impropers_.size();
575  ds & num_items;
576  num_items = harmonic_impropers_.size();
577  ds & num_items;
578  num_items = cmaps_.size();
579  ds & num_items;
580  for(uint i = 0; i < cmaps_.size(); ++i){
581  num_items = cmaps_[i].second.size();
582  ds & num_items;
583  }
584  num_items = lj_pairs_.size();
585  ds & num_items;
586  num_items = distance_constraints_.size();
587  ds & num_items;
588  num_items = exclusions_.size();
589  ds & num_items;
590  num_items = harmonic_position_restraints_.size();
591  ds & num_items;
592  num_items = harmonic_distance_restraints_.size();
593  ds & num_items;
594  num_items = fgmd_hbond_donors_.size();
595  ds & num_items;
596  num_items = fgmd_hbond_acceptors_.size();
597  ds & num_items;
598  }
599 
600  for(std::vector<std::pair<Index<2>,std::vector<Real> > >::iterator i = harmonic_bonds_.begin();
601  i != harmonic_bonds_.end(); ++i){
602  ds & i->first;
603  ds & i->second[0];
604  ds & i->second[1];
605  }
606 
607  for(std::vector<std::pair<Index<3>,std::vector<Real> > >::iterator i = harmonic_angles_.begin();
608  i != harmonic_angles_.end(); ++i){
609  ds & i->first;
610  ds & i->second[0];
611  ds & i->second[1];
612  }
613 
614  for(std::vector<std::pair<Index<3>,std::vector<Real> > >::iterator i = urey_bradley_angles_.begin();
615  i != urey_bradley_angles_.end(); ++i){
616  ds & i->first;
617  ds & i->second[0];
618  ds & i->second[1];
619  ds & i->second[2];
620  ds & i->second[3];
621  }
622 
623  for(std::vector<std::pair<Index<4>,std::vector<Real> > >::iterator i = periodic_dihedrals_.begin();
624  i != periodic_dihedrals_.end(); ++i){
625  ds & i->first;
626  ds & i->second[0];
627  ds & i->second[1];
628  ds & i->second[2];
629  }
630 
631  for(std::vector<std::pair<Index<4>,std::vector<Real> > >::iterator i = periodic_impropers_.begin();
632  i != periodic_impropers_.end(); ++i){
633  ds & i->first;
634  ds & i->second[0];
635  ds & i->second[1];
636  ds & i->second[2];
637  }
638 
639  for(std::vector<std::pair<Index<4>,std::vector<Real> > >::iterator i = harmonic_impropers_.begin();
640  i != harmonic_impropers_.end(); ++i){
641  ds & i->first;
642  ds & i->second[0];
643  ds & i->second[1];
644  }
645 
646  for(std::vector<std::pair<Index<5>,std::vector<Real> > >::iterator i = cmaps_.begin();
647  i != cmaps_.end(); ++i){
648  ds & i->first;
649  for(std::vector<Real>::iterator j = i->second.begin();
650  j != i->second.end(); ++j){
651  ds & (*j);
652  }
653  }
654 
655  for(std::vector<std::pair<Index<2>,std::vector<Real> > >::iterator i = lj_pairs_.begin();
656  i != lj_pairs_.end(); ++i){
657  ds & i->first;
658  ds & i->second[0];
659  ds & i->second[1];
660  }
661 
662  for(std::vector<std::pair<Index<2>,std::vector<Real> > >::iterator i = distance_constraints_.begin();
663  i != distance_constraints_.end(); ++i){
664  ds & i->first;
665  ds & i->second[0];
666  }
667 
668  for(std::vector<Index<2> >::iterator i = exclusions_.begin();
669  i != exclusions_.end(); ++i){
670  ds & (*i);
671  }
672 
673  for(std::vector<std::pair<Index<1>,std::vector<Real> > >::iterator i = harmonic_position_restraints_.begin();
674  i != harmonic_position_restraints_.end(); ++i){
675  ds & i->first;
676  ds & i->second[0];
677  ds & i->second[1];
678  ds & i->second[2];
679  ds & i->second[3];
680  ds & i->second[4];
681  ds & i->second[5];
682  ds & i->second[6];
683  }
684 
685  for(std::vector<std::pair<Index<2>,std::vector<Real> > >::iterator i = harmonic_distance_restraints_.begin();
686  i != harmonic_distance_restraints_.end(); ++i){
687  ds & i->first;
688  ds & i->second[0];
689  ds & i->second[1];
690  }
691 
692  for(std::vector<std::pair<Index<2>,std::vector<Real> > >::iterator i = fgmd_hbond_donors_.begin();
693  i != fgmd_hbond_donors_.end(); ++i){
694  ds & i->first;
695  ds & i->second[0];
696  ds & i->second[1];
697  ds & i->second[2];
698  ds & i->second[3];
699  ds & i->second[4];
700  ds & i->second[5];
701  }
702 
703  for(std::vector<Index<2> >::iterator i = fgmd_hbond_acceptors_.begin();
704  i != fgmd_hbond_acceptors_.end(); ++i){
705  ds & (*i);
706  }
707 
708  if(ds.IsSource()){
709  ds & num_items;
710  for(uint i = 0; i < num_items; ++i){
711  ds & actual_index;
712  added_lj_pairs_.insert(actual_index);
713  }
714 
715  ds & num_items;
716  for(uint i = 0; i < num_items; ++i){
717  ds & actual_index;
718  added_distance_constraints_.insert(actual_index);
719  }
720 
721  ds & num_items;
722  for(uint i = 0; i < num_items; ++i){
723  ds & actual_index;
724  added_exclusions_.insert(actual_index);
725  }
726  }
727  else{
728  num_items = added_lj_pairs_.size();
729  ds & num_items;
730  for(std::set<Index<2> >::iterator i = added_lj_pairs_.begin();
731  i != added_lj_pairs_.end(); ++i){
732  actual_index = *i;
733  ds & actual_index;
734  }
735  num_items = added_distance_constraints_.size();
736  ds & num_items;
737  for(std::set<Index<2> >::iterator i = added_distance_constraints_.begin();
738  i != added_distance_constraints_.end(); ++i){
739  actual_index = *i;
740  ds & actual_index;
741  }
742  num_items = added_exclusions_.size();
743  ds & num_items;
744  for(std::set<Index<2> >::iterator i = added_exclusions_.begin();
745  i != added_exclusions_.end(); ++i){
746  actual_index = *i;
747  ds & actual_index;
748  }
749  }
750  }
751 
752 private:
753 
754  void MergeTop(TopologyPtr other);
755 
756  void MergeEnt(ost::mol::EntityHandle& ent, const ost::mol::EntityHandle& other_ent);
757 
758  void CheckTopToAdd(TopologyPtr other);
759 
760  void CheckEntToAdd(ost::mol::EntityHandle& ent, TopologyPtr other,
761  const ost::mol::EntityHandle& other_ent);
762 
763  uint num_particles_;
764 
765  //fudge parameters for lj 1,4 pairs
766  Real fudge_qq_;
767  Real fudge_lj_;
768 
769  //single atom parameters
770  std::vector<Real> atom_masses_;
771  std::vector<Real> sigmas_;
772  std::vector<Real> epsilons_;
773  std::vector<Real> gbsa_radii_;
774  std::vector<Real> obc_scaling_;
775  std::vector<Real> charges_;
776  std::vector<uint> position_constraints_;
777 
778  //interactions with multiple atoms involved
779  std::vector<std::pair<Index<2>,std::vector<Real> > > harmonic_bonds_;
780  std::vector<std::pair<Index<3>,std::vector<Real> > > harmonic_angles_;
781  std::vector<std::pair<Index<3>,std::vector<Real> > > urey_bradley_angles_;
782  std::vector<std::pair<Index<4>,std::vector<Real> > > periodic_dihedrals_;
783  std::vector<std::pair<Index<4>,std::vector<Real> > > periodic_impropers_;
784  std::vector<std::pair<Index<4>,std::vector<Real> > > harmonic_impropers_;
785  std::vector<std::pair<Index<5>,std::vector<Real> > > cmaps_;
786  std::vector<std::pair<Index<2>,std::vector<Real> > > lj_pairs_;
787  std::vector<std::pair<Index<2>,std::vector<Real> > > distance_constraints_;
788  std::vector<Index<2> > exclusions_;
789  std::vector<std::pair<Index<1>,std::vector<Real> > > harmonic_position_restraints_;
790  std::vector<std::pair<Index<2>,std::vector<Real> > > harmonic_distance_restraints_;
791  std::vector<std::pair<Index<2>,std::vector<Real> > > fgmd_hbond_donors_;
792  std::vector<Index<2> > fgmd_hbond_acceptors_;
793 
794  //the atoms of the interactions, that should be unique get tracked in here
795  //note, that this is waste of memory, needs better implementation
796  std::set<Index<2> > added_lj_pairs_;
797  std::set<Index<2> > added_distance_constraints_;
798  std::set<Index<2> > added_exclusions_;
799 };
800 
801 
802 }}} //ns
803 
804 #endif
void GetLJPairParameters(uint index, uint &index_one, uint &index_two, Real &sigma, Real &epsilon) const
void SetEpsilon(uint index, Real epsilon)
const std::vector< std::pair< Index< 2 >, std::vector< Real > > > & GetLJPairs() const
Definition: topology.hh:259
uint GetNumPeriodicDihedrals()
Definition: topology.hh:387
void SetUreyBradleyAngleParameters(uint index, const Real angle, const Real angle_force_constant, const Real bond_length, const Real bond_force_constant)
void SetMass(uint index, Real mass)
uint AddPeriodicImproper(uint index_one, uint index_two, uint index_three, uint index_four, int multiplicity, Real phase, Real force_constant)
void SetFudgeQQ(Real fudge)
Definition: topology.hh:171
std::vector< uint > GetPeriodicImproperIndices(uint index_one, uint index_two, uint index_three, uint index_four) const
uint AddHarmonicBond(uint index_one, uint index_two, Real bond_length, Real force_constant)
uint GetNumPositionConstraints()
Definition: topology.hh:399
void Serialize(DS &ds)
Definition: topology.hh:416
Real GetEpsilon(uint index) const
int GetLJPairIndex(uint index_one, uint index_two) const
const std::vector< std::pair< Index< 2 >, std::vector< Real > > > & GetFGMDHBondDonors() const
Definition: topology.hh:271
std::vector< Real > GetMasses() const
Definition: topology.hh:298
void SetEpsilons(const std::vector< Real > &epsilons)
uint AddLJPair(uint index_one, uint index_two, Real sigma, Real epsilon)
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
const std::vector< std::pair< Index< 3 >, std::vector< Real > > > & GetUreyBradleyAngles() const
Definition: topology.hh:249
uint GetNumFGMDHBondAcceptors()
Definition: topology.hh:409
const std::vector< std::pair< Index< 4 >, std::vector< Real > > > & GetPeriodicImpropers() const
Definition: topology.hh:253
boost::shared_ptr< Topology > TopologyPtr
Definition: topology.hh:48
uint AddFGMDHBondAcceptor(uint index_one, uint index_two)
std::vector< uint > GetHarmonicDistanceRestraintIndices(uint index_one, uint index_two) const
Real GetCharge(uint index) const
uint GetNumHarmonicDistanceRestraints()
Definition: topology.hh:403
std::vector< uint > GetFGMDHBondDonorIndices(uint index_one, uint index_two) const
uint GetNumDistanceConstraints()
Definition: topology.hh:397
const std::vector< std::pair< Index< 1 >, std::vector< Real > > > & GetHarmonicPositionRestraints() const
Definition: topology.hh:263
void SetGBSARadius(uint index, Real radius)
const std::vector< std::pair< Index< 5 >, std::vector< Real > > > & GetCMaps() const
Definition: topology.hh:257
void SetFGMDHBondDonorParameters(uint index, Real length, Real k_length, Real alpha, Real k_alpha, Real beta, Real k_beta)
void SetSigmas(const std::vector< Real > &sigmas)
void GetFGMDHBondAcceptorParameters(uint index, uint &index_one, uint &index_two) const
void SetOBCScalings(const std::vector< Real > &obc_scaling)
uint AddPeriodicDihedral(uint index_one, uint index_two, uint index_three, uint index_four, int multiplicity, Real phase, Real force_constant)
void SetCharges(const std::vector< Real > &charges)
std::vector< uint > GetCMapIndices(uint index_one, uint index_two, uint index_three, uint index_four, uint index_five) const
std::vector< uint > GetUreyBradleyAngleIndices(uint index_one, uint index_two, uint index_three) const
const std::vector< std::pair< Index< 2 >, std::vector< Real > > > & GetHarmonicDistanceRestraints() const
Definition: topology.hh:265
const std::vector< uint > & GetPositionConstraints() const
Definition: topology.hh:269
void SetCharge(uint index, Real charge)
std::vector< Real > GetCharges() const
Definition: topology.hh:284
Protein or molecule.
uint AddHarmonicImproper(uint index_one, uint index_two, uint index_three, uint index_four, Real angle, Real force_constant)
void GetPeriodicImproperParameters(uint index, uint &index_one, uint &index_two, uint &index_three, uint &index_four, int &multiplicity, Real &phase, Real &force_constant) const
void AddPositionConstraint(uint index)
void GetHarmonicImproperParameters(uint index, uint &index_one, uint &index_two, uint &index_three, uint &index_four, Real &angle, Real &force_constant) const
std::vector< uint > GetLJPairIndices(uint atom_index) const
const std::vector< std::pair< Index< 2 >, std::vector< Real > > > & GetHarmonicBonds() const
Definition: topology.hh:245
void SetPeriodicImproperParameters(uint index, const int multiplicity, const Real phase, const Real force_constant)
void SetHarmonicPositionRestraintParameters(uint index, const geom::Vec3 &ref_position, Real k, Real x_scale=1.0, Real y_scale=1.0, Real z_scale=1.0)
void SetGBSARadii(const std::vector< Real > &gbsa_radii)
void SetFudgeLJ(Real fudge)
Definition: topology.hh:173
void GetDistanceConstraintParameters(uint index, uint &index_one, uint &index_two, Real &distance) const
Real GetFudgeLJ() const
Definition: topology.hh:302
uint AddHarmonicAngle(uint index_one, uint index_two, uint index_three, Real angle, Real force_constant)
const std::vector< std::pair< Index< 2 >, std::vector< Real > > > & GetDistanceConstraints() const
Definition: topology.hh:261
const std::vector< std::pair< Index< 4 >, std::vector< Real > > > & GetHarmonicImpropers() const
Definition: topology.hh:255
Real GetGBSARadius(uint index) const
Real GetMass(uint index) const
void Merge(ost::mol::EntityHandle &ent, TopologyPtr other, const ost::mol::EntityHandle &other_ent)
void GetUreyBradleyAngleParameters(uint index, uint &index_one, uint &index_two, uint &index_three, Real &angle, Real &angle_force_constant, Real &bond_length, Real &bond_force_constant) const
uint AddExclusion(uint index_one, uint index_two)
void ResetPositionConstraints()
Definition: topology.hh:130
void SetHarmonicDistanceRestraintParameters(uint index, Real length, Real force_constant)
uint GetNumFGMDHBondDonors()
Definition: topology.hh:407
void GetCMapParameters(uint index, uint &index_one, uint &index_two, uint &index_three, uint &index_four, uint &index_five, int &dimension, std::vector< Real > &map) const
uint AddFGMDHBondDonor(uint index_one, uint index_two, Real length, Real k_length, Real alpha, Real k_alpha, Real beta, Real k_beta)
uint AddHarmonicPositionRestraint(uint index, const geom::Vec3 &ref_position, Real k, Real x_scale=1.0, Real y_scale=1.0, Real z_scale=1.0)
void SetHarmonicImproperParameters(uint index, const Real angle, const Real force_constant)
const std::vector< Index< 2 > > & GetFGMDHBondAcceptors() const
Definition: topology.hh:273
uint AddHarmonicDistanceRestraint(uint index_one, uint index_two, Real length, Real force_constant)
std::vector< uint > GetHarmonicBondIndices(uint index_one, uint index_two) const
uint AddCMap(uint index_one, uint index_two, uint index_three, uint index_four, uint index_five, int dimension, std::vector< Real > values)
std::vector< uint > GetHarmonicAngleIndices(uint index_one, uint index_two, uint index_three) const
void SetMasses(const std::vector< Real > &masses)
std::vector< uint > GetPeriodicDihedralIndices(uint index_one, uint index_two, uint index_three, uint index_four) const
std::vector< uint > GetFGMDHBondAcceptorIndices(uint index_one, uint index_two) const
const std::vector< Index< 2 > > & GetExclusions() const
Definition: topology.hh:267
void SetDistanceConstraintParameters(uint index, const Real distance)
Three dimensional vector class, using Real precision.
Definition: vec3.hh:43
void GetPeriodicDihedralParameters(uint index, uint &index_one, uint &index_two, uint &index_three, uint &index_four, int &multiplicity, Real &phase, Real &force_constant) const
Real GetSigma(uint index) const
std::vector< Real > GetEpsilons() const
Definition: topology.hh:278
int GetDistanceConstraintIndex(uint index_one, uint index_two) const
uint GetNumHarmonicPositionRestraints()
Definition: topology.hh:401
void GetHarmonicAngleParameters(uint index, uint &index_one, uint &index_two, uint &index_three, Real &angle, Real &force_constant) const
Real GetFudgeQQ() const
Definition: topology.hh:300
void GetFGMDHBondDonorParameters(uint index, uint &index_one, uint &index_two, Real &length, Real &k_length, Real &alpha, Real &k_alpha, Real &beta, Real &k_beta) const
void GetHarmonicDistanceRestraintParameters(uint index, uint &atom_one, uint &atom_two, Real &length, Real &force_constant) const
uint GetNumPeriodicImpropers()
Definition: topology.hh:389
std::vector< uint > GetDistanceConstraintIndices(uint atom_index) const
std::vector< uint > GetHarmonicPositionRestraintIndices(uint atom_index) const
void SetOBCScaling(uint index, Real scaling)
uint AddDistanceConstraint(uint index_one, uint index_two, Real distance)
void SetHarmonicAngleParameters(uint index, const Real angle, const Real force_constant)
std::vector< Real > GetOBCScalings() const
Definition: topology.hh:282
const std::vector< std::pair< Index< 4 >, std::vector< Real > > > & GetPeriodicDihedrals() const
Definition: topology.hh:251
void SetHarmonicBondParameters(uint index, const Real bond_length, const Real force_constant)
uint AddUreyBradleyAngle(uint index_one, uint index_two, uint index_three, Real angle, Real angle_force_constant, Real bond_length, Real bond_force_constant)
static TopologyPtr Load(const String &filename)
const std::vector< std::pair< Index< 3 >, std::vector< Real > > > & GetHarmonicAngles() const
Definition: topology.hh:247
uint GetNumHarmonicImpropers()
Definition: topology.hh:391
Real GetOBCScaling(uint index) const
void SetCMapParameters(uint index, const int dimension, const std::vector< Real > &map)
void SetSigma(uint index, Real sigma)
void SetPeriodicDihedralParameters(uint index, const int multiplicity, const Real phase, const Real force_constant)
std::vector< uint > GetHarmonicImproperIndices(uint index_one, uint index_two, uint index_three, uint index_four) const
void GetHarmonicPositionRestraintParameters(uint index, uint &atom_index, geom::Vec3 &ref_position, Real &k, Real &x_scale, Real &y_scale, Real &z_scale) const
uint GetNumUreyBradleyAngles()
Definition: topology.hh:385
std::vector< Real > GetGBSARadii() const
Definition: topology.hh:280
void GetHarmonicBondParameters(uint index, uint &index_one, uint &index_two, Real &bond_length, Real &force_constant) const
void SetLJPairParameters(uint index, const Real sigma, const Real epsilon)
void Save(const String &filename)
unsigned int uint
Definition: base.hh:29
std::vector< Real > GetSigmas() const
Definition: topology.hh:276