IMP  2.0.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-2013 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 class IMPMULTIFITEXPORT ProbabilisticAnchorGraph : public IMP::base::Object {
21 // Property types
22 typedef boost::property<boost::edge_weight_t, float> EdgeWeightProperty;
23 typedef boost::property<boost::vertex_index_t, int> VertexIndexProperty;
24 // Graph type
25 typedef boost::adjacency_list<boost::vecS, boost::vecS,
26  boost::undirectedS,
27  VertexIndexProperty,
28  EdgeWeightProperty> AnchorGraph;
29 typedef boost::graph_traits<AnchorGraph> GTraits;
30 typedef boost::graph_traits<AnchorGraph const> Const_GTraits;
31 typedef GTraits::vertex_descriptor GVertex;
32 typedef GTraits::edge_descriptor GEdge;
33 public:
34  ProbabilisticAnchorGraph(algebra::Vector3Ds anchor_positions);
35 
36  void add_edge(int i,int j) {
37  boost::add_edge(id2node_[i],id2node_[j],g_);
38  }
39  //! Set the probability of a component to be located at each anchor position
40  /**
41  \param[in] comp_ind the component index
42  \param[in] comp_cen the position of the component centroid
43  \param[in] sols the fitting solutions of the component
44  */
45  void set_particle_probabilities_on_anchors(
46  Particle *p,
48  void show(std::ostream& out=std::cout) const;
49  unsigned int get_number_of_anchors() const {return boost::num_vertices(g_);}
50  unsigned int get_number_of_edges() const {return boost::num_edges(g_);}
51  IntRanges get_edge_list() const;
52  algebra::Vector3Ds get_anchors() const {return positions_;}
53  algebra::Vector3Ds get_particle_anchors(Particle *p,float min_prob=0) const;
54  bool get_are_probabilities_for_particle_set(Particle *p) const {
55  return particle_to_anchor_probabilities_.find(p) !=
56  particle_to_anchor_probabilities_.end();
57  }
58  Floats get_particle_probabilities(Particle *p) const;
59  IMP_OBJECT_INLINE(ProbabilisticAnchorGraph, show(out),{});
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 
67 IMP_OBJECTS(ProbabilisticAnchorGraph,ProbabilisticAnchorGraphs);
68 IMPMULTIFIT_END_NAMESPACE
69 #endif /* IMPMULTIFIT_ANCHOR_GRAPH_H */