00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPSTATISTICS_POINT_CLUSTERING_H
00009 #define IMPSTATISTICS_POINT_CLUSTERING_H
00010
00011 #include "statistics_config.h"
00012 #include "statistics_macros.h"
00013 #include "PartitionalClustering.h"
00014 #include <IMP/macros.h>
00015 #include <IMP/Object.h>
00016 #include <IMP/ConfigurationSet.h>
00017 #include <IMP/SingletonContainer.h>
00018 #include <IMP/algebra/Vector3D.h>
00019 #include <IMP/em/DensityMap.h>
00020 #include <IMP/algebra/VectorD.h>
00021 #include <IMP/core/XYZ.h>
00022
00023 IMPSTATISTICS_BEGIN_NAMESPACE
00024
00025
00026
00027
00028
00029
00030
00031 class IMPSTATISTICSEXPORT Embedding: public Object {
00032 public:
00033 Embedding(std::string name): Object(name){}
00034 virtual Floats get_point(unsigned int i) const =0;
00035 virtual unsigned int get_number_of_points() const=0;
00036 IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Embedding);
00037 };
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 class IMPSTATISTICSEXPORT ConfigurationSetXYZEmbedding: public Embedding {
00050 mutable Pointer<ConfigurationSet> cs_;
00051 Pointer<SingletonContainer> sc_;
00052 public:
00053 ConfigurationSetXYZEmbedding(ConfigurationSet *cs,
00054 SingletonContainer *sc);
00055 IMP_EMBEDDING(ConfigurationSetXYZEmbedding);
00056 };
00057
00058
00059
00060
00061 template <unsigned int D>
00062 class VectorDEmbedding: public Embedding {
00063 std::vector<algebra::VectorD<D> > vectors_;
00064 public:
00065 VectorDEmbedding(const std::vector<algebra::VectorD<D> > &vs):
00066 Embedding("VectorDs"), vectors_(vs){}
00067 IMP_EMBEDDING(VectorDEmbedding);
00068 };
00069
00070 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
00071 template <unsigned int D>
00072 Floats VectorDEmbedding<D>::get_point(unsigned int i) const {
00073 return Floats(vectors_[i].coordinates_begin(),
00074 vectors_[i].coordinates_end());
00075 }
00076
00077 template <unsigned int D>
00078 unsigned int VectorDEmbedding<D>::get_number_of_points() const {
00079 return vectors_.size();
00080 }
00081
00082 template <unsigned int D>
00083 void VectorDEmbedding<D>::do_show(std::ostream &out) const {
00084 }
00085 #endif
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 class IMPSTATISTICSEXPORT ParticleEmbedding: public Embedding {
00096 Particles ps_;
00097 FloatKeys ks_;
00098 bool rescale_;
00099 std::vector<FloatRange> ranges_;
00100 public:
00101 ParticleEmbedding(const ParticlesTemp &ps,
00102 const FloatKeys& ks=core::XYZ::get_xyz_keys(),
00103 bool rescale=false);
00104 IMP_EMBEDDING(ParticleEmbedding);
00105 };
00106
00107
00108
00109
00110
00111
00112 class IMPSTATISTICSEXPORT HighDensityEmbedding: public Embedding {
00113 std::vector<algebra::VectorD<3> > points_;
00114 public:
00115 HighDensityEmbedding(em::DensityMap *dm,
00116 double threshold);
00117 IMP_EMBEDDING(HighDensityEmbedding);
00118 };
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 class IMPSTATISTICSEXPORT KMeansClustering: public PartitionalClustering {
00131 std::vector<Ints> clusters_;
00132 Ints reps_;
00133 std::vector<Floats> centers_;
00134 public:
00135 KMeansClustering(const std::vector<Ints> &clusters,
00136 const std::vector<Floats> ¢ers,
00137 const Ints &reps): PartitionalClustering("k-means"),
00138 clusters_(clusters),
00139 reps_(reps),
00140 centers_(centers){}
00141 const Floats& get_cluster_center(unsigned int i) const {
00142 return centers_[i];
00143 }
00144 IMP_CLUSTERING(KMeansClustering);
00145 };
00146
00147
00148
00149
00150
00151
00152
00153 IMPSTATISTICSEXPORT KMeansClustering*
00154 get_lloyds_kmeans(Embedding *embedding,
00155 unsigned int k, unsigned int iterations);
00156
00157 IMPSTATISTICS_END_NAMESPACE
00158
00159 #endif