ProteoWizard
Functions | Variables
SpectrumList_LockmassRefinerTest.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include "pwiz/utility/misc/almost_equal.hpp"
#include "pwiz/data/msdata/MSDataFile.hpp"
#include "pwiz/data/msdata/Diff.hpp"
#include "pwiz/data/vendor_readers/ExtendedReaderList.hpp"
#include "SpectrumList_LockmassRefiner.hpp"
#include "boost/foreach_field.hpp"
#include "boost/core/null_deleter.hpp"

Go to the source code of this file.

Functions

void test (const string &filepath, double lockmassMz, double lockmassTolerance)
 
void parseArgs (const vector< string > &args, vector< string > &rawpaths)
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ test()

void test ( const string &  filepath,
double  lockmassMz,
double  lockmassTolerance 
)

Definition at line 40 of file SpectrumList_LockmassRefinerTest.cpp.

41{
42 ExtendedReaderList readerList;
43 MSDataFile msd(filepath, &readerList);
44
45 bfs::path targetResultFilename = bfs::path(__FILE__).parent_path() / "SpectrumList_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 SpectrumList_LockmassRefiner lmr(msd.run.spectrumListPtr, lockmassMz, lockmassMz, lockmassTolerance);
51 SpectrumListPtr sl(&lmr, boost::null_deleter());
52 msd.run.spectrumListPtr = 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}
void diff(const string &filename1, const string &filename2)
SpectrumList implementation to replace peak profiles with picked peaks.
default ReaderList, extended to include vendor readers
boost::shared_ptr< SpectrumList > SpectrumListPtr
Definition MSData.hpp:711
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.
#define unit_assert(x)
Definition unit.hpp:85

References diff(), pwiz::msdata::Run::id, pwiz::msdata::DiffConfig::ignoreMetadata, os_, pwiz::msdata::MSData::run, pwiz::msdata::Run::spectrumListPtr, and unit_assert.

◆ parseArgs()

void parseArgs ( const vector< string > &  args,
vector< string > &  rawpaths 
)

Definition at line 71 of file SpectrumList_LockmassRefinerTest.cpp.

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}

References os_.

Referenced by main().

◆ main()

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

Definition at line 82 of file SpectrumList_LockmassRefinerTest.cpp.

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 int tests = 0;
93 for(const string& filepath : rawpaths)
94 {
95 if (bal::ends_with(filepath, "ATEHLSTLSEK_profile.raw"))
96 {
97 ++tests;
98 test(filepath, 684.3469, 0.1);
99 test(filepath, 0, 0.1);
100 }
101 }
102
103 if (tests == 0)
104 throw runtime_error("did not run any tests");
105 }
106 catch (exception& e)
107 {
108 TEST_FAILED(e.what())
109 }
110 catch (...)
111 {
112 TEST_FAILED("Caught unknown exception.")
113 }
114
116}
void parseArgs(const vector< string > &args, vector< string > &rawpaths)
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References parseArgs(), test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 37 of file SpectrumList_LockmassRefinerTest.cpp.

Referenced by parseArgs(), and test().