OpenMS
Loading...
Searching...
No Matches
DigestionEnzyme.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Xiao Liang $
6// $Authors: Xiao Liang $
7// --------------------------------------------------------------------------
8//
9
10#pragma once
11
15
16#include <functional>
17#include <iosfwd>
18#include <set>
19#include <vector>
20
21namespace OpenMS
22{
28 class OPENMS_DLLAPI DigestionEnzyme
29 {
30 public:
31
37
40
42 explicit DigestionEnzyme(const std::string& name,
43 const std::string& cleavage_regex,
44 const std::set<std::string>& synonyms = std::set<std::string>(),
45 std::string regex_description = "");
46
48 explicit DigestionEnzyme(const std::string& name,
49 std::string cut_before,
50 const std::string& nocut_after = "",
51 std::string sense = "C",
52 const std::set<std::string>& synonyms = std::set<std::string>(),
53 std::string regex_description = "");
54
58
64
68
73 void setName(const std::string& name);
74
76 const std::string& getName() const;
77
79 void setSynonyms(const std::set<std::string>& synonyms);
80
82 void addSynonym(const std::string& synonym);
83
85 const std::set<std::string>& getSynonyms() const;
86
88 void setRegEx(const std::string& cleavage_regex);
89
91 const std::string& getRegEx() const;
92
94 void setRegExDescription(const std::string& value);
95
97 const std::string& getRegExDescription() const;
99
104 bool operator==(const DigestionEnzyme& enzyme) const;
105
107 bool operator!=(const DigestionEnzyme& enzyme) const;
108
110 bool operator==(const std::string& cleavage_regex) const;
111
113 bool operator!=(const std::string& cleavage_regex) const;
114
116 bool operator<(const DigestionEnzyme& enzyme) const;
118
124 virtual bool setValueFromFile(const std::string& key, const std::string& value);
125
127 friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const DigestionEnzyme& enzyme);
128
129 protected:
130
133
134 // basic
135 std::string name_;
136
137 std::string cleavage_regex_;
138
139 std::set<std::string> synonyms_;
140
142 };
143
144 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const DigestionEnzyme& enzyme);
145} // namespace OpenMS
146
147namespace std
148{
150 template<>
151 struct hash<OpenMS::DigestionEnzyme>
152 {
153 std::size_t operator()(const OpenMS::DigestionEnzyme& enzyme) const noexcept
154 {
155 std::size_t seed = OpenMS::fnv1a_hash_string(enzyme.getName());
156 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(enzyme.getRegEx()));
157 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(enzyme.getRegExDescription()));
158 // Hash the synonyms set
159 for (const auto& syn : enzyme.getSynonyms())
160 {
162 }
163 return seed;
164 }
165 };
166} // namespace std
167
Base class for digestion enzymes.
Definition DigestionEnzyme.h:29
const std::string & getRegExDescription() const
returns the regex description
const std::string & getRegEx() const
returns the cleavage regex
bool operator<(const DigestionEnzyme &enzyme) const
order operator
friend std::ostream & operator<<(std::ostream &os, const DigestionEnzyme &enzyme)
ostream iterator to write the enzyme to a stream
DigestionEnzyme(const std::string &name, std::string cut_before, const std::string &nocut_after="", std::string sense="C", const std::set< std::string > &synonyms=std::set< std::string >(), std::string regex_description="")
Detailed constructor 2.
virtual ~DigestionEnzyme()
Destructor.
bool operator!=(const DigestionEnzyme &enzyme) const
inequality operator
bool operator==(const DigestionEnzyme &enzyme) const
equality operator
std::set< std::string > synonyms_
Definition DigestionEnzyme.h:139
void setSynonyms(const std::set< std::string > &synonyms)
sets the synonyms
bool operator==(const std::string &cleavage_regex) const
equality operator for regex
const std::string & getName() const
returns the name of the enzyme
bool operator!=(const std::string &cleavage_regex) const
equality operator for regex
std::string name_
Definition DigestionEnzyme.h:135
void addSynonym(const std::string &synonym)
adds a synonym
DigestionEnzyme(const DigestionEnzyme &)=default
Copy constructor.
std::string regex_description_
Definition DigestionEnzyme.h:141
void setRegExDescription(const std::string &value)
sets the regex description
void setName(const std::string &name)
sets the name of the enzyme
DigestionEnzyme & operator=(const DigestionEnzyme &)=default
Assignment operator.
DigestionEnzyme()
default constructor
DigestionEnzyme(DigestionEnzyme &&)=default
Move constructor.
void setRegEx(const std::string &cleavage_regex)
sets the cleavage regex
DigestionEnzyme & operator=(DigestionEnzyme &&) &=default
Move assignment operator.
virtual bool setValueFromFile(const std::string &key, const std::string &value)
Set the value of a member variable based on an entry from an input file.
DigestionEnzyme(const std::string &name, const std::string &cleavage_regex, const std::set< std::string > &synonyms=std::set< std::string >(), std::string regex_description="")
Detailed constructor.
const std::set< std::string > & getSynonyms() const
returns the synonyms
std::string cleavage_regex_
Definition DigestionEnzyme.h:137
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t fnv1a_hash_string(const std::string &s) noexcept
FNV-1a hash for a string.
Definition HashUtils.h:70
STL namespace.
std::size_t operator()(const OpenMS::DigestionEnzyme &enzyme) const noexcept
Definition DigestionEnzyme.h:153