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-2016.
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 getAllOMSSANames(std::vector<String>& all_names) const;
115 
116 
118 
119 
123  bool hasEnzyme(const String& name) const;
125 
127  bool hasRegEx(const String& cleavage_regex) const;
128 
130  bool hasEnzyme(const Enzyme* enzyme) const;
132 
136  inline ConstEnzymeIterator beginEnzyme() const { return const_enzymes_.begin(); } // we only allow constant iterators -- this DB is not meant to be modifiable
137  inline ConstEnzymeIterator endEnzyme() const { return const_enzymes_.end(); }
138 
140 protected:
141  EnzymesDB();
142 
144  EnzymesDB(const EnzymesDB& enzyme_db);
146 
150  EnzymesDB & operator=(const EnzymesDB& enzymes_db);
153 
155  void readEnzymesFromFile_(const String& filename);
156 
158  const Enzyme* parseEnzyme_(Map<String, String>& values) const;
159 
160  // add to internal data; also update indices for search by name and regex
161  void addEnzyme_(const Enzyme* enzyme);
162 
163  boost::unordered_map<String, const Enzyme*> enzyme_names_; // index by names
164 
166 
167  std::set<const Enzyme*> const_enzymes_; // set of enzymes
168 
169  };
170 }
171 #endif
A more convenient string class.
Definition: String.h:57
ConstEnzymeIterator endEnzyme() const
Definition: EnzymesDB.h:137
Map< String, const Enzyme * > enzyme_regex_
Definition: EnzymesDB.h:165
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::set< const Enzyme * >::iterator EnzymeIterator
Definition: EnzymesDB.h:64
std::set< const Enzyme * > const_enzymes_
Definition: EnzymesDB.h:167
std::set< const Enzyme * >::const_iterator ConstEnzymeIterator
Definition: EnzymesDB.h:63
boost::unordered_map< String, const Enzyme * > enzyme_names_
Definition: EnzymesDB.h:163
ConstEnzymeIterator beginEnzyme() const
Definition: EnzymesDB.h:136
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.0.0 Documentation generated on Tue Jan 31 2017 06:39:43 using doxygen 1.8.8