IMP  2.0.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-2013 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/file.h>
17 #include <IMP/multifit/multifit_config.h>
18 #include "DataPointsAssignment.h"
19 IMPMULTIFIT_BEGIN_NAMESPACE
20 
21 
22 class IMPMULTIFITEXPORT AnchorsData {
23  public:
24  AnchorsData(){}
25  AnchorsData(algebra::Vector3Ds points, IntPairs edges){
26  points_=points;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  void show(std::ostream& out=std::cout) const {
50  out<<"==== "<<points_.size()<<" Anchors:"<<std::endl;
51  for(int i=0;i<(int)points_.size();i++) {
52  out<<points_[i]<<std::endl;
53  }
54  out<<"===="<<edges_.size()<<" Edges:"<<std::endl;
55  for(int i=0;i<(int)edges_.size();i++) {
56  out<<"("<<edges_[i].first<<","<<edges_[i].second<<") ";
57  }
58  out<<std::endl;
59  }
60 
61 
62  //!Check if secondary structure is setup
63  bool get_secondary_structure_is_set(){
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  protected:
86  Particles secondary_structure_ps_;
87 };
89 
90 IMPMULTIFITEXPORT AnchorsData read_anchors_data(const char *txt_filename);
91 IMPMULTIFITEXPORT
92 void write_txt(const std::string &txt_filename,
93  const AnchorsData &ad);
94 IMPMULTIFITEXPORT
95 void write_cmm(const std::string &cmm_filename,
96  const std::string &marker_set_name,
97  const AnchorsData &dpa);
98 
99 IMPMULTIFIT_END_NAMESPACE
100 #endif /* IMPMULTIFIT_ANCHORS_READER_H */