NetSci
Loading...
Searching...
No Matches
atom.h
1//
2// Created by astokely on 5/4/23.
3//
4
5#ifndef NETSCI_ATOM_H
6#define NETSCI_ATOM_H
7
8#include <string>
9#include "cuarray.h"
10#include "nlohmann/json.hpp"
11
12class Atom {
13public:
14 /**
15 * \brief Default constructor for Atom.
16 *
17 * Constructs an empty Atom object.
18 */
20
21 /**
22 * \brief Constructor for Atom with PDB line.
23 *
24 * Constructs an Atom object using the provided PDB line. The constructor parses the PDB line to extract
25 * the relevant atom information, such as index, name, element, residue name, residue ID, chain ID, segment ID,
26 * temperature factor, occupancy, serial number, atom tag, mass, and hash.
27 *
28 * The PDB line should follow the standard PDB format for ATOM records as described in Section 9 of the PDB file format documentation:
29 * \see https://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM
30 *
31 * \param pdbLine The PDB line containing atom information in the standard PDB format.
32 */
33 explicit Atom(const std::string &pdbLine);
34
35 /**
36 * \brief Constructor for Atom with PDB line and atom index.
37 *
38 * Constructs an Atom object using the provided PDB line and atom index.
39 *
40 * \param pdbLine The PDB line containing atom information.
41 * \param atomIndex The atom index.
42 */
44 const std::string &pdbLine,
45 int atomIndex
46 );
47
48 /**
49 * \brief Get the atom index.
50 *
51 * Returns the atom index.
52 *
53 * \return The atom index.
54 *
55 * @PythonExample{NetChem_Atom_index.py}
56 */
57 int index() const;
58
59 /**
60 * \brief Get the atom name.
61 *
62 * Returns the atom name.
63 *
64 * \return The atom name.
65 *
66 * @PythonExample{NetChem_Atom_name.py}
67 */
68 std::string name();
69
70 /**
71 * \brief Get the atom element.
72 *
73 * Returns the atom element.
74 *
75 * \return The atom element.
76 *
77 * @PythonExample{NetChem_Atom_element.py}
78 */
79 std::string element();
80
81 /**
82 * \brief Get the residue name.
83 *
84 * Returns the residue name.
85 *
86 * \return The residue name.
87 *
88 * @PythonExample{NetChem_Atom_residueName.py}
89 */
90 std::string residueName();
91
92 /**
93 * \brief Get the residue ID.
94 *
95 * Returns the residue ID.
96 *
97 * \return The residue ID.
98 *
99 * @PythonExample{NetChem_Atom_residueId.py}
100 */
101 int residueId() const;
102
103 /**
104 * \brief Get the chain ID.
105 *
106 * Returns the chain ID.
107 *
108 * \return The chain ID.
109 *
110 * @PythonExample{NetChem_Atom_chainId.py}
111 */
112 std::string chainId();
113
114 /**
115 * \brief Get the segment ID.
116 *
117 * Returns the segment ID.
118 *
119 * \return The segment ID.
120 *
121 * @PythonExample{NetChem_Atom_segmentId.py}
122 */
123 std::string segmentId();
124
125 /**
126 * \brief Get the temperature factor.
127 *
128 * Returns the temperature factor.
129 *
130 * \return The temperature factor.
131 *
132 * @PythonExample{NetChem_Atom_temperatureFactor.py}
133 */
134 float temperatureFactor() const;
135
136 /**
137 * \brief Get the occupancy.
138 *
139 * Returns the occupancy.
140 *
141 * \return The occupancy.
142 *
143 * @PythonExample{NetChem_Atom_occupancy.py}
144 */
145 float occupancy() const;
146
147 /**
148 * \brief Get the serial number.
149 *
150 * Returns the serial number, which is one greater than the atom index.
151 *
152 * \return The serial number.
153 *
154 * @PythonExample{NetChem_Atom_serial.py}
155 */
156 int serial() const;
157
158 /**
159 * \brief Get the atom tag.
160 *
161 * Returns the atom tag, which is the concatenation of the residue name,
162 * residue ID, chain ID, and segment ID.
163 *
164 * \return The atom tag.
165 *
166 * @PythonExample{NetChem_Atom_tag.py}
167 */
168 std::string tag();
169
170 /**
171 * \brief Get the mass of the atom.
172 *
173 * Returns the mass of the atom.
174 *
175 * \return The mass of the atom.
176 *
177 * @PythonExample{NetChem_Atom_mass.py}
178 */
179 float mass() const;
180
181 /**
182 * \brief Get the hash of the atom.
183 *
184 * Returns the hash of the atom, which is calculated from the atom tag
185 * concatenated with the atom index.
186 *
187 * \return The hash of the atom.
188 */
189 unsigned int hash() const;
190
191 /**
192 * \brief Get the x-coordinate of the atom.
193 *
194 * Returns the x-coordinate of the atom at the specified frame.
195 *
196 * \param coordinates The CuArray containing the coordinates.
197 * \param frame The frame index.
198 * \param numFrames The total number of frames.
199 * \return The x-coordinate of the atom.
200 */
201 float x(
202 CuArray<float> *coordinates,
203 int frame,
204 int numFrames
205 ) const;
206
207 /**
208 * \brief Get the y-coordinate of the atom.
209 *
210 * Returns the y-coordinate of the atom at the specified frame.
211 *
212 * \param coordinates The CuArray containing the coordinates.
213 * \param frame The frame index.
214 * \param numFrames The total number of frames.
215 * \return The y-coordinate of the atom.
216 */
217 float y(
218 CuArray<float> *coordinates,
219 int frame,
220 int numFrames
221 ) const;
222
223 /**
224 * \brief Get the z-coordinate of the atom.
225 *
226 * Returns the z-coordinate of the atom at the specified frame.
227 *
228 * \param coordinates The CuArray containing the coordinates.
229 * \param frame The frame index.
230 * \param numFrames The total number of frames.
231 * \return The z-coordinate of the atom.
232 */
233 float z(
234 CuArray<float> *coordinates,
235 int frame,
236 int numFrames
237 ) const;
238
239 /**
240 * \brief Load atom information from a JSON file.
241 *
242 * Loads atom information from the specified JSON file.
243 *
244 * \param jsonFile The name of the JSON file to load.
245 */
246 void load(const std::string &jsonFile);
247
248private:
249 friend nlohmann::adl_serializer<Atom>;
250 friend nlohmann::adl_serializer<Atom *>;
251
252 int _index; // Atom index. Atom indexing starts at 0
253 std::string _name; // Atom name (e.g., CA)
254 std::string _element; // Atom element (e.g., C)
255 std::string _residueName; // Residue name (e.g., ALA)
256 int _residueId; // Residue ID (e.g., 1). Residue indexing starts at 1
257 std::string _chainId; // Chain ID (e.g., A)
258 std::string _segmentId; // Segment ID (e.g., A)
259 float _temperatureFactor; // Temperature factor
260 float _occupancy; // Occupancy
261 int _serial; // Serial number, which is 1 greater than the atom index
262 std::string _tag; // Atom tag, concatenation of residue name, residue ID, chain ID, and segment ID
263 float _mass; // Mass of the atom
264 unsigned int _hash; // Hash of the atom tag concatenated with the atom index
265};
266
267#endif // NETSCI_ATOM_H
268
Definition atom.h:12
float x(CuArray< float > *coordinates, int frame, int numFrames) const
Get the x-coordinate of the atom.
unsigned int hash() const
Get the hash of the atom.
float occupancy() const
Get the occupancy.
int index() const
Get the atom index.
float z(CuArray< float > *coordinates, int frame, int numFrames) const
Get the z-coordinate of the atom.
void load(const std::string &jsonFile)
Load atom information from a JSON file.
float temperatureFactor() const
Get the temperature factor.
int residueId() const
Get the residue ID.
std::string residueName()
Get the residue name.
Atom()
Default constructor for Atom.
std::string chainId()
Get the chain ID.
std::string tag()
Get the atom tag.
std::string name()
Get the atom name.
std::string segmentId()
Get the segment ID.
int serial() const
Get the serial number.
Atom(const std::string &pdbLine, int atomIndex)
Constructor for Atom with PDB line and atom index.
float y(CuArray< float > *coordinates, int frame, int numFrames) const
Get the y-coordinate of the atom.
Atom(const std::string &pdbLine)
Constructor for Atom with PDB line.
std::string element()
Get the atom element.
float mass() const
Get the mass of the atom.
Manages CUDA-supported arrays, offering initialization, memory management, and data manipulation....
Definition cuarray.h:24