41 typedef typename std::set<const DigestionEnzymeType*>::iterator
EnzymeIterator;
48 static InstanceType* db_ =
nullptr;
51 db_ =
new InstanceType;
77 const DigestionEnzymeType*
getEnzyme(
const std::string& name)
const
79 const DigestionEnzymeType* enzyme =
findEnzyme_(name);
80 if (enzyme ==
nullptr)
95 std::string(
"Enzyme with regex " + cleavage_regex +
" was not registered in Enzyme DB, register first!").c_str());
106 all_names.push_back((*it)->getName());
121 bool hasRegEx(
const std::string& cleavage_regex)
const
158 std::string name = enzyme->getName();
163 [&name](
const DigestionEnzymeType* e) { return e->getName() == name; });
166 const DigestionEnzymeType* old = *existing;
169 auto points_to_old = [old](
const auto& entry) {
return entry.second == old; };
173 if (!old->getRegEx().empty())
184 for (
const auto& syn : enzyme->getSynonyms())
190 for (
const auto& syn : enzyme->getSynonyms())
195 if (enzyme->getRegEx() !=
"")
207 for (
auto& provider : providers)
209 auto enzymes = provider->loadEnzymes();
210 for (
auto& enzyme : enzymes)
221 key.reserve(name.size());
222 for (
unsigned char c : name)
224 if (std::isspace(c) || c ==
'-' || c ==
'_')
continue;
225 key +=
static_cast<char>(std::tolower(c));
231 const DigestionEnzymeType*
findEnzyme_(
const std::string& name)
const
236 return (pos !=
enzyme_keys_.end()) ? pos->second :
nullptr;
Digestion enzyme database (base class)
Definition DigestionEnzymeDB.h:34
void getAllNames(std::vector< std::string > &all_names) const
returns all the enzyme names (does NOT include synonym names)
Definition DigestionEnzymeDB.h:101
bool hasEnzyme(const std::string &name) const
returns true if the db contains a enzyme with the given name (supports synonym names; matched as in g...
Definition DigestionEnzymeDB.h:115
const DigestionEnzymeType * findEnzyme_(const std::string &name) const
returns the enzyme with the given name or synonym (see getEnzyme()), or nullptr if unknown
Definition DigestionEnzymeDB.h:231
DigestionEnzymeDB(const DigestionEnzymeDB &enzymes_db)=delete
copy constructor
bool hasRegEx(const std::string &cleavage_regex) const
returns true if the db contains a enzyme with the given regex
Definition DigestionEnzymeDB.h:121
DigestionEnzymeDB()=default
ConstEnzymeIterator endEnzyme() const
Definition DigestionEnzymeDB.h:137
virtual ~DigestionEnzymeDB()
destructor
Definition DigestionEnzymeDB.h:60
static std::string lookupKey_(const std::string &name)
key for lenient name lookup (see getEnzyme()): lowercase, without whitespace, '-' and '_'
Definition DigestionEnzymeDB.h:218
void loadFromProviders_(std::vector< std::unique_ptr< DigestionEnzymeDataProvider< DigestionEnzymeType > > > &providers)
Definition DigestionEnzymeDB.h:205
ConstEnzymeIterator beginEnzyme() const
Definition DigestionEnzymeDB.h:136
std::map< std::string, const DigestionEnzymeType * > enzyme_names_
index by names and synonyms (as written)
Definition DigestionEnzymeDB.h:239
const DigestionEnzymeType * getEnzymeByRegEx(const std::string &cleavage_regex) const
Definition DigestionEnzymeDB.h:89
static const InstanceType * getInstance()
Definition DigestionEnzymeDB.h:46
std::map< std::string, const DigestionEnzymeType * > enzyme_regex_
index by regex
Definition DigestionEnzymeDB.h:243
DigestionEnzymeDB & operator=(const DigestionEnzymeDB &enzymes_db)=delete
assignment operator
std::set< constDigestionEnzymeType * >::const_iterator ConstEnzymeIterator
Definition DigestionEnzymeDB.h:40
std::map< std::string, const DigestionEnzymeType * > enzyme_keys_
index by lookupKey_() of names and synonyms
Definition DigestionEnzymeDB.h:241
std::set< constDigestionEnzymeType * >::iterator EnzymeIterator
Definition DigestionEnzymeDB.h:41
bool hasEnzyme(const DigestionEnzymeType *enzyme) const
returns true if the db contains the enzyme of the given pointer
Definition DigestionEnzymeDB.h:127
const DigestionEnzymeType * getEnzyme(const std::string &name) const
Definition DigestionEnzymeDB.h:77
std::set< const DigestionEnzymeType * > const_enzymes_
set of enzymes
Definition DigestionEnzymeDB.h:245
void addEnzyme_(const DigestionEnzymeType *enzyme)
Definition DigestionEnzymeDB.h:156
Abstract interface for providing digestion enzyme data.
Definition DigestionEnzymeDataProvider.h:30
Element could not be found exception.
Definition Exception.h:657
A method or algorithm argument contains illegal values.
Definition Exception.h:633
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19