STORMM Source Documentation
Loading...
Searching...
No Matches
pdb.h
1// -*-c++-*-
2#ifndef STORMM_PDB_H
3#define STORMM_PDB_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "Accelerator/hybrid.h"
9#include "Accelerator/gpu_enumerators.h"
10#include "DataTypes/stormm_vector_types.h"
11#include "FileManagement/file_enumerators.h"
12#include "Parsing/textfile.h"
13#include "Synthesis/condensate.h"
14#include "Synthesis/phasespace_synthesis.h"
15#include "Topology/atomgraph.h"
16#include "Topology/atomgraph_enumerators.h"
17#include "Trajectory/coordinateframe.h"
18#include "Trajectory/coordinate_series.h"
19#include "Trajectory/phasespace.h"
20#include "molecule_format_enumerators.h"
21
22namespace stormm {
23namespace structure {
24
25using card::default_hpc_format;
26using card::HybridFormat;
27using diskutil::PrintSituation;
28using parse::TextFile;
29using synthesis::Condensate;
30using synthesis::PhaseSpaceSynthesis;
31using topology::AtomGraph;
32using topology::UnitCellType;
33using trajectory::CoordinateFrame;
34using trajectory::CoordinateSeries;
35using trajectory::PhaseSpace;
36
37class Pdb {
38public:
39
71 Pdb(int atom_count_in = 0, int model_count_in = 1);
72
73 Pdb(const std::string &file_name_in, int model_index = -1,
74 const std::vector<char> &alternate_prefs = { ' ', 'A' });
75
76 Pdb(const std::string &file_name_in, const std::vector<int> &model_indices,
77 const std::vector<char> &alternate_prefs = { ' ', 'A' });
78
79 Pdb(int atom_count_in, int model_count_in, const std::vector<double> &x_coordinates_in,
80 const std::vector<double> &y_coordinates_in, const std::vector<double> &z_coordinates_in,
81 const std::vector<char4> &atom_names_in, const std::vector<char4> &residue_names_in,
82 const std::vector<char> &chain_names_in, const std::vector<double> &occupancies_in,
83 const std::vector<double> &b_factors_in, const std::vector<char2> &elements_in = {},
84 const std::vector<int> &atom_numbers_in = {},
85 const std::vector<int> &residue_numbers_in = {},
86 const std::vector<int> &anisotropy_matrices_in = {},
87 const std::vector<PdbAtomKind> &atom_classes_in = {},
88 const std::vector<std::string> &header_in = {},
89 const std::vector<std::string> &remark_in = {},
90 const std::vector<std::string> &extras_in = {});
91
92 Pdb(const AtomGraph *ag, const CoordinateFrame *cf);
93
94 Pdb(const AtomGraph &ag, const CoordinateFrame &cf);
95
96 Pdb(const AtomGraph *ag, const PhaseSpace *ps);
97
98 Pdb(const AtomGraph &ag, const PhaseSpace &ps);
99
100 template <typename T>
101 Pdb(const AtomGraph *ag, const CoordinateSeries<T> *cf, const std::vector<int> &frames = {});
102
103 template <typename T>
104 Pdb(const AtomGraph &ag, const CoordinateSeries<T> &cf, const std::vector<int> &frames = {});
105
106 template <typename T> Pdb(const AtomGraph *ag, const CoordinateSeries<T> *cs, int frame_number);
107
108 template <typename T> Pdb(const AtomGraph &ag, const CoordinateSeries<T> &cs, int frame_number);
110
112 int getAtomCount() const;
113
115 int getModelCount() const;
116
119 bool getFormalChargePrinting() const;
120
128 HybridFormat layout = default_hpc_format) const;
129
133 PhaseSpace exportPhaseSpace(int model_index, HybridFormat layout = default_hpc_format) const;
134
141 template <typename T>
142 CoordinateSeries<T> getCoordinateSeries(const std::vector<int> model_sequence = {}) const;
143
148 void writeToFile(const std::string &file_name, PrintSituation expectation,
149 const std::vector<int> &model_indices = {}) const;
150
162 void loadTopologicalData(const AtomGraph *ag);
163 void loadTopologicalData(const AtomGraph &ag);
165
194 template <typename T>
195 void loadCoordinates(const T* xcrd_in, const T* ycrd_in, const T* zcrd_in, int model_index = 0,
196 double gpos_scale = 1.0);
197
198 void loadCoordinates(const llint* xcrd_in, const llint* ycrd_in, const llint* zcrd_in,
199 const int* xcrd_ovrf, const int* ycrd_ovrf, const int* zcrd_ovrf,
200 double gpos_scale = 1.0, int model_index = 0);
201
202 void loadCoordinates(const CoordinateFrame *cf, int model_index = 0);
203
204 void loadCoordinates(const CoordinateFrame &cf, int model_index = 0);
205
206 void loadCoordinates(const PhaseSpace *ps, int model_index = 0);
207
208 void loadCoordinates(const PhaseSpace &ps, int model_index = 0);
209
210 template <typename T>
211 void loadCoordinates(const CoordinateSeries<T> *cs, const std::vector<int2> &frame_mapping = {});
212
213 template <typename T>
214 void loadCoordinates(const CoordinateSeries<T> &cs, const std::vector<int2> &frame_mapping = {});
215
216 void loadCoordinates(const PhaseSpaceSynthesis *poly_ps, int system_index, int model_index = 0);
217
218 void loadCoordinates(const PhaseSpaceSynthesis &poly_ps, int system_index, int model_index = 0);
219
220 void loadCoordinates(const Condensate *cdns, int system_index, int model_index = 0);
221
222 void loadCoordinates(const Condensate &cdns, int system_index, int model_index = 0);
224
228 void setFormalChargePrinting(bool print_formal_charges_in = true);
229
230private:
231 std::string file_name;
233 int atom_count;
234 int model_count;
238 int padded_atom_count;
241 int ter_card_count;
245 UnitCellType unit_cell;
246 std::vector<PdbAtomKind> atom_classes;
247 std::vector<int> atom_numbers;
250 std::vector<char4> atom_names;
253 std::vector<char4> residue_names;
256 std::vector<char> chain_names;
257 std::vector<int> residue_numbers;
260 std::vector<double> x_coordinates;
261 std::vector<double> y_coordinates;
262 std::vector<double> z_coordinates;
263 std::vector<double> box_dimensions;
269 std::vector<double> occupancies;
272 std::vector<double> b_factors;
273 std::vector<char2> atom_symbols;
274 std::vector<int> atom_formal_charges;
275 std::vector<int> ter_card_locations;
281
282 // The following are anisotropic temperature factors for each atom, providing the six unique
283 // elements of each atom's matrix.
284 std::vector<int> anisotropy_xx;
285 std::vector<int> anisotropy_xy;
286 std::vector<int> anisotropy_xz;
287 std::vector<int> anisotropy_yy;
288 std::vector<int> anisotropy_yz;
289 std::vector<int> anisotropy_zz;
290
291 // The following are output settings which will be called upon when printing the Pdb object's
292 // contents to a file.
293 bool print_formal_charges;
294
297 void allocate();
298
307 void computeTransforms(const int model_index, std::vector<double> *umat,
308 std::vector<double> *invu) const;
309
316 int countAtomRecords(const TextFile &tf, int line_start = 0, int line_end = -1) const;
317
325 void readAtomRecords(const TextFile &tf, int line_start, int line_end, int atom_start,
326 const std::vector<char> &alternate_prefs = { ' ', 'A' });
327
335 void seekUnitCellDimensions(const TextFile &tf, int line_start, int line_end, int box_start);
336
341 void validateModelIndex(int model_index, const char* caller = nullptr) const;
342
347 void writeModel(std::ofstream *foutp, const int model_index) const;
348};
349
350} // namespace structure
351} // namespace stormm
352
353#include "pdb.tpp"
354
355#endif
Pdb(int atom_count_in=0, int model_count_in=1)
The constructor can accept a file to read, arrays of data to compile, or a simple number of atoms for...
Definition pdb.cpp:45
CoordinateSeries< T > getCoordinateSeries(const std::vector< int > model_sequence={}) const
Produce a CoordinateSeries object based on the particle positions in a sequence of models.
PhaseSpace exportPhaseSpace(int model_index, HybridFormat layout=default_hpc_format) const
Produce a PhaseSpace object (with zero velocity and force components) based on the particle positions...
Definition pdb.cpp:265
int getAtomCount() const
Get the number of atoms in the structure (the number of atoms per model).
Definition pdb.cpp:189
void loadCoordinates(const T *xcrd_in, const T *ycrd_in, const T *zcrd_in, int model_index=0, double gpos_scale=1.0)
Load coordinates into the object from various coordinate objects.
bool getFormalChargePrinting() const
Get the object's current directive on whether to print formal charges to any output files.
Definition pdb.cpp:199
void setFormalChargePrinting(bool print_formal_charges_in=true)
Set whether to print formal charges in any output files.
Definition pdb.cpp:487
CoordinateFrame exportCoordinateFrame(int model_index, HybridFormat layout=default_hpc_format) const
Produce a CoordinateFrame object from a specific model index.
Definition pdb.cpp:204
void writeToFile(const std::string &file_name, PrintSituation expectation, const std::vector< int > &model_indices={}) const
Write the contents of the object to a PDB file.
Definition pdb.cpp:348
int getModelCount() const
Get the number of models in the object.
Definition pdb.cpp:194
void loadTopologicalData(const AtomGraph *ag)
Transcribe information from a topology into the object. This includes atom names, symbols,...
Definition pdb.cpp:371
A struct to hold information relating to an Amber topology. This struct's member functions are limite...
Definition atomgraph.h:50
Store the coordinates and box information for a frame, only. This abridged struct can serve when the ...
Definition coordinateframe.h:111
Store the coordinates and box information for a series of frames, in one of several levels of precisi...
Definition coordinate_series.h:137
An object to complement a topology and hold positions, velocities, and forces of all particles in a s...
Definition phasespace.h:141