IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
23IMPPMI_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
47Float 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
54inline 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
71inline 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
90IMPPMI_END_NAMESPACE
91
92#endif /* IMPPMI_UTILITIES_H */
A decorator for keeping track of copies of a molecule.
Distance restraint between two particles.
A decorator for Molecules.
Select a subset of a hierarchy.
A class for storing lists of IMP items.
Decorator for a sphere-like particle.
Decorator for helping deal with a hierarchy of molecules.
Object used to hold a set of restraints.
A decorator for a particle representing an atom.
Definition Atom.h:238
The standard decorator for manipulating molecular structures.
Score distance between two particle centers using a harmonic function.
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
A Score on the distance between a pair of particles.
std::string get_molecule_name(Hierarchy h)
int get_copy_index(Hierarchy h)
Walk up the hierarchy to find the current copy index.
double get_distance(const Surface &s, const XYZR &d)
Get distance from sphere to surface.
Definition Surface.h:153
std::string get_molecule_name_and_copy(atom::Hierarchy h)
Walk up a PMI2 hierarchy/representations and get the "molname.copynum".
RestraintSet * create_elastic_network(const Particles &ps, Float dist_cutoff, Float strength)
Create an elastic network restraint set.
Vector< Pointer< Particle > > Particles
A list of reference-counted Particle objects.
Definition base_types.h:138
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
Restraint * create_restraint(Score *s, const typename Score::Argument &t, std::string name=std::string())
Definition generic.h:36
Array< 2, WeakPointer< Particle >, Particle * > ParticlePair
Definition base_types.h:180
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
Definition types.h:46
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
A smart pointer to a reference counted object.
Definition Pointer.h:88