40 typedef typename std::set<const DigestionEnzymeType*>::iterator
EnzymeIterator;
46 static InstanceType* db_ =
nullptr;
49 db_ =
new InstanceType;
91 String(
"Enzyme with regex " + cleavage_regex +
" was not registered in Enzyme DB, register first!").c_str());
102 all_names.push_back((*it)->getName());
139 if (!db_file.empty())
184 if (param.
empty())
return;
186 std::vector<String> split;
188 if (split[0] !=
"Enzymes")
190 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, split[0],
"name 'Enzymes' expected");
195 std::map<String, String> values;
196 String previous_enzyme = split[1];
201 if (split[0] !=
"Enzymes")
break;
202 if (split[1] != previous_enzyme)
206 previous_enzyme = split[1];
209 values[it.getName()] =
String(it->value.toString());
221 const DigestionEnzymeType*
parseEnzyme_(std::map<String, String>& values)
const
223 DigestionEnzymeType* enzy_ptr =
new DigestionEnzymeType();
225 for (std::map<String, String>::iterator it = values.begin(); it != values.end(); ++it)
227 const String& key = it->first;
228 const String& value = it->second;
229 if (!enzy_ptr->setValueFromFile(key, value))
231 OPENMS_LOG_ERROR <<
"Error while parsing enzymes file: unknown key '" << key <<
"' with value '" << value <<
"'" << std::endl;
241 String name = enzyme->getName();
247 const DigestionEnzymeType* old = existing->second;
250 String old_name = old->getName();
253 for (
const auto& syn : old->getSynonyms())
258 if (!old->getRegEx().empty())
270 for (std::set<String>::const_iterator it = enzyme->getSynonyms().begin(); it != enzyme->getSynonyms().end(); ++it)
275 if (enzyme->getRegEx() !=
"")
#define OPENMS_LOG_ERROR
Macro for non-fatal errors (processing continues)
Definition LogStream.h:546
subpage TOPP_TargetedFileConverter Converts targeted feature or consensus feature files subpage TOPP_FileInfo Shows basic information about the file
Definition TOPP.doxygen:44
Digestion enzyme database (base class)
Definition DigestionEnzymeDB.h:33
const DigestionEnzymeType * parseEnzyme_(std::map< String, String > &values) const
parses an enzyme, given the key/value pairs from an XML file
Definition DigestionEnzymeDB.h:221
static InstanceType * getInstance()
this member function serves as a replacement of the constructor
Definition DigestionEnzymeDB.h:44
DigestionEnzymeDB(const String &db_file="")
Definition DigestionEnzymeDB.h:137
DigestionEnzymeDB(const DigestionEnzymeDB &enzymes_db)=delete
copy constructor
std::map< String, const DigestionEnzymeType * > enzyme_regex_
index by regex
Definition DigestionEnzymeDB.h:284
ConstEnzymeIterator endEnzyme() const
Definition DigestionEnzymeDB.h:133
virtual ~DigestionEnzymeDB()
destructor
Definition DigestionEnzymeDB.h:58
ConstEnzymeIterator beginEnzyme() const
Definition DigestionEnzymeDB.h:132
const DigestionEnzymeType * getEnzyme(const String &name) const
Definition DigestionEnzymeDB.h:73
void getAllNames(std::vector< String > &all_names) const
returns all the enzyme names (does NOT include synonym names)
Definition DigestionEnzymeDB.h:97
void readEnzymesFromFile_(const String &filename)
reads enzymes from the given file
Definition DigestionEnzymeDB.h:178
DigestionEnzymeDB & operator=(const DigestionEnzymeDB &enzymes_db)=delete
assignment operator
std::set< constDigestionEnzymeType * >::const_iterator ConstEnzymeIterator
Definition DigestionEnzymeDB.h:39
std::set< constDigestionEnzymeType * >::iterator EnzymeIterator
Definition DigestionEnzymeDB.h:40
bool hasEnzyme(const DigestionEnzymeType *enzyme) const
returns true if the db contains the enzyme of the given pointer
Definition DigestionEnzymeDB.h:123
bool hasEnzyme(const String &name) const
returns true if the db contains a enzyme with the given name (supports synonym names)
Definition DigestionEnzymeDB.h:111
std::set< const DigestionEnzymeType * > const_enzymes_
set of enzymes
Definition DigestionEnzymeDB.h:286
std::map< String, const DigestionEnzymeType * > enzyme_names_
index by names
Definition DigestionEnzymeDB.h:282
const DigestionEnzymeType * getEnzymeByRegEx(const String &cleavage_regex) const
Definition DigestionEnzymeDB.h:85
bool readEnzymesFromFileIfPresent_(const String &filename)
Reads enzymes from the given file if it exists.
Definition DigestionEnzymeDB.h:163
bool hasRegEx(const String &cleavage_regex) const
returns true if the db contains a enzyme with the given regex
Definition DigestionEnzymeDB.h:117
void addEnzyme_(const DigestionEnzymeType *enzyme)
Definition DigestionEnzymeDB.h:239
Exception base class.
Definition Exception.h:63
Element could not be found exception.
Definition Exception.h:654
File not found exception.
Definition Exception.h:475
A method or algorithm argument contains illegal values.
Definition Exception.h:630
Parse Error exception.
Definition Exception.h:593
static String find(const String &filename, StringList directories=StringList())
Looks up the location of the file filename.
The file pendant of the Param class used to load and store the param datastructure as paramXML (i....
Definition ParamXMLFile.h:25
void load(const String &filename, Param ¶m)
Read XML file.
Forward const iterator for the Param class.
Definition Param.h:170
std::string getName() const
Returns the absolute path of the current element (including all sections)
Management and storage of parameters / INI files.
Definition Param.h:46
ParamIterator begin() const
Begin iterator for the internal tree.
bool empty() const
Returns if there are no entries.
ParamIterator end() const
End iterator for the internal tree.
A more convenient string class.
Definition String.h:34
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
String & toLower()
Converts the string to lowercase.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19