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 String& name,
43 const String& cleavage_regex,
44 const std::set<String>& synonyms = std::set<String>(),
45 String regex_description = "");
46
48 explicit DigestionEnzyme(const String& name,
49 String cut_before,
50 const String& nocut_after = "",
51 String sense = "C",
52 const std::set<String>& synonyms = std::set<String>(),
53 String regex_description = "");
54
58
64
68
73 void setName(const String& name);
74
76 const String& getName() const;
77
79 void setSynonyms(const std::set<String>& synonyms);
80
82 void addSynonym(const String& synonym);
83
85 const std::set<String>& getSynonyms() const;
86
88 void setRegEx(const String& cleavage_regex);
89
91 const String& getRegEx() const;
92
94 void setRegExDescription(const String& value);
95
99
104 bool operator==(const DigestionEnzyme& enzyme) const;
105
107 bool operator!=(const DigestionEnzyme& enzyme) const;
108
110 bool operator==(const String& cleavage_regex) const;
111
113 bool operator!=(const String& cleavage_regex) const;
114
116 bool operator<(const DigestionEnzyme& enzyme) const;
118
124 virtual bool setValueFromFile(const String& key, const String& value);
125
127 friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const DigestionEnzyme& enzyme);
128
129 protected:
130
133
134 // basic
136
138
139 std::set<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
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
virtual ~DigestionEnzyme()
Destructor.
bool operator==(const String &cleavage_regex) const
equality operator for regex
bool operator!=(const DigestionEnzyme &enzyme) const
inequality operator
bool operator==(const DigestionEnzyme &enzyme) const
equality operator
String regex_description_
Definition DigestionEnzyme.h:141
String name_
Definition DigestionEnzyme.h:135
const String & getRegExDescription() const
returns the regex description
DigestionEnzyme(const DigestionEnzyme &)=default
Copy constructor.
void setSynonyms(const std::set< String > &synonyms)
sets the synonyms
void setRegExDescription(const String &value)
sets the regex description
DigestionEnzyme(const String &name, String cut_before, const String &nocut_after="", String sense="C", const std::set< String > &synonyms=std::set< String >(), String regex_description="")
Detailed constructor 2.
const std::set< String > & getSynonyms() const
returns the synonyms
void setName(const String &name)
sets the name of the enzyme
DigestionEnzyme(const String &name, const String &cleavage_regex, const std::set< String > &synonyms=std::set< String >(), String regex_description="")
Detailed constructor.
const String & getName() const
returns the name of the enzyme
virtual bool setValueFromFile(const String &key, const String &value)
Set the value of a member variable based on an entry from an input file.
DigestionEnzyme & operator=(const DigestionEnzyme &)=default
Assignment operator.
std::set< String > synonyms_
Definition DigestionEnzyme.h:139
String cleavage_regex_
Definition DigestionEnzyme.h:137
DigestionEnzyme()
default constructor
bool operator!=(const String &cleavage_regex) const
equality operator for regex
DigestionEnzyme(DigestionEnzyme &&)=default
Move constructor.
DigestionEnzyme & operator=(DigestionEnzyme &&) &=default
Move assignment operator.
const String & getRegEx() const
returns the cleavage regex
void addSynonym(const String &synonym)
adds a synonym
void setRegEx(const String &cleavage_regex)
sets the cleavage regex
A more convenient string class.
Definition String.h:34
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