ProteoWizard
ChromatogramList_LockmassRefinerTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Matt Chambers <matt.chambers <a.t> vanderbilt.edu>
6//
7// Copyright 2015 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
29#include "boost/foreach_field.hpp"
30#include "boost/core/null_deleter.hpp"
31
32using namespace pwiz::util;
33using namespace pwiz::cv;
34using namespace pwiz::msdata;
35using namespace pwiz::analysis;
36
37ostream* os_ = 0;
38
39
40void test(const string& filepath, double lockmassMz, double lockmassTolerance)
41{
42 ExtendedReaderList readerList;
43 MSDataFile msd(filepath, &readerList);
44
45 bfs::path targetResultFilename = bfs::path(__FILE__).parent_path() / "ChromatogramList_LockmassRefinerTest.data" / (msd.run.id + ".mzML");
46 if (!bfs::exists(targetResultFilename))
47 throw runtime_error("test result file does not exist: " + targetResultFilename.string());
48 MSDataFile targetResult(targetResultFilename.string());
49
50 ChromatogramList_LockmassRefiner lmr(msd.run.chromatogramListPtr, lockmassMz, lockmassMz, lockmassTolerance);
51 ChromatogramListPtr sl(&lmr, boost::null_deleter());
52 msd.run.chromatogramListPtr = sl;
53
54 DiffConfig config;
55 config.ignoreMetadata = true;
56
57 Diff<MSData, DiffConfig> diff(msd, targetResult, config);
58
59 if (lockmassMz == 0)
60 {
62 }
63 else
64 {
65 if (os_ && diff) *os_ << diff;
67 }
68}
69
70
71void parseArgs(const vector<string>& args, vector<string>& rawpaths)
72{
73 for (size_t i = 1; i < args.size(); ++i)
74 {
75 if (args[i] == "-v") os_ = &cout;
76 else if (bal::starts_with(args[i], "--")) continue;
77 else rawpaths.push_back(args[i]);
78 }
79}
80
81
82int main(int argc, char* argv[])
83{
84 TEST_PROLOG(argc, argv)
85
86 try
87 {
88 vector<string> args(argv, argv+argc);
89 vector<string> rawpaths;
90 parseArgs(args, rawpaths);
91
92 for(const string& filepath : rawpaths)
93 {
94 if (bal::ends_with(filepath, "091204_NFDM_008.raw"))
95 {
96 test(filepath, 615.38, 0.1);
97 test(filepath, 0, 0.1);
98 }
99 }
100 }
101 catch (exception& e)
102 {
103 TEST_FAILED(e.what())
104 }
105 catch (...)
106 {
107 TEST_FAILED("Caught unknown exception.")
108 }
109
111}
int main(int argc, char *argv[])
void parseArgs(const vector< string > &args, vector< string > &rawpaths)
void diff(const string &filename1, const string &filename2)
ChromatogramList implementation to replace peak profiles with picked peaks.
default ReaderList, extended to include vendor readers
boost::shared_ptr< ChromatogramList > ChromatogramListPtr
Definition MSData.hpp:785
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition diff_std.hpp:143
configuration struct for diffing MSData types
Definition Diff.hpp:206
bool ignoreMetadata
ignore all file level metadata, and most scan level metadata, i.e.
Definition Diff.hpp:214
MSData object plus file I/O.
Run run
a run in mzML should correspond to a single, consecutive and coherent set of scans on an instrument.
Definition MSData.hpp:886
std::string id
a unique identifier for this run.
Definition MSData.hpp:812
ChromatogramListPtr chromatogramListPtr
all chromatograms for this run.
Definition MSData.hpp:830
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175