IMP logo
IMP Reference Guide  develop.7cb8855c60,2024/10/04
The Integrative Modeling Platform
pmi/utilities.h
Go to the documentation of this file.
1 /**
2  * \file IMP/pmi/utilities.h
3  * \brief Useful utilities
4  *
5  * Copyright 2007-2022 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 #include <IMP/atom/Hierarchy.h>
16 #include <IMP/atom/Molecule.h>
17 #include <IMP/atom/Copy.h>
18 #include <IMP/atom/Selection.h>
19 #include <IMP/core/internal/dihedral_helpers.h>
20 #include <IMP/Vector.h>
21 #include <boost/lexical_cast.hpp>
22 
23 IMPPMI_BEGIN_NAMESPACE
24 
25 //! Create an elastic network restraint set
27  Float dist_cutoff,
28  Float strength){
29  IMP_NEW(RestraintSet,rs,(ps[0]->get_model(),"ElasticNetwork"));
30  int nps=ps.size();
31  for (int n1=0;n1<nps;n1++){
32  for (int n2=n1+1;n2<nps;n2++){
33  Float dist = core::get_distance(core::XYZ(ps[n1]),
34  core::XYZ(ps[n2]));
35  if (dist<dist_cutoff){
37  (dist,strength));
39  ParticlePair(ps[n1],ps[n2]));
40  rs->add_restraint(rx);
41  }
42  }
43  }
44  return rs.release();
45 }
46 
47 Float get_dihedral_angle(const atom::Atom &p1,
48  const atom::Atom &p2,
49  const atom::Atom &p3,
50  const atom::Atom &p4){
51  return core::internal::dihedral(p1,p2,p3,p4,nullptr,nullptr,nullptr,nullptr);
52 }
53 
54 inline Float get_bipartite_minimum_sphere_distance(const IMP::core::XYZRs& m1,
55  const IMP::core::XYZRs& m2) {
56 
57  double mindist = -1.0 ;
58 
59  for (unsigned int k1 = 0; k1 < m1.size(); ++k1) {
60  for (unsigned int k2 = 0; k2 < m2.size(); ++k2) {
61  double dist = IMP::core::get_distance(m1[k1],m2[k2]);
62  if (mindist < 0.0){mindist=dist;}
63  if (mindist > dist){mindist=dist;}
64  }
65  }
66  if (mindist < 0 ){mindist = 0;}
67  return mindist;
68 }
69 
70 
71 inline Floats get_list_of_bipartite_minimum_sphere_distance(const ParticlesTemps & pss) {
72  Floats mindistances;
73  for (unsigned int k1 = 0; k1 < pss.size()-1; ++k1) {
74  for (unsigned int k2 = k1+1; k2 < pss.size(); ++k2) {
75  IMP::core::XYZRs xyzrs1=IMP::core::XYZRs(pss[k1]);
76  IMP::core::XYZRs xyzrs2=IMP::core::XYZRs(pss[k2]);
77  double dist = IMP::pmi::get_bipartite_minimum_sphere_distance(xyzrs1,xyzrs2);
78  mindistances.push_back(dist);
79  }
80  }
81  return mindistances;
82 }
83 
84 //! Walk up a PMI2 hierarchy/representations and get the "molname.copynum"
86  return atom::get_molecule_name(h) + "." +
87  boost::lexical_cast<std::string>(atom::get_copy_index(h));
88 }
89 
90 IMPPMI_END_NAMESPACE
91 
92 #endif /* IMPPMI_UTILITIES_H */
Restraint * create_restraint(Score *s, const typename Score::Argument &t, std::string name=std::string())
Definition: generic.h:36
Distance restraint between two particles.
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
Definition: types.h:46
Score distance between two particle centers using a harmonic function.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
A decorator for Molecules.
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Object used to hold a set of restraints.
Definition: RestraintSet.h:41
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Definition: object_macros.h:74
Decorator for helping deal with a hierarchy of molecules.
std::string get_molecule_name_and_copy(atom::Hierarchy h)
Walk up a PMI2 hierarchy/representations and get the "molname.copynum".
Definition: pmi/utilities.h:85
The standard decorator for manipulating molecular structures.
RestraintSet * create_elastic_network(const Particles &ps, Float dist_cutoff, Float strength)
Create an elastic network restraint set.
Definition: pmi/utilities.h:26
A decorator for a particle representing an atom.
Definition: atom/Atom.h:238
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
A class for storing lists of IMP items.
A Score on the distance between a pair of particles.
std::string get_molecule_name(Hierarchy h)
Array< 2, WeakPointer< Particle >, Particle * > ParticlePair
Definition: base_types.h:159
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
A decorator for keeping track of copies of a molecule.
int get_copy_index(Hierarchy h)
Walk up the hierarchy to find the current copy index.
Decorator for a sphere-like particle.
double get_distance(const Surface &s, const XYZR &d)
Get distance from sphere to surface.
Definition: Surface.h:153
Select a subset of a hierarchy.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.