Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cluster.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 ///
10 /// @author Mike Tyka
11 
12 #ifndef INCLUDED_protocols_cluster_cluster_hh
13 #define INCLUDED_protocols_cluster_cluster_hh
14 
15 #include <core/pose/Pose.hh>
17 #include <protocols/moves/Mover.hh>
18 #include <protocols/loops/Loops.hh>
19 
20 // ObjexxFCL headers
21 #include <ObjexxFCL/FArray2D.hh>
22 
23 // C++ headers
24 #include <iostream>
25 #include <string>
26 #include <deque>
27 #include <vector>
28 #include <algorithm>
29 
30 #include <utility/vector1.hh>
31 
32 
33 namespace protocols {
34 namespace cluster {
35 
39 
41 public:
43 
45  void set_filter( core::Real filter );
46 
47  virtual void apply( core::pose::Pose & pose );
48  virtual std::string get_name() const;
49 
50  bool check_tag( const std::string &query_tag );
51 
52  void push_back( const core::pose::Pose & pose ) {
53  poselist.push_back( pose );
54  }
55 
56  void clear() {
57  poselist.clear();
58  }
59 
60  void set_cluster_by_protein_backbone( bool const & setting ) { cluster_by_protein_backbone_ = setting; }
61 
62  void set_cluster_by_all_atom( bool const & setting ) { cluster_by_all_atom_ = setting; }
63 
64  int processed() const { return processed_; }
65 
66  std::vector< core::pose::Pose > & get_pose_list() { return poselist; }
67 
68  std::vector< std::string > const & get_tag_list() const{ return tag_list; }
69 
70  virtual core::Real
72  const core::pose::Pose & pose1,
73  const core::pose::Pose & pose2
74  ) const;
75 
76 protected:
77  std::vector< core::pose::Pose > poselist;
78 
79 private:
82  std::vector< std::string > tag_list;
85 
86  std::map< std::string, core::Real > template_scores;
87 
89 };
90 
91 
92 
93 // Main base class for making constraints out of groups of structures
94 
98 
100 public:
102 #ifndef BOINC // gives windows build error
103  //EnsembleConstraints* clone() const = 0;
104 #endif
105  virtual void createConstraints( std::ostream &out ) = 0;
106  virtual std::string get_name() const;
107 };
108 
109 
110 
111 // A super simple implementation of the above - jsut create bounds for close CA atoms.
115 
117 public:
119  minimum_width_ = minimum_width;
120  };
121 #ifndef BOINC // gives windows build error
123 #endif
124  virtual void createConstraints( std::ostream &out);
125  virtual std::string get_name() const;
126 
127 protected:
129 };
130 
131 
132 
133 
137 
138 struct Cluster {
139 public:
141  cluster_center_( 1 ),
142  group_size_(0)
143  {
144 
145  }
146 
147  Cluster( int new_cluster_center ):
148  cluster_center_( new_cluster_center ),
149  group_size_(0)
150  {
151  add_member( new_cluster_center );
152  }
153 
154 public:
155 
157  std::deque< int > member;
158  core::Size group_size_; // Log this seperately, because sometimes members are prunned, but its still nice to know what the original size would have been
159 
160 public:
161 
162  int get_cluster_center() const { return cluster_center_; }
163  //void set_cluster_center( int new_cluster_center ) { cluster_center_ = new_cluster_center; }
164 
165  // Actual removing or addition of members
166  void add_member( int new_member ){
167  member.push_back( new_member );
168  group_size_ ++;
169  }
170  void add_member_front( int new_member ){
171  member.push_front( new_member );
172  group_size_ ++;
173  }
174  void remove_member( int old_member ){
175  erase( old_member );
176  group_size_ --;
177  }
178 
179  // Editing operations (they are more crude and dont affect the group_size count )
180  void push_back( int new_member ){ member.push_back( new_member ); }
181  void push_front( int new_member ){ member.push_front( new_member ); }
182  int& operator [] ( int index ){ return member[index]; }
183  int operator [] ( int index ) const { return member[index]; }
184  core::Size size() const { return member.size(); }
185  void clear(){ member.clear(); }
186  void erase( core::Size j ){
187  std::deque< int >::iterator it = member.begin();
188  it += j;
189  member.erase(it);
190  }
191  void shuffle();
192 
194 };
195 
197 public:
198  ClusterBase();
199  virtual std::string get_name() const;
200  void set_cluster_radius( core::Real cluster_radius );
201  void set_population_weight( core::Real population_weight );
202 
205 
207 
208  void add_structure( core::pose::Pose & pose );
209 
210 
211  // PostProcessing ---------------------------------------------------------
212 
215  void sort_groups_by_energy( );
216  void remove_singletons();
217  void export_only_low( bool value = false ){ export_only_low_ = value; };
218  void limit_groupsize( int limit = -1);
219  void limit_groupsize( core::Real percent_limit );
220  void random_limit_groupsize( core::Real percent_limit );
221  void limit_groups( int limit = -1);
222  void limit_total_structures( int limit = -1);
223  void clean_pose_store();
224 
225  // Printing --------------------------------------------------------------
226 
227  void print_summary();
228  void print_raw_numbers();
230  void print_cluster_PDBs( std::string prefix );
231  void print_clusters_silentfile( std::string prefix );
232  std::vector< core::pose::PoseOP > return_lowest_poses_in_clusters();
233  std::vector< core::pose::PoseOP > return_top_poses_in_clusters(core::Size count);
234  void create_constraints( std::string prefix, EnsembleConstraints &constraint_maker);
235 
236  std::vector < Cluster > const & get_cluster_list() const{ return clusterlist; }
237 
238 protected:
239  ObjexxFCL::FArray2D< core::Real > distance_matrix;
240  std::vector < Cluster > clusterlist;
241 
246 };
247 
248 
252 
254 public:
256  virtual ~ClusterPhilStyle() {};
257  protocols::moves::MoverOP clone() const { return new ClusterPhilStyle( *this ) ; }
258  virtual std::string get_name() const;
259  virtual void do_clustering( core::Size max_total_cluster );
260 
261  // this ensures every structure is in the cluster to who's cluster center it is most similar too
262  void do_redistribution();
263 };
264 
266 public:
268  : loop_def_(loop_def)
269  {}
270 
272  virtual std::string get_name() const;
274  return new ClusterPhilStyle_Loop( *this );
275  }
276 
277  virtual core::Real
279  const core::pose::Pose & pose1,
280  const core::pose::Pose & pose2
281  ) const;
282 
283 private:
285 };
286 
290 
292 public:
293  AssignToClustersMover( ClusterBaseOP cluster_base );
294 #ifndef BOINC // gives windows build error
296  return new AssignToClustersMover( *this );
297  }
298 #endif
299  virtual void apply( core::pose::Pose & pose );
300  virtual std::string get_name() const;
301 
302  int processed() const { return processed_; }
303 
304 protected:
307 };
308 
309 } //namespace cluster
310 } //namespace protocols
311 
312 #endif