Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_mod_visibility_helper.hpp
1/*
2##############################################################################
3# File: ms_mod_visibility_helper.hpp #
4# Mascot Parser toolkit #
5# Utility classes for managing modification visibility #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2014 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11# $Source: parser/inc/ms_mod_visibility_helper.hpp $
12# $Author: francoisr@matrixscience.com $
13# $Date: 2019-03-15 14:15:26 +0000 $
14# $Revision:
15##############################################################################
16*/
17
18#ifndef _MS_SPECIFICITY_VISIBILITY_H
19#define _MS_SPECIFICITY_VISIBILITY_H
20
21
22#include <string>
23#include <vector>
24
25namespace matrix_science {
26
27 class ms_umod_specificity;
28 class ms_umod_configfile;
29 class ms_modfile;
30
36 // \cond INTERNAL
38
48 class MS_MASCOTRESFILE_API ms_spec_visibility
49 {
50 public:
52 ms_spec_visibility();
53
55 ms_spec_visibility(std::string site);
57 ms_spec_visibility(std::string site, std::string position);
59 ~ms_spec_visibility();
60
62 std::string getSite();
64 void setSite(std::string s);
66 std::string getPosition();
68 void setPosition(std::string s);
69
71 bool isHidden();
73 void setHidden(bool bHide);
74
76 bool inShortList() const;
78 void showInShortList(bool b);
80 bool inLongList() const;
82 void showInLongList(bool b);
84 bool inErrorTolerant() const;
86 void useInErrorTolerant(bool b);
87
89 bool isOveridden();
91 void setOveridden(bool b);
92
93 private:
94 void initialise();
95
96 std::string m_site;
97 std::string m_position;
98 bool m_show_in_short_list;
99 bool m_show_in_long_list;
100 bool m_use_in_error_tolerant;
101 bool m_overridden;
102 }; // class ms_spec_visibility
103 // \endcond
104
105
106 // \cond INTERNAL
108
117 class MS_MASCOTRESFILE_API ms_mod_visibility
118 {
119 public:
121 ms_mod_visibility();
122
124 ~ms_mod_visibility();
125
127 std::string getName();
129 void setName(std::string s);
130
132 void setNumberOfSpecs(int spec_count);
134 int getNumberOfSpecs();
136 void getDefaults(int spec_number, const ms_umod_specificity *spec);
138 void setDefaults(int spec_number, const char site, bool hidden);
140 void setDefaults(int spec_number, const char site, std::string position, bool hidden);
141
142
144 void applyVisibilities( ms_umod_specificity *spec);
146 bool updateVisibilities( const ms_umod_specificity *spec);
148 bool updateIsPrivate(bool is_private);
149
151 bool isPrivate() const;
153 void setPrivate(bool b);
154
156 bool isPrivacyEnabled() const;
158 void setPrivacyEnabled(bool b);
159
161 bool hasOverrides();
163 bool isOveridden();
165 void setOveridden(bool b);
166
168 bool isDeleted();
170 void setDeleted(bool b);
171
173 ms_spec_visibility &getSpecVisibility(int index);
175 ms_spec_visibility &getSpecVisibility(std::string site, bool bCreate);
177 ms_spec_visibility &getSpecVisibility(std::string site, std::string position, bool bCreate);
178
179 private:
180
181 typedef std::vector< ms_spec_visibility> spec_vis_vector;
182 spec_vis_vector m_specs;
183
184 std::string m_name;
185 ms_spec_visibility m_default_spec;
186
187 bool m_isPrivacyEnabled;
188 bool m_isPrivate;
189 bool m_overridden;
190 bool m_deleted;
191 }; // class ms_mod_visibility
192 // \endcond
193
194 // \cond INTERNAL
196
203 class MS_MASCOTRESFILE_API ms_mod_visibility_helper : public ms_errors
204 {
205 public:
207 ms_mod_visibility_helper();
208
210 ms_mod_visibility_helper(const matrix_science::ms_session *session, const std::string &visibility_filename, ms_umod_configfile *config);
212 ms_mod_visibility_helper(const std::vector<int> & groupIds, const std::string &visibility_filename, ms_umod_configfile *config);
214 ms_mod_visibility_helper(const matrix_science::ms_session *session, const std::string &visibility_filename, ms_modfile *modfile);
216 ms_mod_visibility_helper(const std::string &visibility_full_filename);
218 ~ms_mod_visibility_helper();
219
221 bool hasPrivacy();
222
224 bool saveToGroupFiles(const matrix_science::ms_session *session, const std::string &visibility_filename, const bool saveAllForCrosslinking = false);
226 bool saveToFile(const std::string &filename, const bool saveAllForCrosslinking = false);
227
229 ms_mod_visibility *getModVisibility(int index);
231 ms_mod_visibility *getModVisibility(const std::string &mod_title, bool bCreate);
233 void removeModVisibilty(const std::string &mod_title);
234
236 void setVisibilities(matrix_science::ms_umod_configfile *config);
238 void setVisibilities(matrix_science::ms_modfile *modfile);
239
241 static void getUserGroupVisibilty(
242 matrix_science::ms_session *session, const std::string &mod_title, std::string &visibility_filename,
243 std::vector<std::string> &excluded_usergroups, std::vector<std::string> &included_usergroups);
245 static void setUserGroupVisibilty(
246 matrix_science::ms_session *session, const std::string &mod_title, std::string &visibility_filename,
247 std::vector<std::string> &excluded_usergroups, std::vector<std::string> &included_usergroups);
248
250 static void getDefaultUserGroups(
252 std::vector<std::string> &excluded_usergroups, std::vector<std::string> &included_usergroups);
253
254 private:
255 //Do not copy this object
256 ms_mod_visibility_helper(const ms_mod_visibility_helper & src);
257 ms_mod_visibility_helper& operator=(const ms_mod_visibility_helper & right);
258
259 // Setup m_show_in_long_list defaults for config specifity "hidden" attributes.
260 void getDefaults(ms_umod_configfile *config);
261 void getDefaults(ms_modfile *modfile);
262 bool getUserGroupFileNames(const matrix_science::ms_session *session, const std::string &visibility_filename, bool bAllGroups, const std::vector<int> * groupIds = NULL);
263
264 bool loadFromFile(const std::string &filename);
265 void loadVisibility(const matrix_science::ms_session *session, const std::string &visibility_filename, const std::vector<int> * groupIds = NULL);
266
267 void clearOverrideFlags();
268
269 bool getSpecSitesFromModString(std::string modfile_spec_name, std::string &sites, std::string &position);
270
271 typedef std::vector< ms_mod_visibility> mod_vis_vector;
272 mod_vis_vector m_mods;
273
274 ms_mod_visibility m_default_mod;
275
276 std::vector<std::string> m_userGroupVisibilityFiles;
277 bool m_inAdminGroup;
278 bool m_hasPrivacy;
279 }; // class ms_mod_visibility_helper
280 // \endcond
281 // end of config_group
283
284
285
286} // namespace matrix_science
287
288#endif // _MS_SPECIFICITY_VISIBILITY_H
289
290/*------------------------------- End of File -------------------------------*/
Use this class in order to read in the amino acid modification file.
Definition: ms_modfile.hpp:407
Use this class to determine if a user is logged in and if they have 'permission' to perform tasks.
Definition: ms_security_session.hpp:123
This class represents the file unimod.xml.
Definition: ms_umod_configfile.hpp:54