ProteoWizard
pwiz
analysis
peptideid
PeptideID_pepXMLTest.cpp
Go to the documentation of this file.
1
//
2
// $Id$
3
//
4
//
5
// Original author: Robert Burke <robert.burke@cshs.org>
6
//
7
// Copyright 2007 Spielberg Family Center for Applied Proteomics
8
// Cedars-Sinai Medical Center, Los Angeles, California 90048
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License");
11
// you may not use this file except in compliance with the License.
12
// You may obtain a copy of the License at
13
//
14
// http://www.apache.org/licenses/LICENSE-2.0
15
//
16
// Unless required by applicable law or agreed to in writing, software
17
// distributed under the License is distributed on an "AS IS" BASIS,
18
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
// See the License for the specific language governing permissions and
20
// limitations under the License.
21
//
22
23
#include "
pwiz/utility/misc/Std.hpp
"
24
#include <cstring>
25
26
#include "
PeptideID_pepXML.hpp
"
27
#include "
pwiz/utility/minimxml/SAXParser.hpp
"
28
#include "
pwiz/utility/misc/unit.hpp
"
29
30
using namespace
pwiz::util
;
31
using namespace
pwiz::peptideid
;
32
using namespace
pwiz::minimxml::SAXParser
;
33
34
ostream*
os_
;
35
36
const
char
*
samplePepXML
=
37
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
38
"<msms_pipeline_analysis>\n"
39
"<msms_run_summary>\n"
40
"<spectrum_query start_scan=\"1\" end_scan=\"1\" retention_time_sec=\"1.0\">\n"
41
"<search_result>\n"
42
"<search_hit peptide=\"ABC\">\n"
43
"<analysis_result analysis=\"peptideprophet\">\n"
44
"<peptideprophet_result probability=\"0.900\">\n"
45
"<search_score_summary>\n"
46
"</search_score_summary>\n"
47
"</peptideprophet_result>\n"
48
"</analysis_result>\n"
49
"</search_hit>\n"
50
"</search_result>\n"
51
"</spectrum_query>\n"
52
"</msms_run_summary>\n"
53
"</msms_pipeline_analysis>\n"
;
54
55
void
testIStream
()
56
{
57
istringstream xml (
samplePepXML
);
58
59
PeptideID_pepXml
ppXml(&xml);
60
61
PeptideID::Location
loc(
"1"
, 1.0, 0.);
62
PeptideID::Record
bf = ppXml.
record
(loc);
63
64
unit_assert
(bf.
nativeID
==
"1"
);
65
unit_assert
(bf.
sequence
==
"ABC"
);
66
unit_assert_equal
(bf.
normalizedScore
, 0.9, 1e-15);
67
}
68
69
void
testFilename
()
70
{
71
ifstream xml (
"test.pep.xml"
);
72
73
PeptideID_pepXml
ppXml(&xml);
74
75
76
PeptideID::Location
loc(
"1"
, 1.0, 0.);
77
PeptideID::Record
bf = ppXml.
record
(loc);
78
79
unit_assert
(bf.
nativeID
==
"1"
);
80
unit_assert
(bf.
sequence
==
"ABC"
);
81
unit_assert_equal
(bf.
normalizedScore
, 0.9, 1e-15);
82
}
83
84
int
main
(
int
argc,
char
* argv[])
85
{
86
TEST_PROLOG
(argc, argv)
87
88
try
89
{
90
if
(argc>1 && !strcmp(argv[1],
"-v"
))
os_
= &cout;
91
testIStream
();
92
//testFilename();
93
//testDone();
94
//testBadXML();
95
//testNested();
96
}
97
catch
(exception& e)
98
{
99
TEST_FAILED
(e.what())
100
}
101
catch
(...)
102
{
103
TEST_FAILED
(
"Caught unknown exception."
)
104
}
105
106
TEST_EPILOG
107
}
pwiz::peptideid::PeptideID::Record::nativeID
std::string nativeID
Definition:
PeptideID.hpp:60
pwiz::peptideid::PeptideID::Record::normalizedScore
double normalizedScore
Definition:
PeptideID.hpp:65
unit_assert_equal
#define unit_assert_equal(x, y, epsilon)
Definition:
unit.hpp:99
pwiz::peptideid::PeptideID::Location
Definition:
PeptideID.hpp:47
pwiz::peptideid::PeptideID::Record::sequence
std::string sequence
Definition:
PeptideID.hpp:61
SAXParser.hpp
testIStream
void testIStream()
Definition:
PeptideID_pepXMLTest.cpp:55
samplePepXML
const char * samplePepXML
Definition:
PeptideID_pepXMLTest.cpp:36
testFilename
void testFilename()
Definition:
PeptideID_pepXMLTest.cpp:69
pwiz::peptideid
Definition:
PeptideID.hpp:37
pwiz::util
Definition:
almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition:
unit.hpp:183
pwiz::minimxml::SAXParser
An extended SAX interface for custom XML stream parsing.
Definition:
SAXParser.hpp:54
main
int main(int argc, char *argv[])
Definition:
PeptideID_pepXMLTest.cpp:84
Std.hpp
pwiz::peptideid::PeptideID::Record
Definition:
PeptideID.hpp:59
PeptideID_pepXML.hpp
TEST_FAILED
#define TEST_FAILED(x)
Definition:
unit.hpp:177
pwiz::peptideid::PeptideID_pepXml
This class allows access to identified proteins in PeptideProphet files.
Definition:
PeptideID_pepXML.hpp:42
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition:
unit.hpp:175
pwiz::peptideid::PeptideID_pepXml::record
virtual Record record(const Location &location) const
Returns the Record object associated with the given nativeID.
os_
ostream * os_
Definition:
PeptideID_pepXMLTest.cpp:34
unit.hpp
unit_assert
#define unit_assert(x)
Definition:
unit.hpp:85
Generated by
1.8.20