ProteoWizard
ReferencesTest.cpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6 //
7 // Copyright 2009 Vanderbilt University - Nashville, TN 37232
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 //
21 
22 
23 #include "References.hpp"
27 
28 
29 using namespace pwiz::util;
30 using namespace pwiz::cv;
31 using namespace pwiz::tradata;
32 
33 
34 ostream* os_ = 0;
35 
36 
37 
39 {
40  if (os_) *os_ << "testTransition()\n";
41 
42  Transition transition;
43  transition.peptidePtr = PeptidePtr(new Peptide("pep1"));
44  transition.peptidePtr->proteinPtrs.push_back(ProteinPtr(new Protein("prot1")));
45  transition.compoundPtr = CompoundPtr(new Compound("cmp1"));
46 
47  TraData td;
48  td.peptidePtrs.push_back(PeptidePtr(new Peptide("pep1")));
49  td.peptidePtrs.back()->set(MS_theoretical_mass, 123);
50  td.peptidePtrs.back()->proteinPtrs.push_back(ProteinPtr(new Protein("prot1")));
51  td.peptidePtrs.back()->proteinPtrs.back()->sequence = "ABCD";
52 
53  td.compoundPtrs.push_back(CompoundPtr(new Compound("cmp1")));
54  td.compoundPtrs.back()->retentionTimes.push_back(RetentionTime());
55  td.compoundPtrs.back()->retentionTimes.back().set(MS_peak_intensity, 123);
56 
57  References::resolve(transition, td);
58 
59  unit_assert(transition.peptidePtr->cvParam(MS_theoretical_mass).value == "123");
60  unit_assert(transition.peptidePtr->proteinPtrs.back().get());
61  unit_assert(transition.peptidePtr->proteinPtrs.back()->sequence == "ABCD");
62  unit_assert(!transition.compoundPtr->retentionTimes.empty());
63  unit_assert(transition.compoundPtr->retentionTimes.back().cvParam(MS_peak_intensity).value == "123");
64 }
65 
66 
68 {
69  TraData td;
70  td.proteinPtrs.push_back(ProteinPtr(new Protein("prot1")));
71  td.proteinPtrs.back()->sequence = "ABCD";
72 
73  td.peptidePtrs.push_back(PeptidePtr(new Peptide("pep1")));
74  td.peptidePtrs.back()->set(MS_theoretical_mass, 123);
75  td.peptidePtrs.back()->proteinPtrs.push_back(ProteinPtr(new Protein("prot1")));
76 
77  td.compoundPtrs.push_back(CompoundPtr(new Compound("cmp1")));
78  td.compoundPtrs.back()->retentionTimes.push_back(RetentionTime());
79  td.compoundPtrs.back()->retentionTimes.back().set(MS_peak_intensity, 123);
80 
81  td.transitions.push_back(Transition());
82  Transition& transition = td.transitions.back();
83  transition.peptidePtr = PeptidePtr(new Peptide("pep1"));
84  transition.peptidePtr->proteinPtrs.push_back(ProteinPtr(new Protein("prot1")));
85  transition.compoundPtr = CompoundPtr(new Compound("cmp1"));
86 
88 
89  unit_assert(transition.peptidePtr->cvParam(MS_theoretical_mass).value == "123");
90  unit_assert(transition.peptidePtr->proteinPtrs.back().get());
91  unit_assert(transition.peptidePtr->proteinPtrs.back()->sequence == "ABCD");
92  unit_assert(!transition.compoundPtr->retentionTimes.empty());
93  unit_assert(transition.compoundPtr->retentionTimes.back().cvParam(MS_peak_intensity).value == "123");
94 }
95 
96 
97 void test()
98 {
100  testTraData();
101 }
102 
103 
104 int main(int argc, char* argv[])
105 {
106  TEST_PROLOG_EX(argc, argv, "_TraData")
107 
108  try
109  {
110  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
111  test();
112  }
113  catch (exception& e)
114  {
115  TEST_FAILED(e.what())
116  }
117  catch (...)
118  {
119  TEST_FAILED("Caught unknown exception.")
120  }
121 
123 }
124 
pwiz::tradata::CompoundPtr
boost::shared_ptr< Compound > CompoundPtr
Definition: TraData.hpp:254
test
void test()
Definition: ReferencesTest.cpp:212
pwiz::cv
Definition: cv.hpp:108
pwiz::tradata::Compound
Chemical compound other than a peptide for which one or more transitions.
Definition: TraData.hpp:240
pwiz::identdata::References::resolve
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
pwiz::proteome::Peptide
represents a peptide or polypeptide (a sequence of amino acids)
Definition: Peptide.hpp:61
MS_theoretical_mass
MS_theoretical_mass
theoretical mass: The theoretical mass of the molecule (e.g. the peptide sequence and its modificatio...
Definition: cv.hpp:3810
os_
ostream * os_
Definition: ReferencesTest.cpp:36
main
int main(int argc, char *argv[])
Definition: ReferencesTest.cpp:221
testTransition
void testTransition()
Definition: ReferencesTest.cpp:38
pwiz::util
Definition: almost_equal.hpp:33
pwiz::tradata::TraData
Definition: TraData.hpp:350
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
XMLWriter.hpp
Std.hpp
pwiz::tradata::TraData::transitions
std::vector< Transition > transitions
List of transitions.
Definition: TraData.hpp:379
pwiz::tradata::TraData::proteinPtrs
std::vector< ProteinPtr > proteinPtrs
List of proteins for which one or more transitions are intended to identify.
Definition: TraData.hpp:372
pwiz::proteome::Protein
Definition: ProteomeData.hpp:36
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
References.hpp
testTraData
void testTraData()
Definition: ReferencesTest.cpp:67
MS_peak_intensity
MS_peak_intensity
peak intensity: Intensity of ions as measured by the height or area of a peak in a mass spectrum.
Definition: cv.hpp:402
TEST_PROLOG_EX
#define TEST_PROLOG_EX(argc, argv, suffix)
Definition: unit.hpp:157
pwiz::tradata::TraData::compoundPtrs
std::vector< CompoundPtr > compoundPtrs
Definition: TraData.hpp:376
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
pwiz::tradata::RetentionTime
Definition: TraData.hpp:91
pwiz::tradata
Definition: DefaultReaderList.hpp:32
pwiz::tradata::Transition
Definition: TraData.hpp:273
pwiz::tradata::PeptidePtr
boost::shared_ptr< Peptide > PeptidePtr
Definition: TraData.hpp:236
pwiz::tradata::Transition::peptidePtr
PeptidePtr peptidePtr
Reference to a peptide which this transition is intended to identify.
Definition: TraData.hpp:279
pwiz::tradata::Transition::compoundPtr
CompoundPtr compoundPtr
Reference to a compound for this transition.
Definition: TraData.hpp:282
pwiz::tradata::TraData::peptidePtrs
std::vector< PeptidePtr > peptidePtrs
List of compounds (including peptides) for which one or more transitions are intended to identify.
Definition: TraData.hpp:375
pwiz::proteome::ProteinPtr
boost::shared_ptr< Protein > ProteinPtr
Definition: ProteomeData.hpp:48