ProteoWizard
ChromatogramListFactoryTest.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 
27 #include <cstring>
28 
29 
30 using namespace pwiz::analysis;
31 using namespace pwiz::util;
32 using namespace pwiz::cv;
33 using namespace pwiz::msdata;
34 
35 
36 ostream* os_ = 0;
37 
38 
39 void testUsage()
40 {
41  if (os_) *os_ << "ChromatogramListFactory::usage():\n" << ChromatogramListFactory::usage() << endl;
42 }
43 
44 
45 void testWrap()
46 {
47  MSData msd;
49 
51 
52  unit_assert(sl.get());
53  unit_assert_operator_equal(2, sl->size());
54 
55  // CompassXtract and pwiz data processing
57  unit_assert_operator_equal(1, msd.allDataProcessingPtrs()[1]->processingMethods.size());
58 
59  // make sure we can handle config file lines copied from commandline
60  // with quotes intact
61  ChromatogramListFactory::wrap(msd, "'index [1,1]'");
62  unit_assert_operator_equal(1, sl->size());
63  unit_assert_operator_equal("sic", sl->chromatogramIdentity(0).id);
64 
66  unit_assert_operator_equal(1, msd.allDataProcessingPtrs()[1]->processingMethods.size());
67 }
68 
69 /*void testWrapPolarity()
70 {
71  // test filter by positive polarity
72  {
73  MSData msd;
74  examples::initializeTiny(msd);
75 
76  ChromatogramListPtr& sl = msd.run.chromatogramListPtr;
77  unit_assert(sl.get());
78  unit_assert(sl->size() == 5);
79 
80  ChromatogramListFactory::wrap(msd, "polarity positive");
81  unit_assert(sl->size() == 3);
82  }
83  // test filter by + polarity
84  {
85  MSData msd;
86  examples::initializeTiny(msd);
87 
88  ChromatogramListPtr& sl = msd.run.chromatogramListPtr;
89  unit_assert(sl.get());
90  unit_assert(sl->size() == 5);
91 
92  ChromatogramListFactory::wrap(msd, "polarity +");
93  unit_assert(sl->size() == 3);
94  }
95  // test filter by negative polarity
96  {
97  MSData msd;
98  examples::initializeTiny(msd);
99 
100  ChromatogramListPtr& sl = msd.run.chromatogramListPtr;
101  unit_assert(sl.get());
102  unit_assert(sl->size() == 5);
103 
104  ChromatogramListFactory::wrap(msd, "polarity -");
105  unit_assert(sl->size() == 2);
106  }
107  // test invalid argument
108  {
109  MSData msd;
110  examples::initializeTiny(msd);
111 
112  ChromatogramListPtr& sl = msd.run.chromatogramListPtr;
113  unit_assert(sl.get());
114  unit_assert(sl->size() == 5);
115  unit_assert_throws(ChromatogramListFactory::wrap(msd, "polarity UNEXPECTED_INPUT"), runtime_error)
116  }
117 }*/
118 
119 void test()
120 {
121  testUsage();
122  testWrap();
123  //testWrapPolarity();
124 }
125 
126 
127 int main(int argc, char* argv[])
128 {
129  TEST_PROLOG(argc, argv)
130 
131  try
132  {
133  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
134  test();
135  }
136  catch (exception& e)
137  {
138  TEST_FAILED(e.what())
139  }
140  catch (...)
141  {
142  TEST_FAILED("Caught unknown exception.")
143  }
144 
146 }
147 
os_
ostream * os_
Definition: ChromatogramListFactoryTest.cpp:36
testUsage
void testUsage()
Definition: ChromatogramListFactoryTest.cpp:39
ChromatogramListFactory.hpp
pwiz::cv
Definition: cv.hpp:108
pwiz::analysis::ChromatogramListFactory::usage
static std::string usage(bool detailedHelp=true, const char *morehelp_prompt=NULL, int maxLineLength=80)
user-friendly documentation, with option of less or more detail
main
int main(int argc, char *argv[])
Definition: ChromatogramListFactoryTest.cpp:127
pwiz::analysis
Definition: ChromatogramList_Filter.hpp:37
pwiz::msdata::MSData::run
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition: MSData.hpp:886
pwiz::msdata
Definition: DemuxTypes.hpp:27
pwiz::analysis::ChromatogramListFactory::wrap
static void wrap(msdata::MSData &msd, const std::string &wrapper, pwiz::util::IterationListenerRegistry *ilr=NULL)
instantiate the ChromatogramListWrapper indicated by wrapper
unit_assert_operator_equal
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
pwiz::msdata::ChromatogramListPtr
boost::shared_ptr< ChromatogramList > ChromatogramListPtr
Definition: MSData.hpp:785
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
testWrap
void testWrap()
Definition: ChromatogramListFactoryTest.cpp:45
Std.hpp
pwiz::identdata::examples::initializeTiny
PWIZ_API_DECL void initializeTiny(IdentData &mzid)
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
pwiz::msdata::MSData::allDataProcessingPtrs
std::vector< DataProcessingPtr > allDataProcessingPtrs() const
return dataProcessingPtrs augmented by the dataProcessingPtr() set in SpectrumList and/or Chromatogra...
pwiz::msdata::MSData
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
Definition: MSData.hpp:850
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
test
void test()
Definition: ChromatogramListFactoryTest.cpp:119
pwiz::msdata::Run::chromatogramListPtr
ChromatogramListPtr chromatogramListPtr
all chromatograms for this run.
Definition: MSData.hpp:830