ProteoWizard
Serializer_protXML_Test.cpp
Go to the documentation of this file.
1 // TODO this is just a copy of the pepXML work, not yet populated for protXML
2 //
3 // $Id$
4 //
5 // Original author: Brian Pratt <brian.pratt .@. insilicos.com>
6 // after Serializer_pepXML_Test by Matt Chambers <matt.chambers .@. vanderbilt.edu>
7 //
8 // Copyright 2012 Spielberg Family Center for Applied Proteomics
9 // University of Southern California, Los Angeles, California 90033
10 //
11 //
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // you may not use this file except in compliance with the License.
14 // You may obtain a copy of the License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the License is distributed on an "AS IS" BASIS,
20 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 // See the License for the specific language governing permissions and
22 // limitations under the License.
23 //
28 #include "Serializer_protXML.hpp"
29 #include "Diff.hpp"
30 #include "References.hpp"
31 #include "examples.hpp"
36 #include "TextWriter.hpp"
37 #include "boost/range/adaptor/transformed.hpp"
38 #include "boost/range/algorithm/max_element.hpp"
39 #include "boost/range/algorithm/min_element.hpp"
40 #include <cstring>
41 
42 
43 using namespace pwiz::identdata;
44 using namespace pwiz::identdata::examples;
45 using namespace pwiz::util;
46 namespace proteome = pwiz::proteome;
47 
48 ostream* os_ = 0;
49 
50 void testSerialize(const string &example_data_dir)
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 }
93 
94 
95 int main(int argc, char** argv)
96 {
97  TEST_PROLOG(argc, argv)
98 
99  try
100  {
101  if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
102 
103  std::string srcparent(__FILE__);
104  size_t pos = srcparent.find((bfs::path("pwiz") / "data").string());
105  srcparent.resize(pos);
106  string example_data_dir = srcparent + "example_data";
107  testSerialize(example_data_dir);
108  }
109  catch (exception& e)
110  {
111  TEST_FAILED(e.what())
112  }
113  catch (...)
114  {
115  TEST_FAILED("Caught unknown exception.")
116  }
117 
119 }
main
int main(int argc, char **argv)
Definition: Serializer_protXML_Test.cpp:95
pwiz::identdata::DiffConfig
Definition: Diff.hpp:396
TextWriter.hpp
pwiz::identdata::Reader::Config
HACK: provide an option to read only file-level metadata; once we have an enumerable ResultList imple...
Definition: Reader.hpp:47
pwiz::proteome
Definition: AminoAcid.hpp:35
DefaultReaderList.hpp
pwiz::identdata
Definition: DefaultReaderList.hpp:33
testSerialize
void testSerialize(const string &example_data_dir)
Definition: Serializer_protXML_Test.cpp:50
pwiz::data::BaseDiffConfig::ignoreVersions
bool ignoreVersions
Definition: diff_std.hpp:46
pwiz::identdata::examples
Definition: examples.hpp:31
pwiz::data::Diff
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition: diff_std.hpp:143
pwiz::util
Definition: almost_equal.hpp:33
TEST_EPILOG
#define TEST_EPILOG
Definition: unit.hpp:183
os_
ostream * os_
Definition: Serializer_protXML_Test.cpp:48
examples.hpp
Std.hpp
Filesystem.hpp
IdentDataFile.hpp
pwiz::identdata::IdentData
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:994
TEST_FAILED
#define TEST_FAILED(x)
Definition: unit.hpp:177
TEST_PROLOG
#define TEST_PROLOG(argc, argv)
Definition: unit.hpp:175
References.hpp
pwiz::identdata::ReaderList::read
virtual void read(const std::string &filename, IdentData &result, const Config &config=Config()) const
delegates to first child that identifies
pwiz::identdata::DefaultReaderList
default Reader list
Definition: DefaultReaderList.hpp:38
Diff.hpp
unit.hpp
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
Digestion.hpp
Serializer_protXML.hpp