ProteoWizard
PeptideIDMapTest.cpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.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 
24 #include "PeptideIDMap.hpp"
27 
28 
29 using namespace pwiz::util;
30 using namespace pwiz::peptideid;
31 
32 
33 void test()
34 {
35  PeptideIDMap peptideIDMap;
36 
37  PeptideID::Record* record = &peptideIDMap["1"];
38  record->nativeID = "1";
39  record->sequence = "DARREN";
40  record->normalizedScore = .5;
41 
42  record = &peptideIDMap["2"];
43  record->nativeID = "2";
44  record->sequence = "KESSNER";
45  record->normalizedScore = .6;
46 
47  PeptideID::Record result = peptideIDMap.record(PeptideID::Location("goober", 0, 0));
48  unit_assert(result.nativeID.empty());
49  unit_assert(result.sequence.empty());
50  unit_assert_equal(result.normalizedScore, 0, 1e-15);
51 
52  result = peptideIDMap.record(PeptideID::Location("1", 0, 0));
53  unit_assert(result.nativeID == "1");
54  unit_assert(result.sequence == "DARREN");
55  unit_assert_equal(result.normalizedScore, .5, 1e-15);
56 
57  result = peptideIDMap.record(PeptideID::Location("2", 0, 0));
58  unit_assert(result.nativeID == "2");
59  unit_assert(result.sequence == "KESSNER");
60  unit_assert_equal(result.normalizedScore, .6, 1e-15);
61 }
62 
63 
64 int main(int argc, char* argv[])
65 {
66  TEST_PROLOG(argc, argv)
67 
68  try
69  {
70  test();
71  }
72  catch (exception& e)
73  {
74  TEST_FAILED(e.what())
75  }
76  catch (...)
77  {
78  TEST_FAILED("Caught unknown exception.")
79  }
80 
82 }
83 
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
main
int main(int argc, char *argv[])
Definition: PeptideIDMapTest.cpp:64
pwiz::peptideid::PeptideID::Location
Definition: PeptideID.hpp:47
pwiz::peptideid::PeptideID::Record::sequence
std::string sequence
Definition: PeptideID.hpp:61
pwiz::peptideid
Definition: PeptideID.hpp:37
pwiz::util
Definition: almost_equal.hpp:33
pwiz::peptideid::PeptideIDMap
Definition: PeptideIDMap.hpp:39
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
Std.hpp
pwiz::peptideid::PeptideIDMap::record
virtual Record record(const pwiz::peptideid::PeptideID::Location &location) const
pwiz::proteome::AminoAcid::Info::record
PWIZ_API_DECL const Record & record(Type type)
returns the amino acid's Record by type
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
PeptideIDMap.hpp
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
test
void test()
Definition: PeptideIDMapTest.cpp:33