1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Stephan Aiche $
25
// $Authors: Andreas Bertsch $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/CONCEPT/ClassTest.h>
30
///////////////////////////
31
#include <OpenMS/CHEMISTRY/ModificationsDB.h>
34
///////////////////////////
36
using namespace OpenMS;
39
START_TEST(ModificationsDB, "$Id: ModificationsDB_test.C 9373 2011-12-21 12:00:14Z timosachsenberg $")
41
/////////////////////////////////////////////////////////////
42
/////////////////////////////////////////////////////////////
44
ModificationsDB* ptr = 0;
45
ModificationsDB* nullPointer = 0;
46
START_SECTION(ModificationsDB* getInstance())
48
ptr = ModificationsDB::getInstance();
49
TEST_NOT_EQUAL(ptr, nullPointer)
53
START_SECTION(Size getNumberOfModifications() const)
54
// range because data may change over time
55
TEST_EQUAL(ptr->getNumberOfModifications() > 100, true);
58
START_SECTION(const ResidueModification& getModification(Size index) const)
59
TEST_EQUAL(ptr->getModification(0).getId().size() > 0, true)
62
START_SECTION(void searchModifications(std::set<const ResidueModification*>& mods, const String& orgin, const String& mod_name, ResidueModification::Term_Specificity term_spec) const)
63
set<const ResidueModification*> mods;
64
ptr->searchModifications(mods, "T", "Phosphorylation", ResidueModification::ANYWHERE);
65
TEST_EQUAL(mods.size(), 1)
66
TEST_STRING_EQUAL((*mods.begin())->getFullId(), "Phospho (T)")
69
START_SECTION((void searchTerminalModifications(std::set< const ResidueModification * > &mods, const String &name, ResidueModification::Term_Specificity term_spec) const))
70
set<const ResidueModification*> mods;
71
ptr->searchTerminalModifications(mods, "NIC", ResidueModification::N_TERM);
72
TEST_EQUAL(mods.size(), 1)
75
START_SECTION((void searchModifications(std::set< const ResidueModification * > &mods, const String &mod_name, ResidueModification::Term_Specificity term_spec) const ))
77
set<const ResidueModification*> mods;
78
ptr->searchTerminalModifications(mods, "Label:18O(1)", ResidueModification::ANYWHERE);
80
TEST_EQUAL(mods.size(), 4)
81
ABORT_IF(mods.size() != 4)
83
set<const ResidueModification*>::const_iterator mod_it = mods.begin();
85
TEST_STRING_EQUAL((*mod_it)->getOrigin(), "Y")
86
TEST_STRING_EQUAL((*mod_it)->getId(), "Label:18O(1)")
87
TEST_EQUAL((*mod_it)->getTermSpecificity(), ResidueModification::ANYWHERE)
90
TEST_STRING_EQUAL((*mod_it)->getOrigin(), "T")
91
TEST_STRING_EQUAL((*mod_it)->getId(), "Label:18O(1)")
92
TEST_EQUAL((*mod_it)->getTermSpecificity(), ResidueModification::ANYWHERE)
95
TEST_STRING_EQUAL((*mod_it)->getOrigin(), "S")
96
TEST_STRING_EQUAL((*mod_it)->getId(), "Label:18O(1)")
97
TEST_EQUAL((*mod_it)->getTermSpecificity(), ResidueModification::ANYWHERE)
100
TEST_STRING_EQUAL((*mod_it)->getOrigin(), "C-term")
101
TEST_STRING_EQUAL((*mod_it)->getId(), "Label:18O(1)")
102
TEST_EQUAL((*mod_it)->getTermSpecificity(), ResidueModification::C_TERM)
105
ptr->searchTerminalModifications(mods, "Label:18O(1)", ResidueModification::C_TERM);
107
TEST_EQUAL(mods.size(), 1)
108
ABORT_IF(mods.size() != 1)
110
mod_it = mods.begin();
111
TEST_STRING_EQUAL((*mod_it)->getOrigin(), "C-term")
112
TEST_STRING_EQUAL((*mod_it)->getId(), "Label:18O(1)")
113
TEST_EQUAL((*mod_it)->getTermSpecificity(), ResidueModification::C_TERM)
116
ptr->searchTerminalModifications(mods, "Label:18O(1)", ResidueModification::N_TERM);
118
TEST_EQUAL(mods.size(), 0)
119
ABORT_IF( !mods.empty() )
124
START_SECTION((void getTerminalModificationsByDiffMonoMass(std::vector< String > &mods, DoubleReal mass, DoubleReal error, ResidueModification::Term_Specificity term_spec)))
126
ptr->getTerminalModificationsByDiffMonoMass(mods, 42, 0.1, ResidueModification::N_TERM);
127
set<String> uniq_mods;
128
for (vector<String>::const_iterator it = mods.begin(); it != mods.end(); ++it)
130
uniq_mods.insert(*it);
132
TEST_EQUAL(mods.size(), 16)
133
TEST_EQUAL(uniq_mods.size(), 16)
134
TEST_EQUAL(uniq_mods.find("Acetyl (N-term)") != uniq_mods.end(), true)
138
START_SECTION(const ResidueModification& getModification(const String & modification) const)
139
TEST_EQUAL(ptr->getModification("Carboxymethyl (C)").getFullId(), "Carboxymethyl (C)")
140
TEST_EQUAL(ptr->getModification("Carboxymethyl (C)").getId(), "Carboxymethyl")
143
START_SECTION((const ResidueModification& getModification(const String &residue_name, const String &mod_name, ResidueModification::Term_Specificity term_spec) const))
144
TEST_EQUAL(ptr->getModification("S", "Phosphorylation", ResidueModification::ANYWHERE).getId(), "Phospho")
145
TEST_EQUAL(ptr->getModification("S", "Phosphorylation", ResidueModification::ANYWHERE).getFullId(), "Phospho (S)")
148
START_SECTION(Size findModificationIndex(const String &mod_name) const)
149
Size index = numeric_limits<Size>::max();
150
index = ptr->findModificationIndex("Phospho (T)");
151
TEST_NOT_EQUAL(index, numeric_limits<Size>::max())
154
START_SECTION(void getModificationsByDiffMonoMass(std::vector< String > &mods, DoubleReal mass, DoubleReal error=0.0))
156
ptr->getModificationsByDiffMonoMass(mods, 80.0, 0.1);
157
set<String> uniq_mods;
158
for (vector<String>::const_iterator it = mods.begin(); it != mods.end(); ++it)
160
uniq_mods.insert(*it);
163
TEST_EQUAL(uniq_mods.find("Phospho (S)") != uniq_mods.end(), true)
164
TEST_EQUAL(uniq_mods.find("Phospho (T)") != uniq_mods.end(), true)
165
TEST_EQUAL(uniq_mods.find("Phospho (Y)") != uniq_mods.end(), true)
166
TEST_EQUAL(uniq_mods.find("Sulfo (S)") != uniq_mods.end(), true)
169
START_SECTION(void readFromOBOFile(const String &filename))
170
// implicitely tested above
174
START_SECTION(void readFromUnimodXMLFile(const String &filename))
175
// just provided for convenience at the moment
179
START_SECTION((const ResidueModification& getTerminalModification(const String &name, ResidueModification::Term_Specificity term_spec) const))
180
TEST_EQUAL(ptr->getTerminalModification("NIC", ResidueModification::N_TERM).getId(), "NIC")
181
TEST_EQUAL(ptr->getTerminalModification("NIC", ResidueModification::N_TERM).getFullId(), "NIC (N-term)")
182
TEST_EQUAL(ptr->getTerminalModification("Acetyl", ResidueModification::N_TERM).getFullId(), "Acetyl (N-term)")
185
START_SECTION((void getModificationsByDiffMonoMass(std::vector< String > &mods, const String &residue, DoubleReal mass, DoubleReal error=0.0)))
187
ptr->getModificationsByDiffMonoMass(mods, "S", 80.0, 0.1);
188
TEST_EQUAL(find(mods.begin(), mods.end(), "Phospho (S)") != mods.end(), true)
189
TEST_EQUAL(find(mods.begin(), mods.end(), "Sulfo (S)") != mods.end(), true)
192
START_SECTION((void getAllSearchModifications(std::vector< String > &modifications)))
194
ptr->getAllSearchModifications(mods);
195
TEST_EQUAL(find(mods.begin(), mods.end(), "Phospho (S)") != mods.end(), true)
196
TEST_EQUAL(find(mods.begin(), mods.end(), "Sulfo (S)") != mods.end(), true)
197
TEST_EQUAL(find(mods.begin(), mods.end(), "NIC (N-term)") != mods.end(), true)
198
TEST_EQUAL(find(mods.begin(), mods.end(), "Phospho") != mods.end(), false)
199
TEST_EQUAL(find(mods.begin(), mods.end(), "Dehydrated (N-term C)") != mods.end(), true)
204
/////////////////////////////////////////////////////////////
205
/////////////////////////////////////////////////////////////