12 #ifndef IMPCORE_MS_CONNECTIVITY_RESTRAINT_H
13 #define IMPCORE_MS_CONNECTIVITY_RESTRAINT_H
17 #include <IMP/core/core_config.h>
24 IMPCORE_BEGIN_NAMESPACE
29 #define IMP_GCC_VERSION \
30 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
31 #if IMP_GCC_VERSION >= 40100
32 #define IMPCORE_FRIEND_IS_OK
36 #define IMPCORE_FRIEND_IS_OK
76 unsigned int add_composite(
const Ints &components);
77 unsigned int add_composite(
const Ints &components,
unsigned int parent);
102 #ifdef IMPCORE_FRIEND_IS_OK
107 class ParticleMatrix {
111 ParticleData(
Particle *p,
unsigned int id)
112 : particle_(p), id_(id) {}
114 Particle *get_particle()
const {
return particle_; }
116 unsigned int get_id()
const {
return id_; }
123 ParticleMatrix(
unsigned int number_of_classes)
124 : protein_by_class_(number_of_classes),
125 min_distance_(std::numeric_limits<double>::max()),
130 : min_distance_(std::numeric_limits<double>::max()),
134 void resize(
unsigned int number_of_classes) {
135 protein_by_class_.resize(number_of_classes);
138 unsigned int add_particle(Particle *p,
unsigned int id);
139 unsigned int add_type(
const ParticlesTemp &ps);
140 void create_distance_matrix(
const PairScore *ps);
141 void clear_particles() {
143 for (
unsigned int i = 0; i < protein_by_class_.size(); ++i)
144 protein_by_class_[i].clear();
146 unsigned int size()
const {
return particles_.size(); }
147 unsigned int get_number_of_classes()
const {
148 return protein_by_class_.size();
150 double get_distance(
unsigned int p1,
unsigned int p2)
const {
151 return dist_matrix_[p1 * size() + p2];
153 Ints const &get_ordered_neighbors(
unsigned int p)
const {
156 ParticleData
const &get_particle(
unsigned int p)
const {
157 return particles_[p];
159 Ints const &get_all_proteins_in_class(
unsigned int id)
const {
160 return protein_by_class_[id];
162 double max_distance()
const {
return max_distance_; }
163 double min_distance()
const {
return min_distance_; }
168 DistCompare(
unsigned int source, ParticleMatrix
const &parent)
169 : parent_(parent), source_(source) {}
171 bool operator()(
unsigned int p1,
unsigned int p2)
const {
172 return parent_.get_distance(source_, p1) <
173 parent_.get_distance(source_, p2);
177 ParticleMatrix
const &parent_;
178 unsigned int source_;
181 Vector<ParticleData> particles_;
184 Vector<Ints> protein_by_class_;
185 double min_distance_;
186 double max_distance_;
187 unsigned int current_id_;
190 class ExperimentalTree {
192 ExperimentalTree() : root_(-1), finalized_(false) {}
194 void connect(
unsigned int parent,
unsigned int child);
196 unsigned int add_composite(
const Ints &components);
197 unsigned int add_composite(
const Ints &components,
unsigned int parent);
201 Node() : visited_(false) {}
202 unsigned int get_number_of_parents()
const {
return parents_.size(); }
203 bool is_root()
const {
return get_number_of_parents() == 0; }
204 unsigned int get_number_of_children()
const {
return children_.size(); }
205 bool is_leaf()
const {
return get_number_of_children() == 0; }
206 unsigned int get_parent(
unsigned int idx)
const {
return parents_[idx]; }
207 unsigned int get_child(
unsigned int idx)
const {
return children_[idx]; }
208 typedef Vector<std::pair<unsigned int, int> > Label;
209 const Label &get_label()
const {
return label_; }
211 Vector<unsigned int> parents_;
212 Vector<unsigned int> children_;
217 bool find_cycle(
unsigned int node_index);
218 bool is_consistent(
unsigned int node_index)
const;
220 const Node *get_node(
unsigned int index)
const {
return &nodes_[index]; }
221 unsigned int get_number_of_nodes()
const {
return nodes_.size(); }
222 unsigned int get_root()
const {
return root_; }
223 void desc_to_label(
const Ints &components, Node::Label &label);
229 #endif // IMP_DOXYGEN
231 ParticleMatrix particle_matrix_;
232 mutable ExperimentalTree tree_;
234 friend class MSConnectivityScore;
237 IMPCORE_END_NAMESPACE
Abstract class for scoring object(s) of type ParticleIndexPair.
Distance restraint between two particles.
A container for Singletons.
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual double unprotected_evaluate(DerivativeAccumulator *da) const
Return the unweighted score for the restraint.
void add_particle(RMF::FileHandle fh, Particle *hs)
Class for storing model, its restraints, constraints, and particles.
virtual Restraints do_create_current_decomposition() const
PairScore * get_pair_score() const
Return the pair score used for scoring.
Hierarchy get_root(Hierarchy h)
Return the root of the hierarchy.
Class to handle individual particles of a Model object.
Abstract base class for all restraints.
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Ensure that a set of particles remains connected with one another.
double get_distance(const Line3D &s, const Vector3D &p)
Get closest distance between a line and a point.
virtual ModelObjectsTemp do_get_inputs() const =0
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.