ProteoWizard
pwiz
analysis
peptideid
PeptideID_flatTest.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 2008 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_flat.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
*
sampleFlat
=
37
"1\t1000.0\t1000.0\t0.9\tABC\n"
38
"2\t2000\t500.0\t0.7\tDEF\n"
;
39
40
const
char
*
sampleMSI
=
41
"scan time mz mass intensity charge chargeStates kl background median peaks scanFirst scanLast scanCount\n"
42
"1 2.248 878.889 1755.7633 61.847733 2 1 0.05977635 0.9152653 1.0536207 5 693 721 1\n"
43
"1 2.248 752.86017 1503.7076 41.52021 2 1 0.10636939 1.6415321 0.8086928 5 693 715 1\n"
44
"1 2.248 933.4445 932.4372 33.840942 1 1 0.2521489 5.717129 2.8336976 2 695 707 1\n"
45
"4 7.116 801.4013 800.3538 18.389582 1 1 0.6249515 1.6089915 1.3883085 3 698 713 1\n"
;
46
47
48
void
testIStream
()
49
{
50
istringstream data (
sampleFlat
);
51
52
PeptideID_flat
ppFlat(&data, shared_ptr<FlatRecordBuilder>(
new
FlatRecordBuilder
));
53
54
PeptideID::Location
loc(
"1"
, 1000., 0);
55
PeptideID::Record
bf = ppFlat.
record
(loc);
56
57
unit_assert
(bf.
nativeID
==
"1"
);
58
unit_assert
(bf.
sequence
==
"ABC"
);
59
unit_assert_equal
(bf.
normalizedScore
, 0.9, 1e-14);
60
}
61
62
void
testMSInspectIStream
()
63
{
64
istringstream data (
sampleMSI
);
65
66
PeptideID_flat
ppFlat(&data, shared_ptr<FlatRecordBuilder>(
new
MSInspectRecordBuilder
()));
67
68
PeptideID::Location
loc(
"1"
, 2.248, 878.889);
69
PeptideID::Record
bf = ppFlat.
record
(loc);
70
71
unit_assert
(bf.
nativeID
==
"1"
);
72
unit_assert
(bf.
sequence
==
""
);
73
unit_assert_equal
(bf.
normalizedScore
, 0.05977635, 1e-14);
74
}
75
76
//void testFilename()
77
//{
78
// ifstream data ("test.txt");
79
//
80
// PeptideID_flat<> ppFlat(&data);
81
//
82
//
83
// PeptideID::Location loc("1", 0, 0.9);
84
// PeptideID::Record bf = ppFlat.record(loc);
85
//
86
// unit_assert(bf.nativeID == "1");
87
// unit_assert(bf.sequence == "ABC");
88
// unit_assert_equal(bf.normalizedScore, 0.9, 1e-14);
89
//}
90
91
int
main
(
int
argc,
char
* argv[])
92
{
93
TEST_PROLOG
(argc, argv)
94
95
try
96
{
97
if
(argc>1 && !strcmp(argv[1],
"-v"
))
os_
= &cout;
98
testIStream
();
99
testMSInspectIStream
();
100
//testFilename();
101
//testDone();
102
//testBadXML();
103
//testNested();
104
}
105
catch
(exception& e)
106
{
107
TEST_FAILED
(e.what())
108
}
109
catch
(...)
110
{
111
TEST_FAILED
(
"Caught unknown exception."
)
112
}
113
114
TEST_EPILOG
115
}
pwiz::peptideid::PeptideID::Record::nativeID
std::string nativeID
Definition:
PeptideID.hpp:60
sampleMSI
const char * sampleMSI
Definition:
PeptideID_flatTest.cpp:40
pwiz::peptideid::PeptideID::Record::normalizedScore
double normalizedScore
Definition:
PeptideID.hpp:65
PeptideID_flat.hpp
testIStream
void testIStream()
Definition:
PeptideID_flatTest.cpp:48
os_
ostream * os_
Definition:
PeptideID_flatTest.cpp:34
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
pwiz::peptideid::MSInspectRecordBuilder
Definition:
PeptideID_flat.hpp:55
pwiz::peptideid
Definition:
PeptideID.hpp:37
pwiz::util
Definition:
almost_equal.hpp:33
pwiz::peptideid::FlatRecordBuilder
Definition:
PeptideID_flat.hpp:39
TEST_EPILOG
#define TEST_EPILOG
Definition:
unit.hpp:183
main
int main(int argc, char *argv[])
Definition:
PeptideID_flatTest.cpp:91
pwiz::minimxml::SAXParser
An extended SAX interface for custom XML stream parsing.
Definition:
SAXParser.hpp:54
pwiz::peptideid::PeptideID_flat
This class allows access to peptides listed in a flat tab delimited text file.
Definition:
PeptideID_flat.hpp:78
Std.hpp
testMSInspectIStream
void testMSInspectIStream()
Definition:
PeptideID_flatTest.cpp:62
pwiz::peptideid::PeptideID::Record
Definition:
PeptideID.hpp:59
TEST_FAILED
#define TEST_FAILED(x)
Definition:
unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition:
unit.hpp:175
unit.hpp
unit_assert
#define unit_assert(x)
Definition:
unit.hpp:85
sampleFlat
const char * sampleFlat
Definition:
PeptideID_flatTest.cpp:36
pwiz::peptideid::PeptideID_flat::record
virtual Record record(const Location &location) const
Returns the Record object associated with the given nativeID.
Generated by
1.8.20