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: Chris Bielow $
25
// $Authors: Andreas Bertsch $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/CONCEPT/ClassTest.h>
29
#include <OpenMS/FORMAT/IdXMLFile.h>
31
///////////////////////////
32
#include <OpenMS/ANALYSIS/ID/FalseDiscoveryRate.h>
33
///////////////////////////
35
using namespace OpenMS;
38
START_TEST(FalseDiscoveryRate, "$Id: FalseDiscoveryRate_test.C 8907 2011-09-29 12:58:48Z aiche $")
40
/////////////////////////////////////////////////////////////
41
/////////////////////////////////////////////////////////////
43
FalseDiscoveryRate* ptr = 0;
44
FalseDiscoveryRate* nullPointer = 0;
45
START_SECTION(FalseDiscoveryRate())
47
ptr = new FalseDiscoveryRate();
48
TEST_NOT_EQUAL(ptr, nullPointer)
52
START_SECTION(~FalseDiscoveryRate())
58
START_SECTION((void apply(std::vector< PeptideIdentification > &fwd_ids, std::vector< PeptideIdentification > &rev_ids)))
60
ptr = new FalseDiscoveryRate();
61
vector<ProteinIdentification> fwd_prot_ids, rev_prot_ids;
62
vector<PeptideIdentification> fwd_pep_ids, rev_pep_ids;
64
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("XTandem_fwd_ids.idXML"), fwd_prot_ids, fwd_pep_ids, document_id);
65
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("XTandem_rev_ids.idXML"), rev_prot_ids, rev_pep_ids, document_id);
66
ptr->apply(fwd_pep_ids, rev_pep_ids);
67
TOLERANCE_ABSOLUTE(0.0001)
68
for (vector<PeptideIdentification>::const_iterator it = fwd_pep_ids.begin(); it != fwd_pep_ids.end(); ++it)
70
if (it->getHits().size() > 0)
72
PeptideHit hit(*it->getHits().begin());
73
DoubleReal fdr(hit.getScore());
74
DoubleReal orig_score((DoubleReal)hit.getMetaValue("XTandem_score"));
76
if (orig_score >= 39.4)
78
TEST_REAL_SIMILAR(fdr, 0)
80
if (orig_score <= 37.9 + 0.0001 && orig_score >= 37.9 - 0.0001)
82
TEST_REAL_SIMILAR(fdr, 0.08)
89
START_SECTION((void apply(std::vector< ProteinIdentification > &fwd_ids, std::vector< ProteinIdentification > &rev_ids)))
91
vector<ProteinIdentification> fwd_prot_ids, rev_prot_ids;
92
vector<PeptideIdentification> fwd_pep_ids, rev_pep_ids;
94
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("XTandem_fwd_ids_withProtScores.idXML"), fwd_prot_ids, fwd_pep_ids, document_id);
95
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("XTandem_rev_ids_withProtScores.idXML"), rev_prot_ids, rev_pep_ids, document_id);
96
ptr->apply(fwd_prot_ids, rev_prot_ids);
97
TOLERANCE_ABSOLUTE(0.001)
99
for (vector<ProteinIdentification>::const_iterator prot_it = fwd_prot_ids.begin(); prot_it != fwd_prot_ids.end(); ++prot_it)
101
if (prot_it->getHits().size() > 0)
103
for (vector<ProteinHit>::const_iterator it = prot_it->getHits().begin(); it != prot_it->getHits().end(); ++it)
106
DoubleReal fdr(hit.getScore());
107
DoubleReal orig_score((DoubleReal)hit.getMetaValue("XTandem_score"));
109
// it gets here, but neither of the conditions below are ever satisfied
110
if (orig_score < -1.8)
112
TEST_REAL_SIMILAR(fdr, 0)
114
if (orig_score == 0.0)
116
TEST_REAL_SIMILAR(fdr, 0.897384)
124
START_SECTION((void apply(std::vector< PeptideIdentification > &id)))
126
vector<ProteinIdentification> prot_ids;
127
vector<PeptideIdentification> pep_ids;
128
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("FalseDiscoveryRate_OMSSA.idXML"), prot_ids, pep_ids);
131
TOLERANCE_ABSOLUTE(0.001)
132
for (Size z = 1; z <= 4; ++z)
134
for (vector<PeptideIdentification>::const_iterator it = pep_ids.begin(); it != pep_ids.end(); ++it)
136
for (vector<PeptideHit>::const_iterator pit = it->getHits().begin(); pit != it->getHits().end(); ++pit)
138
DoubleReal fdr(pit->getScore());
139
DoubleReal orig_score((DoubleReal)pit->getMetaValue("OMSSA_score"));
141
if (orig_score <= 10e-4)
143
TEST_REAL_SIMILAR(fdr, 0)
145
if (orig_score >= 1000 && pit->getCharge() != 1)
147
TEST_EQUAL(fdr > 0.1, true)
155
START_SECTION((void apply(std::vector<ProteinIdentification>& ids)))
157
vector<ProteinIdentification> fwd_prot_ids, rev_prot_ids, prot_ids;
158
vector<PeptideIdentification> fwd_pep_ids, rev_pep_ids, pep_ids;
160
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("XTandem_fwd_ids.idXML"), fwd_prot_ids, fwd_pep_ids, document_id);
161
IdXMLFile().load(OPENMS_GET_TEST_DATA_PATH("XTandem_rev_ids.idXML"), rev_prot_ids, rev_pep_ids, document_id);
163
for (vector<ProteinIdentification>::const_iterator it = fwd_prot_ids.begin(); it != fwd_prot_ids.end(); ++it)
165
prot_ids.push_back(*it);
168
for (vector<ProteinIdentification>::const_iterator it = rev_prot_ids.begin(); it != rev_prot_ids.end(); ++it)
170
prot_ids.push_back(*it);
173
ptr->apply(prot_ids);
175
TOLERANCE_ABSOLUTE(0.001)
177
for (vector<ProteinIdentification>::const_iterator prot_it = prot_ids.begin(); prot_it != prot_ids.end(); ++prot_it)
179
if (prot_it->getHits().size() > 0)
181
for (vector<ProteinHit>::const_iterator it = prot_it->getHits().begin(); it != prot_it->getHits().end(); ++it)
184
DoubleReal fdr(hit.getScore());
185
DoubleReal orig_score((DoubleReal)hit.getMetaValue("XTandem_score"));
187
if (orig_score < -1.8)
189
TEST_REAL_SIMILAR(fdr, 0)
191
if (orig_score == -1.7)
193
TEST_REAL_SIMILAR(fdr, 0.0617284)
195
if (orig_score > -1.2)
197
TEST_EQUAL(fdr > 0.1, true)
205
/////////////////////////////////////////////////////////////
206
/////////////////////////////////////////////////////////////