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),
226 #ifdef BALL_HAS_RVALUE_REFERENCES
232 template <
class Archive>
233 void serialize(Archive& ar,
const unsigned int version);
251 boost::variant<Eigen::VectorXf, RigidTransformation>
center;
256 #ifdef POSECLUSTERING_DEBUG
259 float current_cluster_id;
263 typedef boost::adjacency_list<boost::vecS,
306 void setConformationSet(
ConformationSet* new_set,
bool precompute_atombijection =
false);
312 void setBaseSystemAndPoses(
System const& base_system, std::vector<PosePointer>
const& poses);
317 void setBaseSystemAndTransformations(
System const& base_system,
String transformation_file_name);
335 const System& getSystem()
const;
348 const std::set<Index>& getCluster(
Index i)
const;
352 std::set<Index>& getCluster(
Index i);
358 float getClusterScore(
Index i)
const;
370 void applyTransformation2System(
Index i,
System& target_system);
373 void convertTransformations2Snaphots();
376 void convertSnaphots2Transformations();
379 float computeCompleteLinkageRMSD(
Index i,
Options options,
bool initialize =
true);
385 boost::shared_ptr<System> getPose(
Index i)
const;
388 std::vector<PosePointer>
const&
getPoses()
const {
return poses_;}
391 boost::shared_ptr<System> getClusterRepresentative(
Index i);
397 boost::shared_ptr<ConformationSet> getClusterConformationSet(
Index i);
400 boost::shared_ptr<ConformationSet> getReducedConformationSet();
415 bool refineClustering(
Options const& refined_options);
427 void setDefaultOptions();
439 static float getRigidRMSD(Eigen::Vector3f
const& t_ab, Eigen::Matrix3f
const& M_ab, Eigen::Matrix3f
const& covariance_matrix);
446 static float getSquaredRigidRMSD(Eigen::Vector3f
const& t_ab, Eigen::Matrix3f
const& M_ab, Eigen::Matrix3f
const& covariance_matrix);
450 static Eigen::Matrix3f computeCovarianceMatrix(
System const& system,
Index rmsd_level_of_detail =
C_ALPHA);
462 std::vector<std::set<Index> > extractClustersForThreshold(
float threshold,
Size min_size = 0);
467 std::vector<std::set<Index> > extractNBestClusters(
Size n);
472 std::vector<std::set<Index> > filterClusters(
Size min_size = 1);
476 void serializeWardClusterTree(std::ostream& out,
bool binary =
false);
480 void deserializeWardClusterTree(std::istream& in,
bool binary =
false);
484 void exportWardClusterTreeToGraphViz(std::ostream& out);
491 void printClusters(std::ostream& out = std::cout)
const;
495 void printClusterScores(std::ostream& out = std::cout);
503 class ComputeNearestClusterTask_
508 const std::vector<ClusterTreeNode>& active_clusters,
513 ComputeNearestClusterTask_(ComputeNearestClusterTask_& cnct, tbb::split);
516 void join(ComputeNearestClusterTask_
const& cnct);
519 void operator() (
const tbb::blocked_range<size_t>& r);
522 Position getMinIndex() {
return my_min_index_;}
525 float getMinValue() {
return my_min_value_;}
529 PoseClustering* parent_;
532 const std::vector<ClusterTreeNode>& active_clusters_;
554 : cluster_tree_(cluster_tree)
557 void operator() (std::ostream& out,
const ClusterTreeNode& v)
const;
569 : cluster_tree_(&cluster_tree)
572 bool operator() (ClusterTreeNode
const first, ClusterTreeNode
const second)
const
574 float first_value = (*cluster_tree_)[ first].merged_at;
575 float second_value = (*cluster_tree_)[second].merged_at;
577 return first_value < second_value;
586 bool trivialCompute_();
589 bool linearSpaceCompute_();
592 bool althausCompute_();
597 void slinkInner_(
int current_level);
602 void clinkInner_(
int current_level);
608 bool nearestNeighborChainCompute_();
610 void initWardDistance_(
Index rmsd_type);
612 void updateWardDistance_(ClusterTreeNode parent, ClusterTreeNode i, ClusterTreeNode j,
Index rmsd_type);
614 float computeWardDistance_(ClusterTreeNode i, ClusterTreeNode j,
Index rmsd_type);
616 std::set<Index> collectClusterBelow_(ClusterTreeNode
const& v);
619 void computeCenterOfMasses_();
622 void precomputeAtomBijection_();
625 bool static isExcludedByLevelOfDetail_(
Atom const* atom,
Index rmsd_level_of_detail);
634 bool readTransformationsFromFile_(
String filename);
640 void storeSnapShotReferences_();
643 void printCluster_(
Index i, std::ostream& out = std::cout)
const;
646 void printVariables_(
int a,
int b,
double c,
int d,
double e,
int current_level);
728 #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
-*- Mode: C++; tab-width: 2; -*-
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_