00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_FORMAT_MOLFILE_H 00006 #define BALL_FORMAT_MOLFILE_H 00007 00008 #ifndef BALL_FORMAT_GENERICMOLFILE_H 00009 # include <BALL/FORMAT/genericMolFile.h> 00010 #endif 00011 00012 #ifndef BALL_MATHS_VECTOR3_H 00013 # include <BALL/MATHS/vector3.h> 00014 #endif 00015 00016 namespace BALL 00017 { 00018 class System; 00019 class Atom; 00020 class Molecule; 00021 00027 class BALL_EXPORT MOLFile 00028 : public GenericMolFile 00029 { 00030 public: 00031 00035 00044 BALL_EXPORT struct Property 00045 { 00047 static const String ATOM_MASS_DIFFERENCE; 00049 static const String ATOM_HYDROGEN_COUNT; 00051 static const String ATOM_STEREO_CARE_BOX; 00053 static const String ATOM_VALENCE; 00055 static const String ATOM_H0_DESIGNATOR; 00057 static const String ATOM_REACTION_COMPONENT_TYPE; 00059 static const String ATOM_REACTION_COMPONENT_NUMBER; 00061 static const String ATOM_INVERSION_RETENTION; 00063 static const String ATOM_EXACT_CHANGE; 00064 00066 static const String BOND_STEREO; 00068 static const String BOND_TOPOLOGY; 00070 static const String BOND_REACTING_CENTER_STATUS; 00071 }; 00072 00074 class BALL_EXPORT CountsStruct 00075 { 00076 public: 00077 Size number_of_atoms; 00078 Size number_of_bonds; 00079 Size number_of_atom_lists; 00080 bool chiral; 00081 Size number_of_stext_entries; 00082 Size number_of_reaction_components; 00083 Size number_of_reactants; 00084 Size number_of_products; 00085 Size number_of_intermediates; 00086 String version; 00087 }; 00088 00090 class BALL_EXPORT AtomStruct 00091 { 00092 public: 00093 Vector3 position; 00094 String symbol; 00095 Index mass_difference; 00096 Index charge; 00097 Index parity; 00098 Size hydrogen_count; 00099 bool stereo_care_box; 00100 Size valence; 00101 bool H0_designator; 00102 Position reaction_component_type; 00103 Position reaction_component_number; 00104 Position number; 00105 Position inversion_retention; 00106 bool exact_change; 00107 }; 00108 00110 class BALL_EXPORT BondStruct 00111 { 00112 public: 00113 Position first_atom; 00114 Position second_atom; 00115 Position type; 00116 Position stereo; 00117 Position topology; 00118 Position reacting_center_status; 00119 }; 00121 00125 00128 MOLFile(); 00129 00133 MOLFile(const String& filename, File::OpenMode open_mode = std::ios::in); 00134 00136 virtual ~MOLFile(); 00137 00139 00143 00147 virtual bool write(const Molecule& molecule); 00148 00152 virtual bool write(const System& system); 00153 00157 virtual bool read(System& system); 00158 00162 virtual Molecule* read(); 00163 00165 const MOLFile& operator = (const MOLFile& file); 00166 00168 00169 protected: 00173 00174 static const String counts_format_; 00175 00177 static const String atom_format_; 00178 00180 static const String bond_format_; 00182 00186 Molecule* readCTAB_(std::vector<Atom*>& atom_map); 00187 00189 bool readCountsLine_(CountsStruct& counts); 00190 00192 bool readAtomLine_(AtomStruct& atom); 00193 00195 bool readBondLine_(BondStruct& bond); 00196 00198 void writeCountsLine_(const CountsStruct& counts); 00199 00201 void writeAtomLine_(const AtomStruct& atom); 00202 00204 void writeBondLine_(const BondStruct& bond); 00205 }; 00206 } // namespace BALL 00207 00208 #endif // BALL_FORMAT_MOLFILE_H