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
29using namespace pwiz::util;
30using namespace pwiz::cv;
31using namespace pwiz::tradata;
32
33
34ostream* 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
97void test()
98{
100 testTraData();
101}
102
103
104int 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
represents a peptide or polypeptide (a sequence of amino acids)
Definition Peptide.hpp:62
MS_theoretical_mass
theoretical mass: The theoretical mass of the molecule (e.g. the peptide sequence and its modificatio...
Definition cv.hpp:3810
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
boost::shared_ptr< Protein > ProteinPtr
PWIZ_API_DECL void resolve(RetentionTime &retentionTime, const TraData &td)
boost::shared_ptr< Compound > CompoundPtr
Definition TraData.hpp:254
boost::shared_ptr< Peptide > PeptidePtr
Definition TraData.hpp:236
Chemical compound other than a peptide for which one or more transitions.
Definition TraData.hpp:241
std::vector< ProteinPtr > proteinPtrs
List of proteins for which one or more transitions are intended to identify.
Definition TraData.hpp:372
std::vector< CompoundPtr > compoundPtrs
Definition TraData.hpp:376
std::vector< PeptidePtr > peptidePtrs
List of compounds (including peptides) for which one or more transitions are intended to identify.
Definition TraData.hpp:375
std::vector< Transition > transitions
List of transitions.
Definition TraData.hpp:379
PeptidePtr peptidePtr
Reference to a peptide which this transition is intended to identify.
Definition TraData.hpp:279
CompoundPtr compoundPtr
Reference to a compound for this transition.
Definition TraData.hpp:282
int main(int argc, char *argv[])
void testTraData()
ostream * os_
void testTransition()
void test()
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_PROLOG_EX(argc, argv, suffix)
Definition unit.hpp:157
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177