2#ifndef STORMM_MDL_FILE_H
3#define STORMM_MDL_FILE_H
9#include "Accelerator/hybrid.h"
10#include "Chemistry/znumber.h"
11#include "Chemistry/chemical_features.h"
12#include "Constants/behavior.h"
13#include "DataTypes/common_types.h"
14#include "DataTypes/stormm_vector_types.h"
15#include "FileManagement/file_util.h"
16#include "Parsing/ascii_numbers.h"
17#include "Parsing/parse.h"
18#include "Potential/energy_enumerators.h"
19#include "Restraints/restraint_apparatus.h"
20#include "Synthesis/condensate.h"
21#include "Synthesis/phasespace_synthesis.h"
22#include "Topology/atomgraph.h"
23#include "Topology/atomgraph_abstracts.h"
24#include "Trajectory/coordinateframe.h"
25#include "Trajectory/coordinate_series.h"
26#include "Trajectory/phasespace.h"
27#include "Trajectory/trajectory_enumerators.h"
28#include "molecule_file_io.h"
29#include "molecule_format_enumerators.h"
30#include "mdlmol_atomlist.h"
31#include "mdlmol_bond.h"
32#include "mdlmol_dataitem.h"
33#include "mdlmol_property.h"
38using card::HybridTargetLevel;
39using chemistry::symbolToZNumber;
40using chemistry::ChemicalFeatures;
41using constants::CartesianDimension;
42using constants::CaseSensitivity;
43using constants::ExceptionResponse;
44using data_types::isFloatingPointScalarType;
45using diskutil::PrintSituation;
46using energy::StateVariable;
48using restraints::RestraintApparatus;
49using synthesis::Condensate;
50using synthesis::CondensateReader;
51using synthesis::PhaseSpaceSynthesis;
52using synthesis::PsSynthesisReader;
53using topology::AtomGraph;
54using topology::ChemicalDetailsKit;
55using topology::NonbondedKit;
56using trajectory::CoordinateCycle;
57using trajectory::CoordinateFrame;
58using trajectory::CoordinateFrameReader;
59using trajectory::CoordinateFrameWriter;
60using trajectory::CoordinateSeries;
61using trajectory::CoordinateSeriesReader;
62using trajectory::CoordinateSeriesWriter;
63using trajectory::PhaseSpace;
64using trajectory::PhaseSpaceReader;
65using trajectory::PhaseSpaceWriter;
69constexpr char4 default_mdl_atomic_symbol = {
' ',
' ',
' ',
' ' };
70constexpr int default_mdl_atomic_number = -1;
71constexpr int default_mdl_formal_charge = 0;
72constexpr RadicalState default_mdl_radical_state = RadicalState::NONE;
73constexpr int default_mdl_isotopic_shift = 0;
74constexpr MolObjAtomStereo default_mdl_stereo_parity = MolObjAtomStereo::NOT_STEREO;
75constexpr HydrogenAssignment default_hydrogenation = HydrogenAssignment::DO_NOT_HYDROGENATE;
76constexpr int default_mdl_implicit_hydrogen = 0;
77constexpr int default_mdl_valence_connections = 0;
78constexpr int default_mdl_map_count = 0;
79constexpr bool default_mdl_stereo_considerations =
false;
80constexpr bool default_mdl_exact_change =
false;
81constexpr StereoRetention default_mdl_stereo_retention = StereoRetention::NOT_APPLIED;
127 MdlMol(ExceptionResponse policy_in = ExceptionResponse::WARN);
129 MdlMol(
const std::string &filename, ExceptionResponse policy_in = ExceptionResponse::WARN,
130 ModificationPolicy dimod_policy = ModificationPolicy::DO_NOT_MODIFY,
131 ExceptionResponse dimod_notify = ExceptionResponse::WARN);
133 MdlMol(
const char* filename, ExceptionResponse policy_in = ExceptionResponse::WARN,
134 ModificationPolicy dimod_policy = ModificationPolicy::DO_NOT_MODIFY,
135 ExceptionResponse dimod_notify = ExceptionResponse::WARN);
138 CaseSensitivity capitalization = CaseSensitivity::YES,
139 ExceptionResponse policy_in = ExceptionResponse::WARN,
140 ModificationPolicy dimod_policy = ModificationPolicy::DO_NOT_MODIFY,
141 ExceptionResponse dimod_notify = ExceptionResponse::WARN);
143 template <
typename T>
145 double inv_scale,
int molecule_index = 0);
147 template <
typename T>
149 int molecule_index = 0);
163 template <
typename T>
165 int molecule_index = 0);
167 template <
typename T>
169 int molecule_index = 0);
171 template <
typename T>
173 int molecule_index = 0);
176 int molecule_index = 0);
179 int molecule_index = 0);
182 int molecule_index = 0);
185 int molecule_index = 0);
188 int molecule_index = 0);
191 int molecule_index = 0);
205 const std::string&
getTitle()
const;
312 double scale_factor);
314 template <
typename T>
void impartCoordinates(
const T* xcrd,
const T* ycrd,
const T* zcrd,
319 const int* xcrd_ovrf,
const int* ycrd_ovrf,
const int* zcrd_ovrf,
320 double scale_factor);
323 const int* xcrd_ovrf,
const int* ycrd_ovrf,
const int* zcrd_ovrf,
331 HybridTargetLevel tier = HybridTargetLevel::HOST);
334 HybridTargetLevel tier = HybridTargetLevel::HOST);
337 HybridTargetLevel tier = HybridTargetLevel::HOST);
340 HybridTargetLevel tier = HybridTargetLevel::HOST);
347 HybridTargetLevel tier = HybridTargetLevel::HOST);
350 HybridTargetLevel tier = HybridTargetLevel::HOST);
352 template <
typename T>
354 HybridTargetLevel tier = HybridTargetLevel::HOST);
356 template <
typename T>
358 HybridTargetLevel tier = HybridTargetLevel::HOST);
360 template <
typename T>
362 HybridTargetLevel tier = HybridTargetLevel::HOST);
364 template <
typename T>
366 HybridTargetLevel tier = HybridTargetLevel::HOST);
369 HybridTargetLevel tier = HybridTargetLevel::HOST);
372 HybridTargetLevel tier = HybridTargetLevel::HOST);
477 void writeMdl(std::ofstream *foutp, MdlMolVersion vformat)
const;
479 void writeMdl(
const std::string &fname, MdlMolVersion vformat, PrintSituation expectation)
const;
481 std::string
writeMdl(MdlMolVersion vformat = MdlMolVersion::V3000)
const;
499 void writeDataItems(std::ofstream *foutp,
int mol_index = 0)
const;
501 void writeDataItems(
const std::string &fname, PrintSituation expectation,
502 int mol_index = 0)
const;
510 ExceptionResponse policy;
511 MdlMolVersion version_no;
516 int stext_entry_count;
517 int properties_count;
520 int constraint_count;
521 MolObjChirality chirality;
526 bool property_formal_charges;
532 bool property_radicals;
536 bool property_isotopes;
540 bool property_element_lists;
545 std::vector<double3> coordinates;
546 std::vector<char4> atomic_symbols;
547 std::vector<int> atomic_numbers;
548 std::vector<int> formal_charges;
549 std::vector<RadicalState> radicals;
551 std::vector<int> isotopic_shifts;
553 std::vector<MolObjAtomStereo> parities;
554 std::vector<int> implicit_hydrogens;
557 std::vector<bool> stereo_considerations;
562 std::vector<int> valence_connections;
564 std::vector<int> atom_atom_mapping_count;
566 std::vector<bool> exact_change_enforced;
572 std::vector<HydrogenAssignment> hydrogenation_protocol;
575 std::vector<StereoRetention> orientation_stability;
578 std::vector<MdlMolBond> bonds;
581 std::vector<MdlMolAtomList> element_lists;
584 std::vector<MolObjSTextGroup> stext_entries;
587 std::vector<MdlMolProperty> properties;
592 std::vector<MdlMolDataItem> data_items;
598 std::string software_details;
601 std::string general_comment;
605 std::string external_regno;
611 void validateAtomIndex(
int index,
const char* caller)
const;
635 int getIsotopicShiftCode(
int atom_index)
const;
643 void interpretFormalCharge(
int charge_in,
int atom_index);
649 int getFormalChargeCode(
int atom_index)
const;
654 MolObjAtomStereo interpretStereoParity(
int setting_in);
665 void interpretImplicitHydrogenContent(
int nh_in,
int atom_index);
671 int getImplicitHydrogenCode(
const int atom_index)
const;
677 bool interpretBooleanValue(
int value_in,
const std::string &desc);
683 int interpretValenceNumber(
int count_in);
688 StereoRetention interpretStereoStability(
int code_in);
692 void updateV2kAtomAttributes();
707 void compareExternalRegistryNumbers(
const std::string ®no_in);
712 void checkAtomCount(
int ext_atom_count)
const;
718 void checkDataItemIndex(
int item_index,
const char* caller)
const;
727 void addAtomIntProperty(
const std::vector<int2> ¬able_data,
const char4 prcode);
736 void transferTopologicalDetails(
const ChemicalFeatures *chemfe,
int molecule_index = 0);
753std::vector<MdlMol> readStructureDataFile(
const TextFile &tf,
int low_frame_limit,
754 int high_frame_limit,
755 CaseSensitivity capitalization = CaseSensitivity::YES,
756 ExceptionResponse policy = ExceptionResponse::WARN);
757std::vector<MdlMol> readStructureDataFile(
const std::string &file_name,
758 CaseSensitivity capitalization = CaseSensitivity::YES,
759 ExceptionResponse policy = ExceptionResponse::WARN);
761std::vector<MdlMol> readStructureDataFile(
const TextFile &tf,
762 CaseSensitivity capitalization = CaseSensitivity::YES,
763 ExceptionResponse policy = ExceptionResponse::WARN);
An object to store information about chemical motifs: participation in rings, planarity,...
Definition chemical_features.h:400
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45
A collection of all restraints pertaining to a specific topology for the purposes of one simulation,...
Definition restraint_apparatus.h:109
A request for one of a sanctioned list of information types to be included in a data item of an SD fi...
Definition mdlmol_request.h:20
A molecular or atomic property read from an MDL .mol or SDF file.
Definition mdlmol_property.h:17
const std::vector< std::string > & getDataItemContent(int item_index) const
Get the lines from a data item as an array of strings.
Definition mdlmol.cpp:1096
const std::string & getTitle() const
Get the title of the MDL MOL entry (for its first three lines)
Definition mdlmol.cpp:417
const std::string & getDataItemName(int item_index) const
Get the name of a data item based on its number.
Definition mdlmol.cpp:1074
const std::vector< int > & getAtomicNumbers() const
Get a const reference to the vector of all atomic numbers in the system.
Definition mdlmol.cpp:517
void addLineToDataItem(const std::string &text, int item_index)
Add a line of text to a specific data item within the MDL MOL entry. This text may contain a pre-form...
Definition mdlmol.cpp:1068
void impartCoordinates(const T *xcrd, const T *ycrd, const T *zcrd, double scale_factor)
Impart a new set of coordinates to the atoms based on one of STORMM's major coordinate classes....
const std::vector< int > & getFormalCharges() const
Get a const reference to the vector of all formal charges.
Definition mdlmol.cpp:528
const std::string & getDataItemOutputName(int item_index) const
Get the name of a data item based on its number, fit for output in the proper Biovia SD file format s...
Definition mdlmol.cpp:1080
int getDataItemIndex(const std::string &item_name) const
Get the index of a data item based on a name.
Definition mdlmol.cpp:1086
char4 getAtomSymbol(int index) const
Get the atomic symbol for a particular atom.
Definition mdlmol.cpp:500
int getBondCount() const
Get the number of bonds in the system.
Definition mdlmol.cpp:427
double3 getCoordinates(int index) const
Get the { X, Y, Z } coordinate tuple for a particular atom, or for all atoms.
Definition mdlmol.cpp:442
StateVariable getTrackedState(int item_index) const
Get the state variable that one of the data items is tracking.
Definition mdlmol.cpp:1062
MdlMol(ExceptionResponse policy_in=ExceptionResponse::WARN)
Constructors for the MDL molecule format object (known as MolObj in RDKit)
Definition mdlmol.cpp:34
int getAtomCount() const
Get the system's atom count.
Definition mdlmol.cpp:422
int getDataItemCount() const
Get the number of data items (XML-like note found after the MDL section of the entry in a BIOVIA Stru...
Definition mdlmol.cpp:437
const std::vector< char4 > & getAtomSymbols() const
Get a const reference to the atomic symbols for all atoms.
Definition mdlmol.cpp:506
void addProperty(const MdlMolProperty *mmprop)
Add a property to the object. Properties must follow a list of pre-approved BIOVIA codes,...
Definition mdlmol.cpp:692
const MdlMol * getSelfPointer() const
Get a const pointer to the object, useful if a pointer is needed and the object is available by const...
Definition mdlmol.cpp:471
int getFormalCharge(int index) const
Get the formal charge on a particular atom.
Definition mdlmol.cpp:522
void writeMdl(std::ofstream *foutp, MdlMolVersion vformat) const
Write a set of molecular coordinates, bonds, and their annotations in MDL MOL format....
Definition mdlmol.cpp:1113
void writeDataItems(std::ofstream *foutp, int mol_index=0) const
Write the non-MDL components of an SD file, including all applicable data items, to a string or file....
Definition mdlmol.cpp:1211
MdlMol(const MdlMol &original)=default
Default copy and move constructors, as well as assignment operators, are appropriate for this object ...
CoordinateFrame exportCoordinateFrame() const
Export the coordinates as a stripped-down CoordinateFrame object suitable for molecular mechanics ene...
Definition mdlmol.cpp:488
PhaseSpace exportPhaseSpace() const
Export the coordinates as a PhaseSpace object suitable for basic molecular mechanics force computatio...
Definition mdlmol.cpp:476
void addDataItem(const MdlMolDataRequest &ask, const AtomGraph &ag, const RestraintApparatus &ra)
Add a data item to the object. These data items follow the classifications set forth in the DataReque...
Definition mdlmol.cpp:697
int getPropertiesCount() const
Get the number of properties found in the MDL MOL entry.
Definition mdlmol.cpp:432
MdlMolDataItemKind getDataItemKind(int item_index) const
Get the classification of a data item from within the MDL MOL entry.
Definition mdlmol.cpp:1056
int getAtomicNumber(int index) const
Get the atomic number of a particular atom.
Definition mdlmol.cpp:511
An SText group from an MDL MOL (.mol) or SDF file. This information is used only by old ISIS / Deskto...
Definition mdlmol.h:86
Condense the data format, and possibly offer a reduced representation of coordinates,...
Definition condensate.h:146
A fixed-precision representation of coordinates, velocities, and forces to manage a set of simulation...
Definition phasespace_synthesis.h:325
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
Definition stormm_vector_types.h:141
Definition stormm_vector_types.h:117
Read-only abstract for the Condensate class. In most cases, the read-only abstract will be preferred ...
Definition condensate.h:102
The reader for a PhaseSpaceSynthesis object, containing all of the data relevant for propagating dyna...
Definition phasespace_synthesis.h:199
Information on atoms and residues which may be useful for applying atom masks or identifying specific...
Definition atomgraph_abstracts.h:382
Information needed for non-bonded real-space calculations. Templating is used as above,...
Definition atomgraph_abstracts.h:287
Collect C-style pointers for the elements of a read-only CoordinateFrame object.
Definition coordinateframe.h:65
Collect C-style pointers for the elements of a writable CoordinateFrame object.
Definition coordinateframe.h:30
Collect C-style pointers and critical constants for a read-only CoordinateSeries object.
Definition coordinate_series.h:96
Collect C-style pointers and critical constants for a writeable CoordinateSeries object.
Definition coordinate_series.h:66
Collect constants and pointers to the components of a read-only PhaseSpace object.
Definition phasespace.h:81
Collect constants and pointers to the components of a modifiable PhaseSpace object.
Definition phasespace.h:31