Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
EnzymesDB.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Xiao Liang $
32 // $Authors: Xiao Liang, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_CHEMISTRY_ENZYMESDB_H
36 #define OPENMS_CHEMISTRY_ENZYMESDB_H
37 
39 #include <boost/unordered_map.hpp>
41 #include <set>
42 
43 namespace OpenMS
44 {
45  // forward declarations
46  class Enzyme;
47 
56  class OPENMS_DLLAPI EnzymesDB
57  {
58 public:
59 
63  typedef std::set<const Enzyme*>::const_iterator ConstEnzymeIterator;
64  typedef std::set<const Enzyme*>::iterator EnzymeIterator;
66 
68  inline static EnzymesDB* getInstance()
69  {
70  static EnzymesDB* db_ = 0;
71  if (db_ == 0)
72  {
73  db_ = new EnzymesDB;
74  }
75  return db_;
76  }
77 
81  virtual ~EnzymesDB();
84 
88  const Enzyme* getEnzyme(const String& name) const;
92 
95  const Enzyme* getEnzymeByRegEx(const String& cleavage_regex) const;
96 
98  void setEnzymes(const String& filename);
99 
102  void addEnzyme(const Enzyme& enzyme);
103 
105  void clear();
106 
108  void getAllNames(std::vector<String>& all_names) const;
109 
111  void getAllXTandemNames(std::vector<String>& all_names) const;
112 
114  void getAllCometNames(std::vector<String>& all_names) const;
115 
117  void getAllOMSSANames(std::vector<String>& all_names) const;
118 
120  void getAllMSGFNames(std::vector<String>& all_names) const;
121 
122 
124 
125 
129  bool hasEnzyme(const String& name) const;
131 
133  bool hasRegEx(const String& cleavage_regex) const;
134 
136  bool hasEnzyme(const Enzyme* enzyme) const;
138 
142  inline ConstEnzymeIterator beginEnzyme() const { return const_enzymes_.begin(); } // we only allow constant iterators -- this DB is not meant to be modifiable
143  inline ConstEnzymeIterator endEnzyme() const { return const_enzymes_.end(); }
144 
146 protected:
147  EnzymesDB();
148 
150  EnzymesDB(const EnzymesDB& enzyme_db);
152 
156  EnzymesDB& operator=(const EnzymesDB& enzymes_db);
159 
161  void readEnzymesFromFile_(const String& filename);
162 
164  const Enzyme* parseEnzyme_(Map<String, String>& values) const;
165 
166  // add to internal data; also update indices for search by name and regex
167  void addEnzyme_(const Enzyme* enzyme);
168 
169  boost::unordered_map<String, const Enzyme*> enzyme_names_; // index by names
170 
172 
173  std::set<const Enzyme*> const_enzymes_; // set of enzymes
174 
175  };
176 }
177 #endif
std::set< const Enzyme * >::iterator EnzymeIterator
Definition: EnzymesDB.h:64
A more convenient string class.
Definition: String.h:57
ConstEnzymeIterator endEnzyme() const
Definition: EnzymesDB.h:143
Map< String, const Enzyme * > enzyme_regex_
Definition: EnzymesDB.h:171
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::set< const Enzyme * > const_enzymes_
Definition: EnzymesDB.h:173
std::set< const Enzyme * >::const_iterator ConstEnzymeIterator
Definition: EnzymesDB.h:63
boost::unordered_map< String, const Enzyme * > enzyme_names_
Definition: EnzymesDB.h:169
ConstEnzymeIterator beginEnzyme() const
Definition: EnzymesDB.h:142
Representation of an enzyme.
Definition: Enzyme.h:56
enzyme database which holds enzymes
Definition: EnzymesDB.h:56
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
static EnzymesDB * getInstance()
this member function serves as a replacement of the constructor
Definition: EnzymesDB.h:68

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:00 using doxygen 1.8.13