00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: MOLFile.h,v 1.14 2005/12/23 17:01:44 amoll Exp $ 00005 // 00006 00007 #ifndef BALL_FORMAT_MOLFILE_H 00008 #define BALL_FORMAT_MOLFILE_H 00009 00010 #ifndef BALL_FORMAT_GENERICMOLFILE_H 00011 # include <BALL/FORMAT/genericMolFile.h> 00012 #endif 00013 00014 #ifndef BALL_MATHS_VECTOR3_H 00015 # include <BALL/MATHS/vector3.h> 00016 #endif 00017 00018 namespace BALL 00019 { 00020 class System; 00021 class Atom; 00022 class Molecule; 00023 00029 class BALL_EXPORT MOLFile 00030 : public GenericMolFile 00031 { 00032 public: 00033 00034 BALL_CREATE(MOLFile) 00035 00036 00039 00048 BALL_EXPORT struct Property 00049 { 00051 static const String ATOM_MASS_DIFFERENCE; 00053 static const String ATOM_HYDROGEN_COUNT; 00055 static const String ATOM_STEREO_CARE_BOX; 00057 static const String ATOM_VALENCE; 00059 static const String ATOM_H0_DESIGNATOR; 00061 static const String ATOM_REACTION_COMPONENT_TYPE; 00063 static const String ATOM_REACTION_COMPONENT_NUMBER; 00065 static const String ATOM_INVERSION_RETENTION; 00067 static const String ATOM_EXACT_CHANGE; 00068 00070 static const String BOND_STEREO; 00072 static const String BOND_TOPOLOGY; 00074 static const String BOND_REACTING_CENTER_STATUS; 00075 }; 00076 00078 class BALL_EXPORT CountsStruct 00079 { 00080 public: 00081 Size number_of_atoms; 00082 Size number_of_bonds; 00083 Size number_of_atom_lists; 00084 bool chiral; 00085 Size number_of_stext_entries; 00086 Size number_of_reaction_components; 00087 Size number_of_reactants; 00088 Size number_of_products; 00089 Size number_of_intermediates; 00090 String version; 00091 }; 00092 00094 class BALL_EXPORT AtomStruct 00095 { 00096 public: 00097 Vector3 position; 00098 String symbol; 00099 Index mass_difference; 00100 Index charge; 00101 Index parity; 00102 Size hydrogen_count; 00103 bool stereo_care_box; 00104 Size valence; 00105 bool H0_designator; 00106 Position reaction_component_type; 00107 Position reaction_component_number; 00108 Position number; 00109 Position inversion_retention; 00110 bool exact_change; 00111 }; 00112 00114 class BALL_EXPORT BondStruct 00115 { 00116 public: 00117 Position first_atom; 00118 Position second_atom; 00119 Position type; 00120 Position stereo; 00121 Position topology; 00122 Position reacting_center_status; 00123 }; 00125 00129 00132 MOLFile() 00133 ; 00134 00137 MOLFile(const String& filename, File::OpenMode open_mode = std::ios::in) 00138 throw(Exception::FileNotFound); 00139 00142 MOLFile(const MOLFile& file) 00143 throw(Exception::FileNotFound); 00144 00146 virtual ~MOLFile() 00147 ; 00148 00150 00154 00157 virtual bool write(const Molecule& molecule) 00158 throw(File::CannotWrite); 00159 00163 virtual bool write(const System& system) 00164 throw(File::CannotWrite); 00165 00168 virtual bool read(System& system) 00169 throw(Exception::ParseError); 00170 00173 virtual Molecule* read() 00174 throw(Exception::ParseError); 00175 00177 const MOLFile& operator = (const MOLFile& file) ; 00178 00180 00181 protected: 00185 00186 static const String counts_format_; 00187 00189 static const String atom_format_; 00190 00192 static const String bond_format_; 00194 00196 Molecule* readCTAB_(std::vector<Atom*>& atom_map) 00197 throw(Exception::ParseError); 00198 00200 bool readCountsLine_(CountsStruct& counts); 00201 00203 bool readAtomLine_(AtomStruct& atom); 00204 00206 bool readBondLine_(BondStruct& bond); 00207 00209 void writeCountsLine_(const CountsStruct& counts); 00210 00212 void writeAtomLine_(const AtomStruct& atom); 00213 00215 void writeBondLine_(const BondStruct& bond); 00216 }; 00217 } // namespace BALL 00218 00219 #endif // BALL_FORMAT_MOLFILE_H