ProteoWizard
PeptideID_flatTest.cpp
Go to the documentation of this file.
1 //
2 // $Id: PeptideID_flatTest.cpp 4129 2012-11-20 00:05:37Z chambm $
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 
24 #include <cstring>
25 
26 #include "PeptideID_flat.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 
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 
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();
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 
115 }