IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
anchors_reader.h
Go to the documentation of this file.
1 /**
2  * \file IMP/multifit/anchors_reader.h
3  * \brief handles reading of anchors data
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPMULTIFIT_ANCHORS_READER_H
10 #define IMPMULTIFIT_ANCHORS_READER_H
11 
14 #include <IMP/Model.h>
15 #include <IMP/core/Hierarchy.h>
16 #include <IMP/multifit/multifit_config.h>
17 #include "DataPointsAssignment.h"
18 IMPMULTIFIT_BEGIN_NAMESPACE
19 
20 //! Storage of anchors (points and edges)
21 class IMPMULTIFITEXPORT AnchorsData {
22  public:
23  AnchorsData() {}
24  AnchorsData(algebra::Vector3Ds points, IntPairs edges) {
25  points_ = points;
26  edges_ = edges;
27  secondary_structure_ps_ = Particles();
28  // set true to consider all points
29  for (unsigned int i = 0; i < points_.size(); i++) {
30  consider_point_.push_back(true);
31  }
32  }
33 
34  void remove_edges_for_node(int node_ind) {
35  // iterate over edges and remove edges including node_ind
36  IntPairs new_edges;
37  for (int i = 0; i < (int)edges_.size(); i++) {
38  if (!((edges_[i].first == node_ind) || (edges_[i].second == node_ind))) {
39  new_edges.push_back(edges_[i]);
40  }
41  }
42  consider_point_[node_ind] = false;
43  edges_ = new_edges;
44  }
45  int get_number_of_points() const { return points_.size(); }
46  int get_number_of_edges() const { return edges_.size(); }
47  bool get_is_point_considered(int node_ind) const {
48  return consider_point_[node_ind];
49  }
50  void show(std::ostream &out = std::cout) const {
51  out << "==== " << points_.size() << " Anchors:" << std::endl;
52  for (int i = 0; i < (int)points_.size(); i++) {
53  out << points_[i] << std::endl;
54  }
55  out << "====" << edges_.size() << " Edges:" << std::endl;
56  for (int i = 0; i < (int)edges_.size(); i++) {
57  out << "(" << edges_[i].first << "," << edges_[i].second << ") ";
58  }
59  out << std::endl;
60  }
61 
62  //!Check if secondary structure is setup
64  return (secondary_structure_ps_.size() == points_.size());
65  }
66 
67  //!Sets up default secondary structure particles for every anchor (run first)
68  void setup_secondary_structure(Model *mdl);
69 
70  //!Assign secondary structure particles. Provide indices if out of order.
71  /**
72  \param[in] ssres_ps The particles which you will be assigning to anchors
73  \param[in] indices (Optional) List of which anchor point numbers the
74  provided ssres_ps belong to.
75  */
76  void set_secondary_structure_probabilities(const Particles &ssres_ps,
77  const Ints &indices = Ints());
78 
79  inline Particles get_secondary_structure_particles() const {
80  return secondary_structure_ps_;
81  }
82  algebra::Vector3Ds points_;
83  std::vector<bool> consider_point_;
84  IntPairs edges_;
85 
86  protected:
87  Particles secondary_structure_ps_;
88 };
90 
91 IMPMULTIFITEXPORT AnchorsData read_anchors_data(const char *txt_filename);
92 IMPMULTIFITEXPORT
93 void write_txt(const std::string &txt_filename, const AnchorsData &ad);
94 IMPMULTIFITEXPORT
95 void write_cmm(const std::string &cmm_filename,
96  const std::string &marker_set_name, const AnchorsData &dpa);
97 
98 IMPMULTIFIT_END_NAMESPACE
99 #endif /* IMPMULTIFIT_ANCHORS_READER_H */
Decorator for helping deal with a hierarchy.
A decorator for storing secondary structure probabilities. Copyright 2007-2018 IMP Inventors...
bool get_secondary_structure_is_set()
Check if secondary structure is setup.
Storage of anchors (points and edges)
Storage of a model, its restraints, constraints and particles.
Tools for data points assignment, after anchor point segmentation.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Simple 3D transformation class.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition: types.h:49