Pteros  2.0
Molecular modeling library for human beings!
structure.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 #pragma once
30 
31 #include <vector>
32 #include <Eigen/Core>
33 #include "pteros/core/atom.h"
34 #include "pteros/core/state.h"
35 
36 namespace pteros {
37 
38 class Structure {
39 public:
40  Structure();
41 
42  size_t size() const {return _atoms.size();}
43  size_t num_atoms() const {return _atoms.size();}
44  size_t num_bonds() const {return _bonds.size();}
45  size_t num_molecules() const {return _molecules.size();}
46  bool has_bonds() const {return !_bonds.empty();}
47  bool has_molecules() const {return !_molecules.empty();}
48 
49  void compute_bonds(const State& state, float cutoff=0.15);
50  void compute_molecules();
51 
52  inline Atom& atom(size_t ind) { return _atoms[ind]; }
53 
54  std::vector<Atom>& atoms() {return _atoms;}
55  std::vector<Eigen::Vector2i>& bonds() {return _bonds;}
56  std::vector<Eigen::Vector2i>& molecules() {return _molecules;}
57 
58  std::vector<int> bonded_atoms(int at) const;
59  std::vector<int> find_bonds(int at) const;
60  int find_molecule(int at) const;
61 
62  void clear();
63 
64 private:
65  std::vector<Atom> _atoms;
66  std::vector<Eigen::Vector2i> _bonds;
67  std::vector<Eigen::Vector2i> _molecules;
68 }; // Structure
69 
70 
71 } // pteros