ProteoWizard
Functions | Variables
Serializer_protXML_Test.cpp File Reference
#include "pwiz/utility/misc/Std.hpp"
#include "pwiz/data/identdata/DefaultReaderList.hpp"
#include "pwiz/data/identdata/IdentDataFile.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "Serializer_protXML.hpp"
#include "Diff.hpp"
#include "References.hpp"
#include "examples.hpp"
#include "pwiz/utility/misc/Filesystem.hpp"
#include "pwiz/data/proteome/Digestion.hpp"
#include "TextWriter.hpp"
#include "boost/range/adaptor/transformed.hpp"
#include "boost/range/algorithm/max_element.hpp"
#include "boost/range/algorithm/min_element.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testSerialize (const string &example_data_dir)
 
int main (int argc, char **argv)
 

Variables

ostream * os_ = 0
 

Function Documentation

§ testSerialize()

void testSerialize ( const string &  example_data_dir)

Definition at line 50 of file Serializer_protXML_Test.cpp.

References pwiz::data::BaseDiffConfig::ignoreVersions, os_, pwiz::identdata::ReaderList::read(), and unit_assert.

Referenced by main().

51 {
52  DefaultReaderList readers;
53  Reader::Config readerConfig;
54  DiffConfig diffconfig;
55  diffconfig.ignoreVersions = true;
56 
57  {
58  // verify that loading protXML with reachable pepXML source files gives more
59  // (well, different) data than pepXML alone
60  IdentData mzid0,mzid1;
61  readers.read(example_data_dir+"/example.pep.xml", mzid0, readerConfig);
62  readers.read(example_data_dir+"/example.prot.xml", mzid1, readerConfig);
63  Diff<IdentData, DiffConfig> diff0(diffconfig);
64  diff0(mzid0, mzid1);
65  unit_assert(diff0);
66  }
67 
68  {
69  // verify that adding protxml to pepXML is equivalent to loading protXML with reachable
70  // pepXML source files
71  IdentData mzid0,mzid1;
72  readers.read(example_data_dir+"/example.pep.xml", mzid0, readerConfig);
73  readers.read(example_data_dir+"/example.prot.xml", mzid0, readerConfig);
74  readers.read(example_data_dir+"/example.prot.xml", mzid1, readerConfig);
75  Diff<IdentData, DiffConfig> diff1(diffconfig);
76  diff1(mzid0, mzid1);
77  if (os_ && diff1) *os_ << diff1 << endl;
78  unit_assert(!diff1);
79  }
80 
81  {
82  // verify that loading protXML is the same as loading a known-good mzIdentML file
83  IdentData mzid0,mzid1;
84  readers.read(example_data_dir+"/example.prot.xml", mzid0, readerConfig);
85  readers.read(example_data_dir+"/example.prot.mzid", mzid1, readerConfig);
86  Diff<IdentData, DiffConfig> diff2(diffconfig);
87  diff2(mzid0, mzid1);
88  if (os_ && diff2) *os_ << diff2 << endl;
89  else if (diff2) cout << diff2 << endl;
90  unit_assert(!diff2);
91  }
92 }
HACK: provide an option to read only file-level metadata; once we have an enumerable ResultList imple...
Definition: Reader.hpp:46
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition: diff_std.hpp:142
ostream * os_
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
virtual void read(const std::string &filename, IdentData &result, const Config &config=Config()) const
delegates to first child that identifies
#define unit_assert(x)
Definition: unit.hpp:85

§ main()

int main ( int  argc,
char **  argv 
)

Definition at line 95 of file Serializer_protXML_Test.cpp.

References os_, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, and testSerialize().

96 {
97  TEST_PROLOG(argc, argv)
98 
99  try
100  {
101  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
102  std::string srcparent(argv[0]);
103  size_t pos = srcparent.find("build");
104 
105  if (pos == std::string::npos) {
106  srcparent = __FILE__; // nonstandard build, maybe? try using source file name
107  // something like \ProteoWizard\pwiz\pwiz\data\identdata\Serializer_ProtXML_Test.cpp
108  pos = srcparent.rfind("pwiz");
109  }
110  srcparent.resize(pos);
111  string example_data_dir = srcparent + "example_data";
112  testSerialize(example_data_dir);
113  }
114  catch (exception& e)
115  {
116  TEST_FAILED(e.what())
117  }
118  catch (...)
119  {
120  TEST_FAILED("Caught unknown exception.")
121  }
122 
124 }
#define TEST_EPILOG
Definition: unit.hpp:182
ostream * os_
void testSerialize(const string &example_data_dir)
#define TEST_FAILED(x)
Definition: unit.hpp:176
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:174

Variable Documentation

§ os_

ostream* os_ = 0

Definition at line 48 of file Serializer_protXML_Test.cpp.

Referenced by main(), and testSerialize().