Pteros  2.0
Molecular modeling library for human beings!
voronoi_packing.h
1 /*
2  * This file is a part of
3  *
4  * ============================================
5  * ### Pteros molecular modeling library ###
6  * ============================================
7  *
8  * https://github.com/yesint/pteros
9  *
10  * (C) 2009-2021, Semen Yesylevskyy
11  *
12  * All works, which use Pteros, should cite the following papers:
13  *
14  * 1. Semen O. Yesylevskyy, "Pteros 2.0: Evolution of the fast parallel
15  * molecular analysis library for C++ and python",
16  * Journal of Computational Chemistry, 2015, 36(19), 1480–1488.
17  * doi: 10.1002/jcc.23943.
18  *
19  * 2. Semen O. Yesylevskyy, "Pteros: Fast and easy to use open-source C++
20  * library for molecular analysis",
21  * Journal of Computational Chemistry, 2012, 33(19), 1632–1636.
22  * doi: 10.1002/jcc.22989.
23  *
24  * This is free software distributed under Artistic License:
25  * http://www.opensource.org/licenses/artistic-license-2.0.php
26  *
27 */
28 
29 
30 #pragma once
31 #include "pteros/core/selection.h"
32 #include <Eigen/Core>
33 //#include "voro++.hh"
34 
35 namespace pteros {
36 
37 struct PackingGroup {
38  PackingGroup(): total_area(0.0), total_volume(0.0) {}
39 
40  Selection sel;
41  int num_residues;
42  double total_area;
43  double total_volume;
44  // Mapping from pid to local indexes
45  std::map<int,int> pid_to_ind;
46  // Mapping from local indexes to pid
47  std::map<int,int> ind_to_pid;
48 
49  void compute_averages(int num_frames);
50 };
51 
52 
53 struct InterGroupFace {
54  InterGroupFace(int at1, int at2, double a): pids(at1,at2),area(a) {}
55  Eigen::Vector2i pids;
56  double area;
57 };
58 
59 
60 class Voronoi3D {
61 public:
62  Voronoi3D(){}
63  Voronoi3D(const std::vector<Selection>& groups_sel);
64  void create(const std::vector<Selection>& groups_sel);
65  void compute();
66  void compute_averages();
67  void write_stats(const std::string& fname) const;
68  PackingGroup& get_group(int i) { return groups[i]; }
69  int num_groups() const { return groups.size(); }
70  Eigen::MatrixXd& get_interface_areas() { return interface_areas; }
71  int get_num_frames() const { return num_frames; }
72 private:
73  int num_frames;
74  std::map<int, int> pid_to_groups;
75  std::vector<PackingGroup> groups;
76  // Output matrix of areas between groups
77  Eigen::MatrixXd interface_areas;
78 };
79 
80 } // namespace pteros
81 
82 
83 
84