Pteros  2.0
Molecular modeling library for human beings!
atom_handler.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 
32 #include "pteros/core/atom.h"
33 #include <Eigen/Core>
34 
35 namespace pteros {
36 
37 
38 using AtomStateIterator = std::vector<Eigen::Vector3f>::iterator;
39 using AtomStateConstIterator = std::vector<Eigen::Vector3f>::const_iterator;
40 using AtomIterator = std::vector<Atom>::iterator;
41 using AtomConstIterator = std::vector<Atom>::const_iterator;
42 
43 class Selection;
44 class System;
45 
49 class AtomHandler {
50  friend class Selection;
51  friend class System;
52 public:
53  AtomHandler(){}
54  AtomHandler(const Selection& sel, int i);
55  AtomHandler(const System& sys, int i, int fr);
56  void set(const Selection& sel, int i);
57  void set(const System& sys, int i, int fr);
58 
61  inline const int& index() const { return ind; }
62 
63  inline int& resid(){ return atom_ptr->resid; }
64  inline const int& resid() const { return atom_ptr->resid; }
65 
66  inline std::string& name(){ return atom_ptr->name; }
67  inline const std::string& name() const { return atom_ptr->name; }
68 
69  inline char& chain(){ return atom_ptr->chain; }
70  inline const char& chain() const { return atom_ptr->chain; }
71 
72  inline std::string& resname(){ return atom_ptr->resname; }
73  inline const std::string& resname() const { return atom_ptr->resname; }
74 
75  inline std::string& tag(){ return atom_ptr->tag; }
76  inline const std::string& tag() const { return atom_ptr->tag; }
77 
78  inline float& occupancy(){ return atom_ptr->occupancy; }
79  inline const float& occupancy() const { return atom_ptr->occupancy; }
80 
81  inline float& beta(){ return atom_ptr->beta; }
82  inline const float& beta() const { return atom_ptr->beta; }
83 
84  inline int& resindex() { return atom_ptr->resindex; }
85  inline const int& resindex() const { return atom_ptr->resindex; }
86 
87  inline float& mass(){ return atom_ptr->mass; }
88  inline const float& mass() const { return atom_ptr->mass; }
89 
90  inline float& charge(){ return atom_ptr->charge; }
91  inline const float& charge() const { return atom_ptr->charge; }
92 
93  inline int& type(){ return atom_ptr->type; }
94  inline const int& type() const { return atom_ptr->type; }
95 
96  inline std::string& type_name(){ return atom_ptr->type_name; }
97  inline const std::string& type_name() const { return atom_ptr->type_name; }
98 
99  inline float& x(){ return (*coord_ptr)(0); }
100  inline const float& x() const { return (*coord_ptr)(0); }
101 
102  inline float& y(){ return (*coord_ptr)(1); }
103  inline const float& y() const { return (*coord_ptr)(1); }
104 
105  inline float& z(){ return (*coord_ptr)(2); }
106  inline const float& z() const { return (*coord_ptr)(2); }
107 
108  inline Eigen::Vector3f& xyz(){ return *coord_ptr; }
109  inline const Eigen::Vector3f& xyz() const { return *coord_ptr; }
110 
111  /*
112  inline Eigen::Vector3f& vel(){ return *v_ptr; }
113  inline const Eigen::Vector3f& vel() const { return *v_ptr; }
114 
115  inline Eigen::Vector3f& force(){ return *f_ptr; }
116  inline const Eigen::Vector3f& force() const { return *f_ptr; }
117  */
118 
119  inline Atom& atom(){ return *atom_ptr; }
120  inline const Atom& atom() const { return *atom_ptr; }
121 
122  inline int& atomic_number(){ return atom_ptr->atomic_number; }
123  inline const int& atomic_number() const { return atom_ptr->atomic_number; }
124 
125  std::string element_name() const;
126 
127  float vdw() const;
129 
130 private:
131  AtomIterator atom_ptr;
132  AtomStateIterator coord_ptr;
133  // Atom don't store it's own index, so store it here
134  int ind;
135 };
136 
137 } //namespace
138 
139 
140 
pteros::Selection
Selection class.
Definition: selection.h:65
pteros::System
The system of atoms.
Definition: system.h:93
pteros::AtomHandler
Auxilary type used to incapsulate the atom and its current coordinates Used internally in Selection::...
Definition: atom_handler.h:49
pteros::Atom
Class which represents a single atom.
Definition: atom.h:39