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);
265#ifdef POSECLUSTERING_DEBUG
268 float current_cluster_id;
272 typedef boost::adjacency_list<boost::vecS,
397 std::vector<PosePointer>
const&
getPoses()
const {
return poses_;}
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);
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_;}
542 PoseClustering* parent_;
545 const std::vector<ClusterTreeNode>& active_clusters_;
567 : cluster_tree_(cluster_tree)
582 : cluster_tree_(&cluster_tree)
587 float first_value = (*cluster_tree_)[ first].merged_at;
588 float second_value = (*cluster_tree_)[second].merged_at;
590 return first_value < second_value;
NEAREST_NEIGHBOR_CHAIN_WARD
BALL_EXTERN_VARIABLE const double c
Computation of clusters of docking poses.
void deserializeWardClusterTree(std::istream &in, bool binary=false)
bool has_rigid_transformations_
float computeWardDistance_(ClusterTreeNode i, ClusterTreeNode j, Index rmsd_type)
boost::shared_ptr< System > getClusterRepresentative(Index i)
returns the "central cluster" conformation of cluster i as system
AtomBijection const & getAtomBijection() const
returns a const reference to the cached AtomBijection
float getClusterScore(Index i) const
returns the score of cluster i
std::vector< PosePointer > poses_
void clinkInner_(int current_level)
void setConformationSet(ConformationSet *new_set, bool precompute_atombijection=false)
sets the poses to be clustered, the conformation set's reference system will the base system
bool nearestNeighborChainCompute_()
Eigen::Matrix3f covariance_matrix_
ConformationSet * getConformationSet()
returns the poses to be clustered as ConformationSet
void exportToJSONDFS_(ClusterTreeNode const ¤t, String &result)
void precomputeAtomBijection_()
AtomBijection atom_bijection_
bool readTransformationsFromFile_(String filename)
const std::vector< RigidTransformation > & getRigidTransformations() const
returns the poses as rigid transformations
const ConformationSet * getConformationSet() const
returns the poses to be clustered as ConformationSet
boost::shared_ptr< ConformationSet > getReducedConformationSet()
returns a ConformationSet containing one structure per cluster
float getScore(const System sys_a, const System sys_b, Options options) const
returns the score between two poses given as systems
bool linearSpaceCompute_()
void setBaseSystemAndTransformations(System const &base_system, String transformation_file_name)
bool delete_conformation_set_
void exportWardClusterTreeToGraphViz(std::ostream &out)
float getRMSD_(Index i, Index j, Index rmsd_type)
virtual ~PoseClustering()
Index findClusterRepresentative(Index i)
returns the index of the cluster representative
std::vector< float > cluster_scores_
the scores of the clusters
void updateWardDistance_(ClusterTreeNode parent, ClusterTreeNode i, ClusterTreeNode j, Index rmsd_type)
SnapShot base_conformation_
static float getRigidRMSD(Eigen::Vector3f const &t_ab, Eigen::Matrix3f const &M_ab, Eigen::Matrix3f const &covariance_matrix)
std::set< Index > collectClusterBelow_(ClusterTreeNode const &v)
void applyTransformation2System(Index i, System &target_system)
apply a transformation to a given system
std::vector< std::set< Index > > extractClustersForThreshold(float threshold, Size min_size=0)
System & getSystem()
returns the reference pose
boost::shared_ptr< ConformationSet > getClusterConformationSet(Index i)
returns cluster i as ConformationSet
void exportClusterTreeToJSON(std::ostream &out)
void serializeWardClusterTree(std::ostream &out, bool binary=false)
void initWardDistance_(Index rmsd_type)
std::vector< Vector3 > const & getCentersOfMass() const
returns the centers of mass-vector, const version (non-empty only for CENTER_OF_MASS_DISTANCE)
Size number_of_selected_atoms_
std::vector< std::set< Index > > filterClusters(Size min_size=1)
std::vector< PosePointer > const & getPoses() const
returns poses as PosePointer
PoseClustering()
Default constructor.
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, ClusterProperties, boost::no_property, unsigned int > ClusterTree
Eigen::MatrixXd pairwise_scores_
boost::shared_ptr< System > getPose(Index i) const
returns the complete linkage RMSD of a pose set
PoseClustering(ConformationSet *poses, float rmsd)
void setBaseSystemAndPoses(System const &base_system, std::vector< PosePointer > const &poses)
const std::set< Index > & getCluster(Index i) const
std::vector< double > lambda_
std::vector< RigidTransformation > transformations_
ConformationSet * current_set_
the ConformationSet we wish to cluster
PoseClustering(System const &base_system, String transformation_file_name)
PoseClustering for a given set of rigid transformations of a base structure.
Index rmsd_level_of_detail_
the RMSD definition used for clustering
void storeSnapShotReferences_()
BALL_CREATE(PoseClustering)
float getClusterRMSD_(Index i, Index j, Index rmsd_type)
ClusterTree::vertex_descriptor ClusterTreeNode
Size getNumberOfPoses() const
returns the number of poses
void printClusterScores(std::ostream &out=std::cout)
bool refineClustering(Options const &refined_options)
void convertTransformations2Snaphots()
convert the poses to SnapShots
std::set< Index > & getCluster(Index i)
std::vector< double > mu_
void slinkInner_(int current_level)
void computeCenterOfMasses_()
Size getNumberOfClusters() const
returns the number of clusters found
std::vector< Index > cluster_representatives_
const System & getSystem() const
returns the reference pose
std::vector< Vector3 > & getCentersOfMass()
returns the centers of mass-vector (non-empty only for CENTER_OF_MASS_DISTANCE)
std::vector< std::set< Index > > extractNBestClusters(Size n)
static float getSquaredRigidRMSD(Eigen::Vector3f const &t_ab, Eigen::Matrix3f const &M_ab, Eigen::Matrix3f const &covariance_matrix)
void convertSnaphots2Transformations()
convert the poses to rigid transformations
Size getClusterSize(Index i) const
returns the size of cluster i
std::vector< std::set< Index > > clusters_
the clusters: sets of pose indices
std::vector< Vector3 > com_
AtomBijection & getAtomBijection()
returns a reference to the cached AtomBijection
ClusterTree cluster_tree_
The tree built during hierarchical clustering.
float computeCompleteLinkageRMSD(Index i, Options options, bool initialize=true)
returns the complete linkage RMSD of cluster i
void printClusters(std::ostream &out=std::cout) const
static Eigen::Matrix3f computeCovarianceMatrix(System const &system, Index rmsd_level_of_detail=C_ALPHA)
static bool isExcludedByLevelOfDetail_(Atom const *atom, Index rmsd_level_of_detail)
void printVariables_(int a, int b, double c, int d, double e, int current_level)
void printCluster_(Size i, std::ostream &out=std::cout) const
static const String RUN_PARALLEL
static const String DISTANCE_THRESHOLD
static const String RMSD_TYPE
static const String CLUSTER_METHOD
static const String RMSD_LEVEL_OF_DETAIL
Default values for options.
static const float DISTANCE_THRESHOLD
static const bool USE_CENTER_OF_MASS_PRECLINK
static const bool RUN_PARALLEL
static const Index RMSD_TYPE
static const Index RMSD_LEVEL_OF_DETAIL
static const Index CLUSTER_METHOD
Eigen::Vector3f translation
RigidTransformation(Eigen::Vector3f const &new_trans, Eigen::Matrix3f const &new_rot)
PosePointer(RigidTransformation const *new_trafo, SnapShot const *new_snap=0)
RigidTransformation const * trafo
PosePointer(SnapShot const *new_snap)
ClusterProperties & operator=(const ClusterProperties &)
ClusterProperties(ClusterProperties &&) BALL_NOEXCEPT
ClusterProperties(const ClusterProperties &)
ClusterTreeWriter_(ClusterTree const *cluster_tree)
ClusterTree const * cluster_tree_
ClusterTree * cluster_tree_
ClusterTreeNodeComparator(ClusterTree &cluster_tree)