ProteoWizard
Functions
TraDataTest.cpp File Reference
#include "TraData.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

void testParamContainer ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ testParamContainer()

void testParamContainer ( )

Definition at line 32 of file TraDataTest.cpp.

33 {
34  ParamContainer pc;
35  pc.cvParams.push_back(MS_reflectron_on);
36  pc.cvParams.push_back(MS_MSn_spectrum);
37  pc.cvParams.push_back(MS_reflectron_off);
38  pc.cvParams.push_back(CVParam(MS_ionization_type, 420));
39  pc.userParams.push_back(UserParam("name1", "1", "type1", UO_second));
40  pc.userParams.push_back(UserParam("name2", "2", "type2", UO_minute));
41 
44 
46 
49 
51 
52  string result = "goober";
53  result = pc.cvParam(MS_selected_ion_m_z).value;
54  unit_assert(result == "");
55  result = pc.cvParam(MS_ionization_type).value;
56  unit_assert(result == "420");
57 
58  UserParam userParam = pc.userParam("name");
59  unit_assert(userParam.empty());
60  userParam = pc.userParam("name1");
61  unit_assert(userParam.name == "name1");
62  unit_assert(userParam.valueAs<int>() == 1);
63  unit_assert(userParam.type == "type1");
64  unit_assert(userParam.units == UO_second);
65  userParam = pc.userParam("name2");
66  unit_assert(userParam.name == "name2");
67  unit_assert(userParam.valueAs<double>() == 2);
68  unit_assert(userParam.type == "type2");
69  unit_assert(userParam.units == UO_minute);
70  unit_assert(pc.userParam("goober").valueAs<int>() == 0);
71 
72  pc.set(MS_ms_level, 2);
73  unit_assert(pc.cvParam(MS_ms_level).valueAs<int>() == 2);
74  pc.set(MS_ms_level, 3);
75  unit_assert(pc.cvParam(MS_ms_level).valueAs<int>() == 3);
76 
77  pc.set(MS_deisotoping, true);
78  unit_assert(pc.cvParam(MS_deisotoping).valueAs<bool>() == true);
79  pc.set(MS_deisotoping, false);
80  unit_assert(pc.cvParam(MS_deisotoping).valueAs<bool>() == false);
81 }

References CVID_Unknown, pwiz::data::ParamContainer::cvParam(), pwiz::data::ParamContainer::cvParamChild(), pwiz::data::ParamContainer::cvParams, pwiz::data::UserParam::empty(), pwiz::data::ParamContainer::hasCVParam(), pwiz::data::ParamContainer::hasCVParamChild(), MS_deisotoping, MS_ionization_type, MS_ms_level, MS_MSn_spectrum, MS_reflectron_off, MS_reflectron_on, MS_selected_ion_m_z, MS_spectrum_type, pwiz::data::UserParam::name, pwiz::data::ParamContainer::set(), pwiz::data::UserParam::type, unit_assert, pwiz::data::UserParam::units, UO_minute, UO_second, pwiz::data::ParamContainer::userParam(), pwiz::data::ParamContainer::userParams, pwiz::data::CVParam::value, pwiz::data::CVParam::valueAs(), and pwiz::data::UserParam::valueAs().

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 84 of file TraDataTest.cpp.

85 {
86  TEST_PROLOG(argc, argv)
87 
88  try
89  {
91  }
92  catch (exception& e)
93  {
94  TEST_FAILED(e.what())
95  }
96  catch (...)
97  {
98  TEST_FAILED("Caught unknown exception.")
99  }
100 
102 }

References TEST_EPILOG, TEST_FAILED, TEST_PROLOG, and testParamContainer().

pwiz::data::UserParam
Uncontrolled user parameters (essentially allowing free text). Before using these,...
Definition: ParamTypes.hpp:185
pwiz::data::UserParam::type
std::string type
the datatype of the parameter, where appropriate (e.g.: xsd:float).
Definition: ParamTypes.hpp:194
MS_deisotoping
MS_deisotoping
deisotoping: The removal of isotope peaks to represent the fragment ion as one data point and is comm...
Definition: cv.hpp:363
pwiz::data::ParamContainer::userParams
std::vector< UserParam > userParams
a collection of uncontrolled user terms
Definition: ParamTypes.hpp:253
MS_MSn_spectrum
MS_MSn_spectrum
MSn spectrum: MSn refers to multi-stage MS2 experiments designed to record product ion spectra where ...
Definition: cv.hpp:2364
pwiz::data::UserParam::valueAs
value_type valueAs() const
Templated value access with type conversion.
Definition: ParamTypes.hpp:214
pwiz::data::UserParam::units
CVID units
an optional CV parameter for the unit term associated with the value, if any (e.g....
Definition: ParamTypes.hpp:197
UO_second
UO_second
second: A time unit which is equal to the duration of 9 192 631 770 periods of the radiation correspo...
Definition: cv.hpp:13833
MS_ionization_type
MS_ionization_type
ionization type: The method by which gas phase ions are generated from the sample.
Definition: cv.hpp:285
pwiz::data::CVParam::valueAs
value_type valueAs() const
templated value access with type conversion
Definition: ParamTypes.hpp:112
testParamContainer
void testParamContainer()
Definition: TraDataTest.cpp:32
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
pwiz::data::ParamContainer::userParam
UserParam userParam(const std::string &) const
finds UserParam with specified name
pwiz::data::ParamContainer::cvParam
CVParam cvParam(CVID cvid) const
finds cvid in the container:
CVID_Unknown
CVID_Unknown
Definition: cv.hpp:114
pwiz::data::ParamContainer
The base class for elements that may contain cvParams, userParams, or paramGroup references.
Definition: ParamTypes.hpp:244
pwiz::data::ParamContainer::hasCVParamChild
bool hasCVParamChild(CVID cvid) const
returns true iff cvParams contains a child (is_a) of cvid (recursive)
pwiz::data::CVParam::value
std::string value
Definition: ParamTypes.hpp:47
pwiz::data::ParamContainer::hasCVParam
bool hasCVParam(CVID cvid) const
returns true iff cvParams contains exact cvid (recursive)
pwiz::data::ParamContainer::cvParamChild
CVParam cvParamChild(CVID cvid) const
finds child of cvid in the container:
MS_selected_ion_m_z
MS_selected_ion_m_z
selected ion m/z: Mass-to-charge ratio of an selected ion.
Definition: cv.hpp:2901
MS_spectrum_type
MS_spectrum_type
spectrum type: Spectrum type.
Definition: cv.hpp:2286
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
MS_ms_level
MS_ms_level
ms level: Stages of ms achieved in a multi stage mass spectrometry experiment.
Definition: cv.hpp:2139
pwiz::data::ParamContainer::set
void set(CVID cvid, const std::string &value="", CVID units=CVID_Unknown)
set/add a CVParam (not recursive)
MS_reflectron_on
MS_reflectron_on
reflectron on: Reflectron is on.
Definition: cv.hpp:636
pwiz::data::UserParam::empty
bool empty() const
returns true iff name, value, type, and units are all empty
MS_reflectron_off
MS_reflectron_off
reflectron off: Reflectron is off.
Definition: cv.hpp:633
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
UO_minute
UO_minute
minute: A time unit which is equal to 60 seconds.
Definition: cv.hpp:13896
pwiz::data::CVParam
represents a tag-value pair, where the tag comes from the controlled vocabulary
Definition: ParamTypes.hpp:44
pwiz::data::UserParam::name
std::string name
the name for the parameter.
Definition: ParamTypes.hpp:188
pwiz::data::ParamContainer::cvParams
std::vector< CVParam > cvParams
a collection of controlled vocabulary terms
Definition: ParamTypes.hpp:250