STORMM Source Documentation
Loading...
Searching...
No Matches
atommask.h
1// -*-c++-*-
2#ifndef STORMM_AMBMASK_H
3#define STORMM_AMBMASK_H
4
5#include <string>
6#include <vector>
7#include <climits>
8#include "copyright.h"
9#include "Constants/behavior.h"
10#include "Topology/atomgraph.h"
11#include "Trajectory/coordinateframe.h"
12#include "Trajectory/phasespace.h"
13#include "chemical_features.h"
14
15namespace stormm {
16namespace chemistry {
17
18using constants::ExceptionResponse;
19using parse::WildCardKind;
20using topology::AtomGraph;
21using trajectory::CoordinateFrame;
22using trajectory::PhaseSpace;
23
26enum class MaskOperator {
27 NONE,
28 ATOM_LT,
29 ATOM_LE,
30 ATOM_GT,
31 ATOM_GE,
32 RESIDUE_LT,
33 RESIDUE_GT,
34 RESIDUE_LE,
35 RESIDUE_GE,
36 AND,
37 OR,
38 NOT
39};
40
43enum class SelectionItemKind {
44 ATOM_NAME,
45 ATOM_NUMBER,
46 ELEMENT_NAME,
47 ELEMENT_NUMBER,
48 ATOM_TYPE,
50 RESIDUE_NAME,
52 RESIDUE_NUMBER,
53#if 0
54 RING_SIZE,
55#endif
56 NONE
57};
58
64public:
65
75 SelectionItem(const SelectionItemKind kind_in, const char4 name_in,
76 const std::vector<WildCardKind> &wildcards_in);
77 SelectionItem(const SelectionItemKind kind_in, const int begin_in, const int end_in = INT_MIN);
79
80 SelectionItemKind kind;
83 std::vector<WildCardKind> wildcards;
86};
87
89enum class MaskComponentKind {
90 OPERATOR,
92 MASK
93};
94
99public:
100
114 MaskComponent(MaskOperator op_in, const std::string &basis_in, int start_idx, int end_idx);
115 MaskComponent(MaskOperator op_in, double range, const std::string &basis_in, int start_idx,
116 int end_idx);
117 MaskComponent(const std::vector<SelectionItem> &parts_in, const AtomGraph *ag,
118 const ChemicalFeatures &chemfe, const std::string &basis_in, int start_idx,
119 int end_idx);
120 MaskComponent(const std::vector<uint> &primitive_mask_in, const std::string &basis_in,
121 int start_idx, int end_idx);
123
125 MaskComponentKind getKind() const;
126
128 MaskOperator getOperator() const;
129
131 std::vector<uint> getMask() const;
132
134 std::string getText() const;
135
138 int2 getTextLimits() const;
139
141 void applyNotOperator();
142
146 void applyAndOperator(const std::vector<uint> &other);
147
151 void applyOrOperator(const std::vector<uint> &other);
152
165 MaskComponent applyRangeOperator(const std::vector<uint> &other, const AtomGraph *ag,
166 const CoordinateFrameReader &cfr);
167
168private:
169 MaskComponentKind kind;
170 MaskOperator op;
171 double range;
172 std::vector<uint> primitive_mask;
173 std::string text_basis;
174 int2 text_limits;
175};
176
182enum class MaskTraversalMode {
183 COMPLETE,
184 PARTIAL,
185 SEGMENTED
187};
188
190enum class MaskInputMode {
191 AMBMASK,
192 VMD
193};
194
199class AtomMask {
200public:
201
224 AtomMask(const AtomGraph *ag_in = nullptr);
225
226 AtomMask(const std::string &input_text_in, const AtomGraph *ag_in,
227 const ChemicalFeatures &chemfe, const CoordinateFrameReader &cfr,
228 MaskInputMode mode = MaskInputMode::AMBMASK,
229 const std::string &description_in = std::string("No description provided"));
230
231 AtomMask(const std::string &input_text_in, const AtomGraph *ag_in,
232 const ChemicalFeatures &chemfe, const CoordinateFrame &cf,
233 MaskInputMode mode = MaskInputMode::AMBMASK,
234 const std::string &description_in = std::string("No description provided"));
235
236 AtomMask(const std::string &input_text_in, const AtomGraph *ag_in,
237 const ChemicalFeatures &chemfe, const PhaseSpace &ps,
238 MaskInputMode mode = MaskInputMode::AMBMASK,
239 const std::string &description_in = std::string("No description provided"));
241
246 AtomMask(const AtomMask &original) = default;
247 AtomMask(AtomMask &&original) = default;
249
251 MaskTraversalMode getRecommendation() const;
252
255 const std::vector<uint>& getRawMask() const;
256
258 int getMaskedAtomCount() const;
259
262 std::vector<bool> getMask() const;
263
264 // \brief Get a list of the masked atoms
265 std::vector<int> getMaskedAtomList() const;
266
269 std::vector<int2> getSegments() const;
270
272 std::string getInputText() const;
273
276 MaskInputMode getInputKind() const;
277
279 std::string getDescription() const;
280
282 const AtomGraph* getTopologyPointer() const;
283
297 bool isAtomInMask(const char4 atom_name) const;
298 bool isAtomInMask(const char4 res_name, const char4 atom_name) const;
299 bool isAtomInMask(int atom_index) const;
301
318 void addAtoms(const std::vector<int> &new_indices,
319 ExceptionResponse policy = ExceptionResponse::DIE);
320
321 void addAtoms(const std::vector<char4> &new_names);
322
323 void addAtoms(const AtomMask &new_mask, const CoordinateFrame &cf,
324 const ChemicalFeatures &chemfe);
325
326 void addAtoms(const std::string &new_mask, const CoordinateFrame &cf,
327 const ChemicalFeatures &chemfe);
328
329 void addAtoms(const AtomMask &new_mask, const CoordinateFrame &cf);
330
331 void addAtoms(const std::string &new_mask, const CoordinateFrame &cf);
333
334private:
335 MaskTraversalMode recommended_scan;
336 MaskInputMode style;
337 int masked_atom_count;
338 std::vector<uint> raw_mask;
339 std::vector<int2> segments;
340 std::string input_text;
342 std::string description;
344 const AtomGraph *ag_pointer;
345
352 double extractRangeValue(int start_char, int final_char, int *position);
353
361 std::vector<SelectionItem> evaluateInclusions(const std::string &inclusion_list);
362
368 std::vector<uint> parseMask(const std::vector<int> &scope_levels, int *position,
369 const CoordinateFrameReader &cfr, const ChemicalFeatures &chemfe);
370};
371
372} // namespace chemistry
373} // namespace stormm
374
375#endif
const AtomGraph * getTopologyPointer() const
Get a pointer to the topology that this mask describes.
Definition atommask.cpp:597
MaskInputMode getInputKind() const
Get the input text mode, e.g. AMBMASK to indicate that an Amber-style atom mask string was used to ma...
Definition atommask.cpp:587
int getMaskedAtomCount() const
Get a count of the number of masked atoms.
Definition atommask.cpp:546
MaskTraversalMode getRecommendation() const
Get the recommendation for scanning this mask.
Definition atommask.cpp:536
AtomMask(const AtomMask &original)=default
AtomMask(const AtomGraph *ag_in=nullptr)
Constructor takes a mask string, topology, and coordinates.
Definition atommask.cpp:462
void addAtoms(const std::vector< int > &new_indices, ExceptionResponse policy=ExceptionResponse::DIE)
Add atoms to the atom mask.
Definition atommask.cpp:641
std::vector< int2 > getSegments() const
Get the segments of atoms over which the mask applies (only filled out if the recommended scanning me...
Definition atommask.cpp:577
std::string getDescription() const
Get the description of the mask, if provided.
Definition atommask.cpp:592
const std::vector< uint > & getRawMask() const
Get the raw mask as a vector of unsigned long integers (bit strings storing whether each atom is mask...
Definition atommask.cpp:541
std::vector< bool > getMask() const
Get the mask as a vector of boolean values (not just a bit mask as the object stores privately)
Definition atommask.cpp:551
bool isAtomInMask(const char4 atom_name) const
Answer whether an atom is in the mask.
Definition atommask.cpp:602
std::string getInputText() const
Get the input text used to generate this atom mask.
Definition atommask.cpp:582
An object to store information about chemical motifs: participation in rings, planarity,...
Definition chemical_features.h:400
MaskComponent applyRangeOperator(const std::vector< uint > &other, const AtomGraph *ag, const CoordinateFrameReader &cfr)
Apply one of the ranged operators. This will produce a new MASK-kind MaskComponent....
Definition atommask.cpp:297
MaskComponent(MaskOperator op_in, const std::string &basis_in, int start_idx, int end_idx)
Constructor takes either an operator designation or a series of atoms or residues.
Definition atommask.cpp:50
std::string getText() const
Get the textual basis of this mask component.
Definition atommask.cpp:266
MaskOperator getOperator() const
Get the operator, if relevant.
Definition atommask.cpp:250
std::vector< uint > getMask() const
Get the bitmask, if relevant.
Definition atommask.cpp:258
int2 getTextLimits() const
Get the indices from within the original mask string where this component's textual basis is to be fo...
Definition atommask.cpp:271
MaskComponentKind getKind() const
Get the kind of component.
Definition atommask.cpp:245
void applyOrOperator(const std::vector< uint > &other)
Apply the OR operator to a primitive mask, given another primitive mask.
Definition atommask.cpp:290
void applyAndOperator(const std::vector< uint > &other)
Apply the AND operator to a primitive mask, given another primitive mask.
Definition atommask.cpp:283
void applyNotOperator()
Apply the NOT operator to a primitive mask.
Definition atommask.cpp:276
SelectionItem(const SelectionItemKind kind_in, const char4 name_in, const std::vector< WildCardKind > &wildcards_in)
Initialization for this struct makes it simpler to create an array of such objects and be assured tha...
Definition atommask.cpp:30
char4 name
Definition atommask.h:81
int scan_begin
Point at which to begin the scan.
Definition atommask.h:84
SelectionItemKind kind
Indicates the type of selection, i.e. atom name.
Definition atommask.h:80
std::vector< WildCardKind > wildcards
Indicators of wildcards in the name.
Definition atommask.h:83
int scan_end
Point at which to end the scan.
Definition atommask.h:85
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
An object to complement a topology and hold positions, velocities, and forces of all particles in a s...
Definition phasespace.h:141
Definition stormm_vector_types.h:141
Definition stormm_vector_types.h:22
Collect C-style pointers for the elements of a read-only CoordinateFrame object.
Definition coordinateframe.h:65