ProteoWizard
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
24#include <cstring>
25
26#include "PeptideID_pepXML.hpp"
29
30using namespace pwiz::util;
31using namespace pwiz::peptideid;
32using namespace pwiz::minimxml::SAXParser;
33
34ostream* os_;
35
36const 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
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
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
84int 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;
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
107}
int main(int argc, char *argv[])
const char * samplePepXML
void testFilename()
void testIStream()
ostream * os_
This class allows access to identified proteins in PeptideProphet files.
virtual Record record(const Location &location) const
Returns the Record object associated with the given nativeID.
An extended SAX interface for custom XML stream parsing.
Definition SAXParser.hpp:54
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175