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 /// @file
11 /// @brief
12 /// @author
13 
14 #ifndef INCLUDED_protocols_toolbox_Cluster_hh
15 #define INCLUDED_protocols_toolbox_Cluster_hh
16 
17 
18 // AUTO-REMOVED #include <utility/vector1.hh>
19 #include <core/types.hh>
20 #include <ObjexxFCL/FArray2D.hh>
21 #include <deque>
23 
24 #include <utility/vector1_bool.hh>
25 
26 
27 namespace protocols {
28 namespace toolbox {
29 
30 class ClusterBase {
31 public:
33  distance_( dim, dim, 0.0 ),
34  dim_( dim )
35  {};
36 
38  return distance_( i, j );
39  }
40 
42  return distance_( i, j);
43  }
44 
45  ObjexxFCL::FArray2D< core::Real > & distance_matrix() { return distance_; }
46  ObjexxFCL::FArray2D< core::Real > const& distance_matrix() const { return distance_; }
47 
48  core::Size dim() const { return dim_; }
49 
50  void print_cluster_assignment( std::ostream& out ) const;
51 
52  typedef std::deque< core::Size > Cluster;
54  typedef Cluster::const_iterator IntraClusterIterator;
55  typedef ClusterList::const_iterator ClusterIterator;
56 
57  core::Size size() const {
58  return clusterlist_.size();
59  }
60 
61  Cluster const& cluster( core::Size i ) const {
62  return clusterlist_[ i ];
63  }
64 
65  ClusterList const& clusterlist() const {
66  return clusterlist_;
67  }
68 
69  void sort_each_group_by_energy( utility::vector1< core::Real > all_energies, bool keep_center = false );
70  void limit_groupsize( core::Size limit );
72 
73  void show( std::ostream& out ) const;
74  void read( std::istream& in );
75 
76 protected:
78  ObjexxFCL::FArray2D< core::Real > distance_;
80 
81 };
82 
83 class ClusterPhilStyle : public ClusterBase {
84 public:
86  ClusterBase( dim ),
87  cluster_radius_ ( rad ),
88  n_max_cluster_( 10 )
89  {};
90 
91  void compute();
92  void do_clustering() { compute(); };
93 
94  void set_radius( core::Real setting ) {
95  cluster_radius_ = setting;
96  }
97 
98  void set_n_max_cluster( core::Size setting ) {
99  n_max_cluster_ = setting;
100  }
101 private:
104 };
105 
106 
107 
108 extern std::ostream& operator<< ( std::ostream& out, ClusterBase const& cl);
109 extern std::ostream& operator<< ( std::ostream& out, ClusterBase::ClusterList const& cl);
110 extern std::istream& operator>> ( std::istream& in, ClusterBase& cl);
111 extern std::istream& operator>> ( std::istream& in, ClusterBase::ClusterList& cl);
112 
114 public:
115  ClusterOptions( bool assign_new_cluster_tag = false ); //set options from cmd-line
116 
121 };
122 
123 
124 // use with any iterator that points to a SilentStruct& :
125 // (1) SilentFileData sfd;
126 // cluster_silent_structs( sfd.size(), sfd.begin(), sfd.end(), ... )
127 //
128 // or
129 // (2) typedef vector1< SilentStructOP > SilentStructs;
130 // typedef toolbox::OP_const_iterator< SilentStructs::const_iterator, SilentStructs::value_type > Deref;
131 // SilentStructs list;
132 // /* fill list with decoys ... */
133 // cluster_silent_struct( list.size(), Deref( list.begin() ), Deref( list.end() ), ... );
134 //
135 template< typename SilentStructIterator, typename StructureContainer >
137  core::Size n_decoys,
138  SilentStructIterator input_decoys_begin,
139  SilentStructIterator input_decoys_end,
140  StructureContainer& new_structs, //provides a "push_back" method
141  ClusterOptions opts
142 );
143 
144 template< typename SilentStructIterator, typename StructureContainer >
145 void cluster_silent_structs( DecoySetEvaluation const& CA_set,
146  SilentStructIterator input_decoys_begin,
147  SilentStructIterator input_decoys_end,
148  StructureContainer& new_structs,
149  ClusterOptions opts
150 );
151 
152 }
153 }
154 
155 #endif