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> 48 #ifndef BALL_HAS_NOEXCEPT 49 # define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS 50 # include <boost/graph/adjacency_list.hpp> 51 # undef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS 53 # include <boost/graph/adjacency_list.hpp> 60 # include <tbb/parallel_reduce.h> 61 # include <tbb/blocked_range.h> 65 #undef POSECLUSTERING_DEBUG 172 CENTER_OF_MASS_DISTANCE
181 PROPERTY_BASED_ATOM_BIJECTION
199 : translation(new_trans),
241 template <
class Archive>
242 void serialize(Archive& ar,
const unsigned int version);
260 boost::variant<Eigen::VectorXf, RigidTransformation>
center;
265 #ifdef POSECLUSTERING_DEBUG 268 float current_cluster_id;
272 typedef boost::adjacency_list<boost::vecS,
315 void setConformationSet(
ConformationSet* new_set,
bool precompute_atombijection =
false);
321 void setBaseSystemAndPoses(
System const& base_system, std::vector<PosePointer>
const& poses);
326 void setBaseSystemAndTransformations(
System const& base_system,
String transformation_file_name);
344 const System& getSystem()
const;
357 const std::set<Index>& getCluster(
Index i)
const;
361 std::set<Index>& getCluster(
Index i);
367 float getClusterScore(
Index i)
const;
379 void applyTransformation2System(
Index i,
System& target_system);
382 void convertTransformations2Snaphots();
385 void convertSnaphots2Transformations();
388 float computeCompleteLinkageRMSD(
Index i,
Options options,
bool initialize =
true);
394 boost::shared_ptr<System> getPose(
Index i)
const;
397 std::vector<PosePointer>
const&
getPoses()
const {
return poses_;}
400 boost::shared_ptr<System> getClusterRepresentative(
Index i);
406 boost::shared_ptr<ConformationSet> getClusterConformationSet(
Index i);
409 boost::shared_ptr<ConformationSet> getReducedConformationSet();
424 bool refineClustering(
Options const& refined_options);
436 void setDefaultOptions();
448 static float getRigidRMSD(Eigen::Vector3f
const& t_ab, Eigen::Matrix3f
const& M_ab, Eigen::Matrix3f
const& covariance_matrix);
455 static float getSquaredRigidRMSD(Eigen::Vector3f
const& t_ab, Eigen::Matrix3f
const& M_ab, Eigen::Matrix3f
const& covariance_matrix);
459 static Eigen::Matrix3f computeCovarianceMatrix(
System const& system,
Index rmsd_level_of_detail =
C_ALPHA);
471 std::vector<std::set<Index> > extractClustersForThreshold(
float threshold,
Size min_size = 0);
476 std::vector<std::set<Index> > extractNBestClusters(
Size n);
481 std::vector<std::set<Index> > filterClusters(
Size min_size = 1);
485 void serializeWardClusterTree(std::ostream& out,
bool binary =
false);
489 void deserializeWardClusterTree(std::istream& in,
bool binary =
false);
493 void exportWardClusterTreeToGraphViz(std::ostream& out);
497 void exportClusterTreeToJSON(std::ostream& out);
504 void printClusters(std::ostream& out = std::cout)
const;
508 void printClusterScores(std::ostream& out = std::cout);
516 class ComputeNearestClusterTask_
521 const std::vector<ClusterTreeNode>& active_clusters,
526 ComputeNearestClusterTask_(ComputeNearestClusterTask_& cnct, tbb::split);
529 void join(ComputeNearestClusterTask_
const& cnct);
532 void operator() (
const tbb::blocked_range<size_t>& r);
535 Position getMinIndex() {
return my_min_index_;}
538 float getMinValue() {
return my_min_value_;}
545 const std::vector<ClusterTreeNode>& active_clusters_;
567 : cluster_tree_(cluster_tree)
570 void operator() (std::ostream& out,
const ClusterTreeNode& v)
const;
582 : cluster_tree_(&cluster_tree)
585 bool operator() (ClusterTreeNode
const first, ClusterTreeNode
const second)
const 587 float first_value = (*cluster_tree_)[ first].merged_at;
588 float second_value = (*cluster_tree_)[second].merged_at;
590 return first_value < second_value;
599 bool trivialCompute_();
602 bool linearSpaceCompute_();
605 bool althausCompute_();
610 void slinkInner_(
int current_level);
615 void clinkInner_(
int current_level);
621 bool nearestNeighborChainCompute_();
623 void initWardDistance_(
Index rmsd_type);
625 void updateWardDistance_(ClusterTreeNode parent, ClusterTreeNode i, ClusterTreeNode j,
Index rmsd_type);
627 float computeWardDistance_(ClusterTreeNode i, ClusterTreeNode j,
Index rmsd_type);
629 std::set<Index> collectClusterBelow_(ClusterTreeNode
const& v);
632 void computeCenterOfMasses_();
635 void precomputeAtomBijection_();
638 bool static isExcludedByLevelOfDetail_(
Atom const* atom,
Index rmsd_level_of_detail);
647 bool readTransformationsFromFile_(
String filename);
653 void storeSnapShotReferences_();
656 void printCluster_(
Size i, std::ostream& out = std::cout)
const;
659 void printVariables_(
int a,
int b,
double c,
int d,
double e,
int current_level);
665 void exportToJSONDFS_(ClusterTreeNode
const& current,
String& result);
744 #endif // BALL_DOCKING_POSECLUSTERING_H
SnapShot base_conformation_
PosePointer(RigidTransformation const *new_trafo, SnapShot const *new_snap=0)
AtomBijection const & getAtomBijection() const
returns a const reference to the cached AtomBijection
static const String DISTANCE_THRESHOLD
ClusterTree::vertex_descriptor ClusterTreeNode
std::vector< Vector3 > & getCentersOfMass()
returns the centers of mass-vector (non-empty only for CENTER_OF_MASS_DISTANCE)
static const String RMSD_LEVEL_OF_DETAIL
std::vector< Vector3 > const & getCentersOfMass() const
returns the centers of mass-vector, const version (non-empty only for CENTER_OF_MASS_DISTANCE) ...
ClusterTree cluster_tree_
The tree built during hierarchical clustering.
static const String RUN_PARALLEL
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, ClusterProperties, boost::no_property, unsigned int > ClusterTree
static const float DISTANCE_THRESHOLD
ClusterTree * cluster_tree_
std::vector< RigidTransformation > transformations_
std::vector< Vector3 > com_
NEAREST_NEIGHBOR_CHAIN_WARD
static const String CLUSTER_METHOD
Eigen::Vector3f translation
BALL_EXTERN_VARIABLE const double c
RigidTransformation(Eigen::Vector3f const &new_trans, Eigen::Matrix3f const &new_rot)
static const bool USE_CENTER_OF_MASS_PRECLINK
Eigen::MatrixXd pairwise_scores_
ClusterTreeWriter_(ClusterTree const *cluster_tree)
Computation of clusters of docking poses.
ConformationSet * getConformationSet()
returns the poses to be clustered as ConformationSet
Size getNumberOfPoses() const
returns the number of poses
Default values for options.
bool delete_conformation_set_
Eigen::Matrix3f covariance_matrix_
std::vector< Index > cluster_representatives_
std::vector< std::set< Index > > clusters_
the clusters: sets of pose indices
PosePointer(SnapShot const *new_snap)
std::vector< PosePointer > poses_
const ConformationSet * getConformationSet() const
returns the poses to be clustered as ConformationSet
std::vector< PosePointer > const & getPoses() const
returns poses as PosePointer
ClusterTreeNodeComparator(ClusterTree &cluster_tree)
const std::vector< RigidTransformation > & getRigidTransformations() const
returns the poses as rigid transformations
RigidTransformation const * trafo
AtomBijection & getAtomBijection()
returns a reference to the cached AtomBijection
std::vector< float > cluster_scores_
the scores of the clusters
std::vector< double > mu_
AtomBijection atom_bijection_
static const bool RUN_PARALLEL
static const Index RMSD_LEVEL_OF_DETAIL
static const Index CLUSTER_METHOD
bool has_rigid_transformations_
Size getNumberOfClusters() const
returns the number of clusters found
static const String RMSD_TYPE
ConformationSet * current_set_
the ConformationSet we wish to cluster
Size number_of_selected_atoms_
Index rmsd_level_of_detail_
the RMSD definition used for clustering
boost::variant< Eigen::VectorXf, RigidTransformation > center
static const Index RMSD_TYPE
ClusterTree const * cluster_tree_
#define BALL_CREATE(name)
std::vector< double > lambda_