IMP logo
IMP Reference Guide  2.11.0
The Integrative Modeling Platform
anchor_graph.h
Go to the documentation of this file.
1 /**
2  * \file IMP/multifit/anchor_graph.h
3  * \brief anchor graph utilities
4  *
5  * Copyright 2007-2019 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPMULTIFIT_ANCHOR_GRAPH_H
10 #define IMPMULTIFIT_ANCHOR_GRAPH_H
11 
12 #include <boost/graph/adjacency_list.hpp>
13 #include <vector>
14 #include <IMP/algebra/Vector3D.h>
15 #include <IMP/multifit/multifit_config.h>
16 #include "FittingSolutionRecord.h"
17 #include <IMP/Object.h>
18 
19 IMPMULTIFIT_BEGIN_NAMESPACE
20 
21 //! Probabilistic anchor graph.
22 class IMPMULTIFITEXPORT ProbabilisticAnchorGraph : public IMP::Object {
23  // Property types
24  typedef boost::property<boost::edge_weight_t, float> EdgeWeightProperty;
25  typedef boost::property<boost::vertex_index_t, int> VertexIndexProperty;
26  // Graph type
27  typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
28  VertexIndexProperty,
29  EdgeWeightProperty> AnchorGraph;
30  typedef boost::graph_traits<AnchorGraph> GTraits;
31  typedef boost::graph_traits<AnchorGraph const> Const_GTraits;
32  typedef GTraits::vertex_descriptor GVertex;
33  typedef GTraits::edge_descriptor GEdge;
34 
35  public:
37 
38  void add_edge(int i, int j) { boost::add_edge(id2node_[i], id2node_[j], g_); }
39  //! Set the probability of a component to be located at each anchor position
40  /**
41  \param[in] p
42  \param[in] sols the fitting solutions of the component
43  */
44  void set_particle_probabilities_on_anchors(
46  void show(std::ostream &out = std::cout) const;
47  unsigned int get_number_of_anchors() const { return boost::num_vertices(g_); }
48  unsigned int get_number_of_edges() const { return boost::num_edges(g_); }
49  IntRanges get_edge_list() const;
50  algebra::Vector3Ds get_anchors() const { return positions_; }
51  algebra::Vector3Ds get_particle_anchors(Particle *p,
52  float min_prob = 0) const;
53  bool get_are_probabilities_for_particle_set(Particle *p) const {
54  return particle_to_anchor_probabilities_.find(p) !=
55  particle_to_anchor_probabilities_.end();
56  }
57  Floats get_particle_probabilities(Particle *p) const;
59 
60  private:
61  AnchorGraph g_;
62  std::map<Particle *, Floats> particle_to_anchor_probabilities_;
63  algebra::Vector3Ds positions_;
64  std::vector<GVertex> id2node_;
65 };
66 
68 IMPMULTIFIT_END_NAMESPACE
69 #endif /* IMPMULTIFIT_ANCHOR_GRAPH_H */
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Common base class for heavy weight IMP objects.
Definition: Object.h:106
stored a multifit fitting solution
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A shared base class to help in debugging and things.
Simple 3D vector class.
Class to handle individual particles of a Model object.
Definition: Particle.h:41
Probabilistic anchor graph.
Definition: anchor_graph.h:22