00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_FORMAT_MOL2FILE_H
00008 #define BALL_FORMAT_MOL2FILE_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 #ifndef BALL_KERNEL_ATOMCONTAINER_H
00019 # include <BALL/KERNEL/atomContainer.h>
00020 #endif
00021
00022 namespace BALL
00023 {
00024 class Atom;
00025 class System;
00026
00032 class BALL_EXPORT MOL2File
00033 : public GenericMolFile
00034 {
00035 public:
00036
00038 BALL_EXPORT struct SetStruct
00039 {
00040 String name;
00041 bool is_static;
00042 String obj_type;
00043 String sub_type;
00044 String status;
00045 String comment;
00046 Size number_of_members;
00047
00048 vector<Index> static_members;
00049 String dynamic_rule;
00050 };
00051
00055
00058 static const String TRIPOS;
00060
00064
00067 MOL2File()
00068 ;
00069
00072 MOL2File(const String& filename, File::OpenMode open_mode = std::ios::in)
00073 throw(Exception::FileNotFound);
00074
00077 MOL2File(const MOL2File& file)
00078 throw(Exception::FileNotFound);
00079
00081 virtual ~MOL2File()
00082 ;
00083
00085
00089
00092 virtual bool write(const System& system)
00093 throw(File::CannotWrite);
00094
00097 virtual bool read(System& system)
00098 throw(Exception::ParseError);
00099
00102 virtual Molecule* read()
00103 throw(Exception::ParseError);
00104
00107 virtual bool write(const Molecule& molecule)
00108 throw(File::CannotWrite);
00109
00111 const MOL2File& operator = (const MOL2File& file) ;
00112
00114 Size getNumberOfSets() const { return sets_.size(); }
00115
00117 SetStruct& getSet(Position i) { return sets_[i]; }
00118
00120 const SetStruct& getSet(Position i) const { return sets_[i]; }
00121
00123
00124 protected:
00125
00126 void readAtomSection_();
00127
00128 void readBondSection_();
00129
00130 void readMoleculeSection_();
00131
00132 void readSetSection_();
00133
00134 void readSubstructureSection_();
00135
00136 String getSybylType_(const Atom& atom) const;
00137
00138 bool nextLine_();
00139
00140 void clear_();
00141
00142 bool buildAll_(System& system);
00143
00144 bool containsAtomChilds_(AtomContainerConstIterator& frag_it);
00145
00146 BALL_EXPORT struct AtomStruct
00147 {
00148 String name;
00149 Vector3 position;
00150 String type;
00151 Position substructure;
00152 String substructure_name;
00153 float charge;
00154 };
00155
00156 BALL_EXPORT struct BondStruct
00157 {
00158 Position atom1;
00159 Position atom2;
00160 String type;
00161 };
00162
00163 BALL_EXPORT struct MoleculeStruct
00164 {
00165 String name;
00166 Size number_of_atoms;
00167 Size number_of_bonds;
00168 Size number_of_substructures;
00169 Size number_of_features;
00170 Size number_of_sets;
00171 String type;
00172 String charge_type;
00173 String comment;
00174 };
00175
00176 BALL_EXPORT struct SubstructureStruct
00177 {
00178 String name;
00179 Size root_atom;
00180 String substructure_type;
00181 Size dictionary_type;
00182 String chain;
00183 String sub_type;
00184 Size inter_bonds;
00185 String comment;
00186 };
00187
00188
00189 vector<AtomStruct> atoms_;
00190 vector<BondStruct> bonds_;
00191 vector<SetStruct> sets_;
00192 vector<SubstructureStruct> substructures_;
00193 MoleculeStruct molecule_;
00194
00195 Size number_of_lines_;
00196 static const Size MAX_LENGTH_;
00197 char buffer_[4096];
00198 String line_;
00199 };
00200 }
00201
00202 #endif // BALL_FORMAT_MOL2FILE_H