5 #ifndef BALL_DOCKING_POSECLUSTERING_H
6 #define BALL_DOCKING_POSECLUSTERING_H
8 #ifndef BALL_DATATYPE_OPTIONS_H
12 #ifndef BALL_DOCKING_COMMON_CONFORMATIONSET_H
16 #ifndef BALL_MOLMEC_COMMON_SNAPSHOT_H
20 #ifndef BALL_STRUCTURE_ATOMBIJECTION_H
24 #ifndef BALL_KERNEL_SYSTEM_H
28 #ifndef BALL_DATATYPE_STRING_H
32 #ifndef BALL_MATHS_VECTOR3_H
36 #ifndef BALL_MATHS_MATRIX44_H
42 #include <boost/shared_ptr.hpp>
43 #include <boost/variant.hpp>
44 #include <boost/graph/adjacency_list.hpp>
50 # include <tbb/parallel_reduce.h>
51 # include <tbb/blocked_range.h>
55 #undef POSECLUSTERING_DEBUG
162 CENTER_OF_MASS_DISTANCE
171 PROPERTY_BASED_ATOM_BIJECTION
189 : translation(new_trans),
223 template <
class Archive>
224 void serialize(Archive& ar,
const unsigned int version);
242 boost::variant<Eigen::VectorXf, RigidTransformation>
center;
247 #ifdef POSECLUSTERING_DEBUG
250 float current_cluster_id;
254 typedef boost::adjacency_list<boost::vecS,
297 void setConformationSet(
ConformationSet* new_set,
bool precompute_atombijection =
false);
303 void setBaseSystemAndPoses(
System const& base_system, std::vector<PosePointer>
const& poses);
308 void setBaseSystemAndTransformations(
System const& base_system,
String transformation_file_name);
326 const System& getSystem()
const;
339 const std::set<Index>& getCluster(
Index i)
const;
343 std::set<Index>& getCluster(
Index i);
349 float getClusterScore(
Index i)
const;
361 void applyTransformation2System(
Index i,
System& target_system);
364 void convertTransformations2Snaphots();
367 void convertSnaphots2Transformations();
370 float computeCompleteLinkageRMSD(
Index i,
Options options,
bool initialize =
true);
376 boost::shared_ptr<System> getPose(
Index i)
const;
379 std::vector<PosePointer>
const&
getPoses()
const {
return poses_;}
382 boost::shared_ptr<System> getClusterRepresentative(
Index i);
388 boost::shared_ptr<ConformationSet> getClusterConformationSet(
Index i);
391 boost::shared_ptr<ConformationSet> getReducedConformationSet();
406 bool refineClustering(
Options const& refined_options);
418 void setDefaultOptions();
430 static float getRigidRMSD(Eigen::Vector3f
const& t_ab, Eigen::Matrix3f
const& M_ab, Eigen::Matrix3f
const& covariance_matrix);
437 static float getSquaredRigidRMSD(Eigen::Vector3f
const& t_ab, Eigen::Matrix3f
const& M_ab, Eigen::Matrix3f
const& covariance_matrix);
441 static Eigen::Matrix3f computeCovarianceMatrix(
System const& system,
Index rmsd_level_of_detail =
C_ALPHA);
453 std::vector<std::set<Index> > extractClustersForThreshold(
float threshold,
Size min_size = 0);
458 std::vector<std::set<Index> > extractNBestClusters(
Size n);
463 std::vector<std::set<Index> > filterClusters(
Size min_size = 1);
467 void serializeWardClusterTree(std::ostream& out,
bool binary =
false);
471 void deserializeWardClusterTree(std::istream& in,
bool binary =
false);
475 void exportWardClusterTreeToGraphViz(std::ostream& out);
482 void printClusters(std::ostream& out = std::cout)
const;
486 void printClusterScores(std::ostream& out = std::cout);
494 class ComputeNearestClusterTask_
499 const std::vector<ClusterTreeNode>& active_clusters,
504 ComputeNearestClusterTask_(ComputeNearestClusterTask_& cnct, tbb::split);
507 void join(ComputeNearestClusterTask_
const& cnct);
510 void operator() (
const tbb::blocked_range<size_t>& r);
513 Position getMinIndex() {
return my_min_index_;}
516 float getMinValue() {
return my_min_value_;}
520 PoseClustering* parent_;
523 const std::vector<ClusterTreeNode>& active_clusters_;
545 : cluster_tree_(cluster_tree)
560 : cluster_tree_(&cluster_tree)
565 float first_value = (*cluster_tree_)[ first].merged_at;
566 float second_value = (*cluster_tree_)[second].merged_at;
568 return first_value < second_value;
577 bool trivialCompute_();
580 bool linearSpaceCompute_();
583 bool althausCompute_();
588 void slinkInner_(
int current_level);
593 void clinkInner_(
int current_level);
599 bool nearestNeighborChainCompute_();
601 void initWardDistance_(
Index rmsd_type);
610 void computeCenterOfMasses_();
613 void precomputeAtomBijection_();
616 bool static isExcludedByLevelOfDetail_(
Atom const* atom,
Index rmsd_level_of_detail);
625 bool readTransformationsFromFile_(
String filename);
631 void storeSnapShotReferences_();
634 void printCluster_(
Index i, std::ostream& out = std::cout)
const;
637 void printVariables_(
int a,
int b,
double c,
int d,
double e,
int current_level);
719 #endif // BALL_DOCKING_POSECLUSTERING_H
#define BALL_CREATE(name)
std::vector< double > mu_
std::vector< double > lambda_
static const String RMSD_TYPE
std::vector< Vector3 > & getCentersOfMass()
returns the centers of mass-vector (non-empty only for CENTER_OF_MASS_DISTANCE)
static const Index RMSD_TYPE
std::vector< PosePointer > const & getPoses() const
returns poses as PosePointer
ClusterTree * cluster_tree_
bool delete_conformation_set_
static const bool RUN_PARALLEL
const std::vector< RigidTransformation > & getRigidTransformations() const
returns the poses as rigid transformations
std::vector< std::set< Index > > clusters_
the clusters: sets of pose indices
std::vector< Vector3 > com_
static const String CLUSTER_METHOD
static const String RUN_PARALLEL
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, ClusterProperties, boost::no_property, unsigned int > ClusterTree
Eigen::Matrix3f covariance_matrix_
static const float DISTANCE_THRESHOLD
bool has_rigid_transformations_
const ConformationSet * getConformationSet() const
returns the poses to be clustered as ConformationSet
ClusterTreeWriter_(ClusterTree const *cluster_tree)
ClusterTreeNodeComparator(ClusterTree &cluster_tree)
Index rmsd_level_of_detail_
the RMSD definition used for clustering
RigidTransformation const * trafo
PosePointer(RigidTransformation const *new_trafo, SnapShot const *new_snap=0)
BALL_EXTERN_VARIABLE const double c
static const Index CLUSTER_METHOD
std::vector< Index > cluster_representatives_
boost::variant< Eigen::VectorXf, RigidTransformation > center
AtomBijection const & getAtomBijection() const
returns a const reference to the cached AtomBijection
Eigen::MatrixXd pairwise_scores_
Computation of clusters of docking poses.
ClusterTree const * cluster_tree_
ConformationSet * current_set_
the ConformationSet we wish to cluster
static const String DISTANCE_THRESHOLD
Size getNumberOfClusters() const
returns the number of clusters found
Size getNumberOfPoses() const
returns the number of poses
static const String RMSD_LEVEL_OF_DETAIL
PosePointer(SnapShot const *new_snap)
ConformationSet * getConformationSet()
returns the poses to be clustered as ConformationSet
std::vector< Vector3 > const & getCentersOfMass() const
returns the centers of mass-vector, const version (non-empty only for CENTER_OF_MASS_DISTANCE) ...
std::vector< float > cluster_scores_
the scores of the clusters
std::vector< PosePointer > poses_
Size number_of_selected_atoms_
static const Index RMSD_LEVEL_OF_DETAIL
static const bool USE_CENTER_OF_MASS_PRECLINK
ClusterTree cluster_tree_
The tree built during hierarchical clustering.
std::vector< RigidTransformation > transformations_
SnapShot base_conformation_
AtomBijection & getAtomBijection()
returns a reference to the cached AtomBijection
Default values for options.
NEAREST_NEIGHBOR_CHAIN_WARD
ClusterTree::vertex_descriptor ClusterTreeNode
AtomBijection atom_bijection_