00001
00002
00003
00004
00005 #ifndef BALL_NMR_READ_STAR_H
00006 #define BALL_NMR_READ_STAR_H
00007
00008 #ifndef BALL_FORMAT_LineBasedFile_H
00009 # include<BALL/FORMAT/lineBasedFile.h>
00010 #endif
00011
00012 #include <vector>
00013
00014 namespace BALL
00015 {
00021
00027 struct BALL_EXPORT NMRAtomData
00028 {
00029 NMRAtomData();
00030
00031 Position atom_ID;
00032 Position residue_seq_code;
00033 String residue_label;
00034 String atom_name;
00035 char atom_type;
00036 float shift_value;
00037 float error_value;
00038 Position ambiguity_code;
00039 };
00040
00046 struct BALL_EXPORT SampleCondition
00047 {
00048 SampleCondition();
00049
00050 String name;
00051 float temperature;
00052 float pH;
00053 float pressure;
00054 };
00055
00061 struct BALL_EXPORT ShiftReferenceElement
00062 {
00063 ShiftReferenceElement();
00064
00065 String mol_common_name;
00066 char atom_type;
00067 Position isotope_number;
00068 String atom_group;
00069 String shift_units;
00070 float shift_value;
00071 char reference_method;
00072 char reference_type;
00073 float indirect_shift_ratio;
00074 };
00075
00081 struct BALL_EXPORT ShiftReferenceSet
00082 {
00083 ShiftReferenceSet();
00084 String name;
00085 std::vector<ShiftReferenceElement> elements;
00086 };
00087
00088 struct BALL_EXPORT NMRAtomDataSet
00089 {
00090 NMRAtomDataSet();
00091
00092 String name;
00093 std::vector<NMRAtomData> atom_data;
00094 SampleCondition condition;
00095 ShiftReferenceSet reference;
00096 };
00097
00099
00108 class BALL_EXPORT NMRStarFile
00109 : public LineBasedFile
00110 {
00111 public:
00112
00116
00119 NMRStarFile();
00120
00124 NMRStarFile(const String& file_name)
00125 throw(Exception::FileNotFound, Exception::ParseError);
00126
00130 const NMRStarFile& operator = (const NMRStarFile& f);
00131
00132 ~NMRStarFile();
00133
00136 void clear();
00137
00139
00140
00144
00147 Size getNumberOfAtoms() const;
00148
00151 const std::vector<NMRAtomDataSet>& getData() const;
00152
00154
00157
00161 bool operator == (const NMRStarFile& f);
00162
00166 bool operator != (const NMRStarFile& f);
00167
00169
00172
00173 enum ReferenceMethod
00174 {
00175 INTERNAL_REFERENCE,
00176 EXTERNAL_REFERENCE,
00177 UNKNOWN_REFERENCE,
00178 UNSET_REFERENCE
00179 };
00180
00181 enum ReferenceType
00182 {
00183 DIRECT_TYPE,
00184 INDIRECT_TYPE,
00185 UNKNOWN_TYPE,
00186 UNSET_TYPE
00187 };
00188
00190
00191 private:
00192
00193
00194
00195
00196
00198 NMRAtomData processShiftLine_()
00199 throw(Exception::ParseError);
00200
00202 void readEntryInformation_()
00203 throw(Exception::ParseError, Exception::InvalidFormat);
00204
00206 void readMolSystem_();
00207
00209 void readSampleConditions_();
00210
00212 void readShiftReferences_();
00213
00215 void readShifts_()
00216 throw (Exception::ParseError);
00217
00219 static void initializeReferenceOptions_();
00220
00221
00222
00223
00224
00225
00227 Size number_of_shifts_;
00228
00230 std::vector<NMRAtomDataSet> atom_data_sets_;
00231
00233 std::vector<SampleCondition> sample_conditions_;
00234
00236 std::vector<ShiftReferenceSet> shift_references_;
00237
00239 String system_name_;
00240
00242 static std::vector<String> reference_options_;
00243
00245 enum ShiftReferenceTypes_
00246 {
00247 MOL_COMMON_NAME,
00248 ATOM_TYPE,
00249 ISOTOPE_NUMBER,
00250 ATOM_GROUP,
00251 SHIFT_UNITS,
00252 SHIFT_VALUE,
00253 REFERENCE_METHOD,
00254 REFERENCE_TYPE,
00255 INDIRECT_SHIFT_RATIO
00256 };
00257
00258
00259
00260 };
00261
00263 }
00264
00265 #endif // BALL_NMR_READ_STAR_H