IMP  2.4.0
The Integrative Modeling Platform
utilities.h
Go to the documentation of this file.
1 /**
2  * \file IMP/pmi/utilities.h
3  * \brief Useful utilities
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPPMI_UTILITIES_H
9 #define IMPPMI_UTILITIES_H
10 
11 #include <IMP/pmi/pmi_config.h>
14 #include <IMP/core/XYZR.h>
15 
16 IMPPMI_BEGIN_NAMESPACE
17 
18 //! Create an elastic network restraint set
19 RestraintSet * create_elastic_network(const Particles &ps,
20  Float dist_cutoff,
21  Float strength){
22  IMP_NEW(RestraintSet,rs,(ps[0]->get_model(),"ElasticNetwork"));
23  int nps=ps.size();
24  for (int n1=0;n1<nps;n1++){
25  for (int n2=n1+1;n2<nps;n2++){
26  Float dist = core::get_distance(core::XYZ(ps[n1]),
27  core::XYZ(ps[n2]));
28  if (dist<dist_cutoff){
30  (dist,strength));
32  ParticlePair(ps[n1],ps[n2]));
33  rs->add_restraint(rx);
34  }
35  }
36  }
37  return rs.release();
38 }
39 
40 
41 IMPPMI_END_NAMESPACE
42 
43 #endif /* IMPPMI_UTILITIES_H */
Distance restraint between two particles.
Object used to hold a set of restraints.
A smart pointer to a reference counted object.
Definition: Pointer.h:87
base::Array< 2, base::WeakPointer< Particle >, Particle * > ParticlePair
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Definition: object_macros.h:72
double get_distance(const Plane3D &pln, const Vector3D &p)
Return the distance between a plane and a point in 3D.
Definition: Plane3D.h:71
RestraintSet * create_elastic_network(const Particles &ps, Float dist_cutoff, Float strength)
Create an elastic network restraint set.
Definition: utilities.h:19
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
A Score on the distance between a pair of particles.
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Decorator for a sphere-like particle.
kernel::Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())