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