STORMM Source Documentation
Loading...
Searching...
No Matches
nml_files.h
1// -*-c++-*-
2#ifndef STORMM_NML_FILES_H
3#define STORMM_NML_FILES_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "Constants/behavior.h"
9#include "Parsing/textfile.h"
10#include "Trajectory/trajectory_enumerators.h"
11#include "input.h"
12#include "namelist_emulator.h"
13
14namespace stormm {
15namespace namelist {
16
17using constants::ExceptionResponse;
18using constants::ModificationPolicy;
19using parse::WrapTextSearch;
20using trajectory::CoordinateFileKind;
21using trajectory::TrajectoryFusion;
22
26constexpr bool default_filecon_read_all_free = false;
27constexpr char default_filecon_topology_name[] = "prmtop";
28constexpr char default_filecon_coordinate_name[] = "inpcrd";
29constexpr char default_filecon_report_name[] = "md.out";
30constexpr char default_filecon_trajectory_name[] = "md.crd";
31constexpr char default_filecon_checkpoint_name[] = "md.rst";
32constexpr char default_filecon_warnings_name[] = "warn.out";
33constexpr char default_filecon_errors_name[] = "err.out";
34constexpr char default_filecon_result_fusion[] = "AUTO";
35constexpr char default_filecon_sdf_mod_policy[] = "NO";
36constexpr char default_filecon_sdf_notification[] = "WARN";
37constexpr CoordinateFileKind default_filecon_inpcrd_type = CoordinateFileKind::UNKNOWN;
38constexpr CoordinateFileKind default_filecon_outcrd_type = CoordinateFileKind::AMBER_CRD;
39constexpr CoordinateFileKind default_filecon_chkcrd_type = CoordinateFileKind::AMBER_ASCII_RST;
40constexpr char default_filecon_inpcrd_type_name[] = "AMBER_INPCRD";
41constexpr char default_filecon_outcrd_type_name[] = "AMBER_CRD";
42constexpr char default_filecon_chkcrd_type_name[] = "AMBER_ASCII_RST";
44
49public:
50
73 MoleculeSystem(const std::string &topology_file_in, const std::string &coordinate_file_in,
74 const std::string &trajectory_file_in, const std::string &checkpoint_file_in,
75 const std::string &label_in, int frame_start_in, int frame_end_in,
76 int replica_count_in, CoordinateFileKind coordinate_kind_in,
77 CoordinateFileKind trajectory_kind_in, CoordinateFileKind checkpoint_kind_in);
79
83 MoleculeSystem(const MoleculeSystem &original) = default;
84 MoleculeSystem(MoleculeSystem &&original) = default;
85 MoleculeSystem& operator=(const MoleculeSystem &original) = default;
86 MoleculeSystem& operator=(MoleculeSystem &&original) = default;
88
90 const std::string& getTopologyFileName() const;
91
93 const std::string& getInputCoordinateFileName() const;
94
96 const std::string& getTrajectoryFileName() const;
97
99 const std::string& getCheckpointFileName() const;
100
102 const std::string& getLabel() const;
103
105 int getStartingFrame() const;
106
108 int getFinalFrame() const;
109
111 int getTotalFrames() const;
112
115 int getReplicaCount() const;
116
118 CoordinateFileKind getInputCoordinateFileKind() const;
119
121 CoordinateFileKind getTrajectoryFileKind() const;
122
124 CoordinateFileKind getCheckpointFileKind() const;
125
128 void setTopologyFileName(const std::string &file_name);
129
133 void setInputCoordinateFileName(const std::string &file_name);
134
138 void setTrajectoryFileName(const std::string &file_name);
139
143 void setCheckpointFileName(const std::string &file_name);
144
149 void setStartingFrame(int frame_number);
150
155 void setFinalFrame(int frame_number);
156
160 void setReplicaCount(int count);
161
170 void setInputCoordinateFileKind(const std::string &kind);
171 void setInputCoordinateFileKind(CoordinateFileKind kind);
173
182 void setTrajectoryFileKind(const std::string &kind);
183 void setTrajectoryFileKind(CoordinateFileKind kind);
185
194 void setCheckpointFileKind(const std::string &kind);
195 void setCheckpointFileKind(CoordinateFileKind kind);
197
201 bool validateTopologyFile() const;
202
204 bool validateInputCoordinateFile() const;
205
206private:
207 std::string topology_file_name;
208 std::string coordinate_file_name;
209 std::string coordinate_output_name;
212 std::string checkpoint_name;
215 std::string label;
216 int frame_start;
217 int frame_end;
220 int replica_count;
221 CoordinateFileKind coordinate_kind;
222 CoordinateFileKind trajectory_kind;
223 CoordinateFileKind checkpoint_kind;
224};
225
230public:
231
262 FilesControls(ExceptionResponse policy_in = ExceptionResponse::DIE,
263 WrapTextSearch wrap = WrapTextSearch::NO);
264 FilesControls(const TextFile &tf, int *start_line, bool *found_nml = nullptr,
265 ExceptionResponse policy_in = ExceptionResponse::DIE,
266 WrapTextSearch wrap = WrapTextSearch::NO,
267 const std::vector<std::string> &alternatives = {},
268 const std::vector<std::string> &sys_requirements = {"-pe", "-ce"});
270
274 FilesControls(const FilesControls &original) = default;
275 FilesControls(FilesControls &&original) = default;
276 FilesControls& operator=(const FilesControls &original) = default;
277 FilesControls& operator=(FilesControls &&original) = default;
279
284 int getStructureCount() const;
285
287 int getFreeTopologyCount() const;
288
290 int getFreeCoordinatesCount() const;
291
293 int getSystemDefinitionCount() const;
294
296 bool readAllFreeFrames() const;
297
299 CoordinateFileKind getOutputCoordinateFormat() const;
300
302 CoordinateFileKind getCheckpointFormat() const;
303
305 TrajectoryFusion getFileFusionProtocol() const;
306
315 std::string getFreeTopologyName(int index) const;
316 std::vector<std::string> getFreeTopologyNames() const;
318
327 std::string getFreeCoordinateName(int index) const;
328 std::vector<std::string> getFreeCoordinateNames() const;
330
334 MoleculeSystem getSystem(int index) const;
335
337 std::string getReportFile() const;
338
341 std::string getInputTranscriptFile() const;
342
344 std::string getTrajectoryFileName() const;
345
347 std::string getCheckpointFileName() const;
348
350 std::string getWarningFileName() const;
351
353 ModificationPolicy getSdfModificationPolicy() const;
354
357 ExceptionResponse getSdfNotifications() const;
358
360 const NamelistEmulator& getTranscript() const;
361
366 void setAllFreeFrameReading(const bool active);
367
376 void setOutputCoordinateFormat(const std::string &traj_kind);
377 void setOutputCoordinateFormat(CoordinateFileKind traj_kind);
379
388 void setCheckpointFormat(const std::string &chk_kind);
389 void setCheckpointFormat(CoordinateFileKind chk_kind);
391
395 void addFreeTopologyName(const std::string &file_name);
396
406 void removeFreeTopologyName(int index, int stretch = 1);
407 void removeFreeTopologyName(const std::string &fname);
409
413 void addFreeCoordinateName(const std::string &file_name);
414
424 void removeFreeCoordinateName(int index, int stretch = 1);
425 void removeFreeCoordinateName(const std::string &fname);
427
431 void addSystem(const MoleculeSystem &new_mol);
432
437 void removeSystem(int index, int stretch = 1);
438
442 void setReportFileName(const std::string &file_name);
443
447 void setInputTranscriptFileName(const std::string &file_name);
448
452 void setGeneralTrajectoryFileName(const std::string &proto_name);
453
457 void setGeneralCheckpointFileName(const std::string &proto_name);
458
462 void setWarningFileName(const std::string &file_name);
463
467 void setSdfModficiationPolicy(ModificationPolicy policy_in);
468
472 void setSdfNotifications(ExceptionResponse policy_in);
473
474private:
475
477 ExceptionResponse policy;
478
479 // Counts of critical data
480 int structure_count;
485 int free_topology_count;
487 int free_coordinate_count;
489 int system_count;
490 bool all_free_frames;
492 TrajectoryFusion fuse_files;
494
496 CoordinateFileKind coordinate_input_format;
497
499 CoordinateFileKind coordinate_output_format;
500
502 CoordinateFileKind coordinate_checkpoint_format;
503
507 std::vector<std::string> topology_file_names;
508
514 std::vector<std::string> coordinate_file_names;
515
520 std::vector<MoleculeSystem> systems;
521
524 std::string report_file;
525
528 std::string input_transcript_file;
529
538 std::string coordinate_output_name;
539
542 std::string checkpoint_name;
543
545 std::string warning_file_name;
546
549 ModificationPolicy sdf_mod_policy;
550
553 ExceptionResponse sdf_mod_alert;
554
556 NamelistEmulator nml_transcript;
557};
558
586filesInput(const TextFile &tf, int *start_line, bool *found,
587 const std::vector<KeyRequirement> &sys_keyword_reqs,
588 ExceptionResponse policy = ExceptionResponse::DIE,
589 WrapTextSearch wrap = WrapTextSearch::NO,
590 CoordinateFileKind crd_input_format = default_filecon_inpcrd_type,
591 CoordinateFileKind crd_output_format = default_filecon_outcrd_type,
592 CoordinateFileKind crd_checkpoint_format = default_filecon_chkcrd_type);
593
595filesInput(const TextFile &tf, int *start_line, bool *found, ExceptionResponse policy,
596 WrapTextSearch wrap);
598
599} // namespace namelist
600} // namespace stormm
601
602#endif
int getFreeCoordinatesCount() const
Get the free coordinate file count.
Definition nml_files.cpp:571
void addFreeCoordinateName(const std::string &file_name)
Add a free coordinate file to the list, after checking for its prior existence.
Definition nml_files.cpp:724
void removeSystem(int index, int stretch=1)
Remove entries from the systems array.
Definition nml_files.cpp:765
bool readAllFreeFrames() const
Get the indicator of whether to read all free coordinate files' frames.
Definition nml_files.cpp:581
std::string getCheckpointFileName() const
Get the base name of (coordinate) checkpoint files to write.
Definition nml_files.cpp:641
CoordinateFileKind getOutputCoordinateFormat() const
Get the coordinate (trajectory) file output format.
Definition nml_files.cpp:586
void removeFreeCoordinateName(int index, int stretch=1)
Remove entries from the free coordinates array.
Definition nml_files.cpp:733
void setReportFileName(const std::string &file_name)
Set the report file name.
Definition nml_files.cpp:780
std::string getInputTranscriptFile() const
Get the name of the input transcript file (there is no sander or pmemd equivalent other than the verb...
Definition nml_files.cpp:631
std::string getFreeCoordinateName(int index) const
Get one or more free coordinate file names.
Definition nml_files.cpp:611
void setGeneralCheckpointFileName(const std::string &proto_name)
Set the general (fallback) checkpoint file name.
Definition nml_files.cpp:795
void setWarningFileName(const std::string &file_name)
Set the warning file name.
Definition nml_files.cpp:800
void removeFreeTopologyName(int index, int stretch=1)
Remove entries from the free topologies array.
Definition nml_files.cpp:699
TrajectoryFusion getFileFusionProtocol() const
Get the preferences for fusing output coordinate files.
Definition nml_files.cpp:596
void setSdfModficiationPolicy(ModificationPolicy policy_in)
Set the .sdf output file modification policy.
Definition nml_files.cpp:805
int getStructureCount() const
Get the structure count, based on the number of free coordinate files as well as the number of system...
Definition nml_files.cpp:561
void setOutputCoordinateFormat(const std::string &traj_kind)
Set the coordinate (trajectory) file output format.
Definition nml_files.cpp:671
void setInputTranscriptFileName(const std::string &file_name)
Set the input transcript file name.
Definition nml_files.cpp:785
FilesControls(ExceptionResponse policy_in=ExceptionResponse::DIE, WrapTextSearch wrap=WrapTextSearch::NO)
The constructor can prepare an object with default settings or read the corresponding namelist to acc...
Definition nml_files.cpp:192
std::string getTrajectoryFileName() const
Get the base name of trajectory files to write.
Definition nml_files.cpp:636
ModificationPolicy getSdfModificationPolicy() const
Get the policy on modifying .sdf file outputs to conform to the Biovia standard.
Definition nml_files.cpp:651
std::string getFreeTopologyName(int index) const
Get one or more free topology names.
Definition nml_files.cpp:601
FilesControls(const FilesControls &original)=default
As with other control objects, copy and move constructors, plus copy and move assignment operators,...
std::string getWarningFileName() const
Get the name of the file containing warnings printed by the program.
Definition nml_files.cpp:646
CoordinateFileKind getCheckpointFormat() const
Get the coordinate (checkpoint) file output format.
Definition nml_files.cpp:591
void addFreeTopologyName(const std::string &file_name)
Add a free topology to the list, after checking for its prior existence in the list.
Definition nml_files.cpp:691
std::string getReportFile() const
Get the name of the report file (equivalent to mdout in sander or pmemd)
Definition nml_files.cpp:626
void setAllFreeFrameReading(const bool active)
Set whether to read all frames from each free trajectory (true), or just the first (false).
Definition nml_files.cpp:666
void addSystem(const MoleculeSystem &new_mol)
Add a system to the list.
Definition nml_files.cpp:758
void setGeneralTrajectoryFileName(const std::string &proto_name)
Set the general (fallback) coordinate output file name.
Definition nml_files.cpp:790
void setSdfNotifications(ExceptionResponse policy_in)
Set whether to emit notifications about .sdf output file modifications.
Definition nml_files.cpp:810
void setCheckpointFormat(const std::string &chk_kind)
Set the checkpoint (coordinate) file output format.
Definition nml_files.cpp:681
MoleculeSystem getSystem(int index) const
Get a molecule system from this object's array.
Definition nml_files.cpp:621
const NamelistEmulator & getTranscript() const
Get the original namelist emulator object as a transcript of the user input.
Definition nml_files.cpp:661
int getSystemDefinitionCount() const
Get the number of system specifications made with the -sys keyword.
Definition nml_files.cpp:576
int getFreeTopologyCount() const
Get the free topology count.
Definition nml_files.cpp:566
ExceptionResponse getSdfNotifications() const
Get an indication of whether to alert the user when correcting minor mistakes in ....
Definition nml_files.cpp:656
Object to encapsulate a system, a coupled set of coordinates and a single topology....
Definition nml_files.h:48
MoleculeSystem(const MoleculeSystem &original)=default
This object, containing no const members or pointers to repair, can take the default copy and move co...
int getFinalFrame() const
Get the last frame that this system will read for initial coordinate states.
Definition nml_files.cpp:87
CoordinateFileKind getTrajectoryFileKind() const
Get the type of trajectory file.
Definition nml_files.cpp:107
void setCheckpointFileName(const std::string &file_name)
Set the checkpoint file name.
Definition nml_files.cpp:132
CoordinateFileKind getCheckpointFileKind() const
Get the type of checkpoint file.
Definition nml_files.cpp:112
void setInputCoordinateFileName(const std::string &file_name)
Set the input coordinates file name.
Definition nml_files.cpp:122
const std::string & getTopologyFileName() const
Get the name of the topology file in this system.
Definition nml_files.cpp:57
bool validateTopologyFile() const
Report whether the topology file named in this system is a valid file. This validator is public so th...
Definition nml_files.cpp:182
void setInputCoordinateFileKind(const std::string &kind)
Set the input coordinates file type.
Definition nml_files.cpp:152
CoordinateFileKind getInputCoordinateFileKind() const
Get the type of input coordinate file.
Definition nml_files.cpp:102
void setCheckpointFileKind(const std::string &kind)
Set the checkpoint file type.
Definition nml_files.cpp:172
const std::string & getInputCoordinateFileName() const
Get the name of the input coordinates file.
Definition nml_files.cpp:62
const std::string & getCheckpointFileName() const
Get the name of the checkpoint file to write for this system.
Definition nml_files.cpp:72
void setReplicaCount(int count)
Set the number of replicas.
Definition nml_files.cpp:147
int getTotalFrames() const
Get the total number of frames, thus initial states, that this system expects.
Definition nml_files.cpp:92
void setTopologyFileName(const std::string &file_name)
Set the topology file name. This is useful if pre-allocating an array of MoleculeSystems and then fil...
Definition nml_files.cpp:117
int getStartingFrame() const
Get the starting frame that this system will read for initial coordinate states.
Definition nml_files.cpp:82
const std::string & getLabel() const
Get the assigned label for this system.
Definition nml_files.cpp:77
int getReplicaCount() const
Get the replica count for this system, the number of copies of each initial coordinate frame that it ...
Definition nml_files.cpp:97
bool validateInputCoordinateFile() const
Report whether the input coordinate file named in this system is a valid file.
Definition nml_files.cpp:187
void setFinalFrame(int frame_number)
Set the final frame. This can be necessary if the input coordinates file does not contain the request...
Definition nml_files.cpp:142
void setTrajectoryFileKind(const std::string &kind)
Set the trajectory file type.
Definition nml_files.cpp:162
MoleculeSystem()
The constructor can make a blank system or automatically fill values.
Definition nml_files.cpp:25
const std::string & getTrajectoryFileName() const
Get the name of the trajectory file.
Definition nml_files.cpp:67
void setStartingFrame(int frame_number)
Set the starting frame. This can be necessary if the input coordinates file does not contain the requ...
Definition nml_files.cpp:137
void setTrajectoryFileName(const std::string &file_name)
Set the trajectory file name.
Definition nml_files.cpp:127
Collection of variables to transcribe information contained within a namelist.
Definition namelist_emulator.h:30
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45