clustering  0.12
Clustering suite for molecular dynamics trajectories.
 All Classes Namespaces Files Functions Variables Typedefs
mpp.hpp
1 /*
2 Copyright (c) 2015, Florian Sittel (www.lettis.net)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11 2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
16 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
18 SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25 #pragma once
26 
27 #include <vector>
28 #include <map>
29 #include <set>
30 #include <stdexcept>
31 
32 #include <boost/program_options.hpp>
33 #include <boost/numeric/ublas/matrix_sparse.hpp>
34 #include <boost/numeric/ublas/io.hpp>
35 
36 #include "tools.hpp"
37 
38 namespace Clustering {
40  namespace MPP {
42  using SparseMatrixF = boost::numeric::ublas::mapped_matrix<float>;
48  transition_counts(std::vector<std::size_t> trajectory, std::vector<std::size_t> concat_limits, std::size_t n_lag_steps);
51  row_normalized_transition_probabilities(SparseMatrixF count_matrix, std::set<std::size_t> microstate_names);
54  std::map<std::size_t, std::size_t>
55  single_step_future_state(SparseMatrixF transition_matrix,
56  std::set<std::size_t> cluster_names,
57  float q_min,
58  std::map<std::size_t, float> min_free_energy);
61  std::map<std::size_t, std::vector<std::size_t>>
62  most_probable_path(std::map<std::size_t, std::size_t> future_state, std::set<std::size_t> cluster_names);
64  std::map<std::size_t, std::size_t>
65  microstate_populations(std::vector<std::size_t> clusters, std::set<std::size_t> cluster_names);
68  std::map<std::size_t, float>
69  microstate_min_free_energy(const std::vector<std::size_t>& clustering,
70  const std::vector<float>& free_energy);
74  std::map<std::size_t, std::size_t>
75  path_sinks(std::vector<std::size_t> clusters,
76  std::map<std::size_t, std::vector<std::size_t>> mpp,
77  SparseMatrixF transition_matrix,
78  std::set<std::size_t> cluster_names,
79  float q_min,
80  std::vector<float> free_energy);
83  std::vector<std::size_t>
84  lumped_trajectory(std::vector<std::size_t> trajectory,
85  std::map<std::size_t, std::size_t> sinks);
87  std::tuple<std::vector<std::size_t>, std::map<std::size_t, std::size_t>>
88  fixed_metastability_clustering(std::vector<std::size_t> initial_trajectory,
89  std::vector<std::size_t> concat_limits,
90  float q_min,
91  std::size_t lagtime,
92  std::vector<float> free_energy);
106  void
107  main(boost::program_options::variables_map args);
108  } // end namespace Clustering::MPP
109 } // end namespace Clustering
110 
boost::numeric::ublas::mapped_matrix< float > SparseMatrixF
BOOST implementation of a sparse matrix for floats.
Definition: mpp.hpp:42
SparseMatrixF row_normalized_transition_probabilities(SparseMatrixF count_matrix, std::set< std::size_t > cluster_names)
compute transition matrix from counts by normalization of rows
Definition: mpp.cpp:63
std::map< std::size_t, std::size_t > microstate_populations(std::vector< std::size_t > clusters, std::set< std::size_t > cluster_names)
compute cluster populations
Definition: mpp.cpp:155
std::map< std::size_t, float > microstate_min_free_energy(const std::vector< std::size_t > &clustering, const std::vector< float > &free_energy)
Definition: mpp.cpp:167
std::map< std::size_t, std::vector< std::size_t > > most_probable_path(std::map< std::size_t, std::size_t > future_state, std::set< std::size_t > cluster_names)
Definition: mpp.cpp:135
std::map< std::size_t, std::size_t > path_sinks(std::vector< std::size_t > clusters, std::map< std::size_t, std::vector< std::size_t >> mpp, SparseMatrixF transition_matrix, std::set< std::size_t > cluster_names, float q_min, std::vector< float > free_energy)
Definition: mpp.cpp:184
std::map< std::size_t, Clustering::Tools::Neighbor > Neighborhood
map frame id to neighbors
Definition: tools.hpp:55
Clustering::Tools::Neighborhood Neighborhood
Neighborhood per frame.
Definition: mpp.hpp:44
std::map< std::size_t, std::size_t > single_step_future_state(SparseMatrixF transition_matrix, std::set< std::size_t > cluster_names, float q_min, std::map< std::size_t, float > min_free_energy)
Definition: mpp.cpp:85
SparseMatrixF transition_counts(std::vector< std::size_t > trajectory, std::vector< std::size_t > concat_limits, std::size_t n_lag_steps)
Definition: mpp.cpp:33
std::tuple< std::vector< std::size_t >, std::map< std::size_t, std::size_t > > fixed_metastability_clustering(std::vector< std::size_t > initial_trajectory, std::vector< std::size_t > concat_limits, float q_min, std::size_t lagtime, std::vector< float > free_energy)
run clustering for given Q_min value
Definition: mpp.cpp:249
std::vector< std::size_t > lumped_trajectory(std::vector< std::size_t > trajectory, std::map< std::size_t, std::size_t > sinks)
Definition: mpp.cpp:238
void main(boost::program_options::variables_map args)
Definition: mpp.cpp:320