00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MS_UMOD_CONFIGFILE_HPP
00020 #define MS_UMOD_CONFIGFILE_HPP
00021
00022
00023 #include <string>
00024 #include <vector>
00025
00026
00027 namespace matrix_science {
00028
00029 class ms_umod_element;
00030 class ms_umod_modification;
00031 class ms_umod_aminoacid;
00032 class ms_umod_modbrick;
00033 class ms_session;
00034
00040
00041
00053 class MS_MASCOTRESFILE_API ms_umod_configfile: public ms_errors
00054 {
00055 public:
00057
00064 enum MODFILE_FLAGS
00065 {
00066 MODFILE_FLAGS_EMPTY = 0x00000000,
00067 MODFILE_FLAGS_REGULAR = 0x00000001,
00068 MODFILE_FLAGS_HIDDEN = 0x00000002,
00069 MODFILE_FLAGS_AASUBST = 0x00000004,
00070 MODFILE_FLAGS_ALL = 0x7FFFFFFF
00071 };
00072
00074 ms_umod_configfile();
00075
00077 ms_umod_configfile(const char* fileName, const char* schemaFileName,
00078 const ms_connection_settings * cs = 0, bool useSchema = true);
00079
00081 ms_umod_configfile(const ms_umod_configfile& right);
00082
00084 virtual ~ms_umod_configfile();
00085
00086 #ifndef SWIG
00087
00088 ms_umod_configfile& operator=(const ms_umod_configfile& right);
00089 #endif
00090
00091 void copyFrom(const ms_umod_configfile* right);
00092
00094 virtual void defaultValues();
00095
00097 void updateMasses();
00098
00099
00101 std::string getFileName() const;
00102
00104 void setFileName(const char* filename);
00105
00106
00108 void setSchemaFileName(const char* name);
00109
00111 std::string getSchemaFileName() const;
00112
00114 static std::string getDefaultSchemaFileName();
00115
00117 void setConnectionSettings(const ms_connection_settings & cs);
00118
00120 ms_connection_settings getConnectionSettings() const;
00121
00122
00124 void read_file();
00125
00127 void save_file();
00128
00130 void applyVisibility( const ms_session *session);
00131
00133 void applyVisibility(const std::vector<int> & groupIds);
00134
00136 void read_buffer(const char* buffer);
00137
00139 std::string save_buffer(bool validateAgainstSchema = true);
00140
00141
00143 std::string validateDocument() const;
00144
00145
00147 int getNumberOfElements() const;
00148
00150 void clearElements();
00151
00153 void appendElement(const ms_umod_element *elem);
00154
00156 const ms_umod_element * getElementByNumber(const int idx) const;
00157
00159 const ms_umod_element * getElementByName(const char *name) const;
00160
00162 bool updateElementByNumber(const int idx, const ms_umod_element* element);
00163
00165 bool updateElementByName(const char *name, const ms_umod_element* element);
00166
00168 bool deleteElementByNumber(const int idx);
00169
00171 bool deleteElementByName(const char *name);
00172
00173
00175 std::vector< std::string > getModFileList(const unsigned int flags = MODFILE_FLAGS_ALL) const;
00176
00178 int findModFileName(const char * modFileName) const;
00179
00181 int findModification(const char* modName) const;
00182
00183
00185 int getNumberOfModifications() const;
00186
00188 void clearModifications();
00189
00191 void appendModification(const ms_umod_modification *mod);
00192
00194 const ms_umod_modification * getModificationByNumber(const int idx) const;
00195
00197 const ms_umod_modification * getModificationByName(const char *name) const;
00198
00200 bool updateModificationByNumber(const int idx, const ms_umod_modification *mod);
00201
00203 bool updateModificationByName(const char *name, const ms_umod_modification *mod);
00204
00206 bool deleteModificationByNumber(const int idx);
00207
00209 bool deleteModificationByName(const char *name);
00210
00211
00213 int getNumberOfAminoAcids() const;
00214
00216 void clearAminoAcids();
00217
00219 void appendAminoAcid(const ms_umod_aminoacid *aa);
00220
00222 const ms_umod_aminoacid * getAminoAcidByNumber(const int idx) const;
00223
00225 const ms_umod_aminoacid * getAminoAcidByName(const char *name) const;
00226
00228 bool updateAminoAcidByNumber(const int idx, const ms_umod_aminoacid *aa);
00229
00231 bool updateAminoAcidByName(const char *name, const ms_umod_aminoacid *aa);
00232
00234 bool deleteAminoAcidByNumber(const int idx);
00235
00237 bool deleteAminoAcidByName(const char *name);
00238
00239
00241 int getNumberOfModBricks() const;
00242
00244 void clearModBricks();
00245
00247 void appendModBrick(const ms_umod_modbrick *brick);
00248
00250 const ms_umod_modbrick * getModBrickByNumber(const int idx) const;
00251
00253 const ms_umod_modbrick * getModBrickByName(const char *name) const;
00254
00256 bool updateModBrickByNumber(const int idx, const ms_umod_modbrick *brick);
00257
00259 bool updateModBrickByName(const char *name, const ms_umod_modbrick *brick);
00260
00262 bool deleteModBrickByNumber(const int idx);
00263
00265 bool deleteModBrickByName(const char *name);
00266
00268 std::string getMajorVersion() const;
00269
00271 std::string getMinorVersion() const;
00272
00274 void setMajorVersion(const std::string & version);
00275
00277 void setMinorVersion(const std::string & version);
00278 private:
00279
00280 void applyVisibilityHelper();
00281
00282 std::string m_fileName;
00283 std::string m_schemaFileName;
00284 ms_connection_settings m_cs;
00285
00286 typedef std::vector< ms_umod_element* > element_vector;
00287 element_vector m_elements;
00288
00289 typedef std::vector< ms_umod_modification* > modification_vector;
00290 modification_vector m_modifications;
00291 typedef std::map<std::string, size_t> modification_index_map;
00292 modification_index_map m_modifications_nameToIndex;
00293
00294 typedef std::vector< ms_umod_aminoacid* > aminoacid_vector;
00295 aminoacid_vector m_aminoacids;
00296
00297 typedef std::vector< ms_umod_modbrick* > modbrick_vector;
00298 modbrick_vector m_modbricks;
00299
00300 std::string m_majorVersion;
00301 std::string m_minorVersion;
00302
00303 std::string m_encodingName;
00304 bool m_useSchema;
00305 };
00306
00308
00309 }
00310
00311 #endif // MS_UMOD_CONFIGFILE_HPP
00312