ProteoWizard
Functions | Variables
DiffTest.cpp File Reference
#include "Diff.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

void testProteinList ()
 
void testProteomeData ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Function Documentation

◆ testProteinList()

void testProteinList ( )

Definition at line 54 of file DiffTest.cpp.

55{
56 if (os_) *os_ << "testProteinList()\n";
57
58 ProteinListSimple aSimple, bSimple;
59
60 ProteinPtr protein1a = ProteinPtr(new Protein("420", 0, "", ""));
61 ProteinPtr protein1b = ProteinPtr(new Protein("420", 0, "", ""));
62
63 aSimple.proteins.push_back(protein1a);
64 bSimple.proteins.push_back(protein1b);
65
66 ProteinList& a = aSimple;
67 ProteinList& b = bSimple;
68
70
71 DiffConfig config_ignore;
72 config_ignore.ignoreMetadata = true;
73
74 Diff<ProteinList, DiffConfig, ProteinListSimple> diffIgnore(a, b, config_ignore);
76 unit_assert(!diffIgnore);
77
78 // check: different ProteinList::size()
79
80 ProteinPtr protein2 = ProteinPtr(new Protein("421", 0, "", ""));
81 aSimple.proteins.push_back(protein2);
82
83 diff(a, b);
84 if (os_) *os_ << diff << endl;
86 unit_assert(diff.a_b.proteins.size() == 1);
87
88 diffIgnore(a, b);
89 if (os_) *os_ << diffIgnore << endl;
90 unit_assert(diffIgnore);
91 unit_assert(diffIgnore.a_b.proteins.size() == 1);
92
93 // check: same ProteinList::size(), different last id
94
95 ProteinPtr protein3 = ProteinPtr(new Protein("422", 0, "", ""));
96 bSimple.proteins.push_back(protein3);
97
98 diff(a, b);
99 if (os_) *os_ << diff << endl;
101 unit_assert(diff.a_b.proteins.size() == 1);
102 unit_assert(diff.a_b.proteins[0]->id == "421");
103 unit_assert(diff.b_a.proteins.size() == 1);
104 unit_assert(diff.b_a.proteins[0]->id == "422");
105
106 // id is not ignored
107 diffIgnore(a, b);
108 unit_assert(diffIgnore);
109
110 // check: ids match, different description
111
112 bSimple.proteins.back() = ProteinPtr(new Protein("421", 0, "different metadata", ""));
113
114 diff(a, b);
115 if (os_) *os_ << diff << endl;
117 unit_assert(diff.a_b.proteins.size() == 1);
118 unit_assert(diff.a_b.proteins[0]->description == "");
119 unit_assert(diff.b_a.proteins.size() == 1);
120 unit_assert(diff.b_a.proteins[0]->description == "different metadata");
121
122
123 diffIgnore(a, b);
124 unit_assert(!diffIgnore);
125
126 // check: same metadata, different sequences
127
128 bSimple.proteins.back() = ProteinPtr(new Protein("421", 0, "", "ELVISLIVES"));
129
130 diff(a, b);
132
133 diffIgnore(a, b);
134 unit_assert(diffIgnore);
135}
void diff(const string &filename1, const string &filename2)
ostream * os_
Definition DiffTest.cpp:35
boost::shared_ptr< Protein > ProteinPtr
Calculate diffs of objects in a ProteoWizard data model hierarchy.
Definition diff_std.hpp:143
configuration struct for diffs
Definition Diff.hpp:73
std::vector< ProteinPtr > proteins
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::data::Diff< object_type, config_type, object_result_type >::a_b, diff(), pwiz::proteome::DiffConfig::ignoreMetadata, os_, pwiz::proteome::ProteinListSimple::proteins, and unit_assert.

Referenced by test().

◆ testProteomeData()

void testProteomeData ( )

Definition at line 138 of file DiffTest.cpp.

139{
140 if (os_) *os_ << "testProteomeData()\n";
141
142 ProteomeData a, b;
143
144 a.id = "goober";
145 b.id = "goober";
146
149
150 b.id = "raisinet";
151
152 shared_ptr<ProteinListSimple> proteinList1(new ProteinListSimple);
153 proteinList1->proteins.push_back(ProteinPtr(new Protein("p1", 0, "", "")));
154 b.proteinListPtr = proteinList1;
155
156 diff(a, b);
157 if (os_) *os_ << diff << endl;
159
160 unit_assert(diff.a_b.proteinListPtr.get());
161 unit_assert(diff.a_b.proteinListPtr->size() == 1);
162}

References diff(), pwiz::proteome::ProteomeData::id, os_, pwiz::proteome::ProteomeData::proteinListPtr, and unit_assert.

Referenced by test().

◆ test()

void test ( )

Definition at line 165 of file DiffTest.cpp.

166{
167 //testProtein();
170}
void testProteinList()
Definition DiffTest.cpp:54
void testProteomeData()
Definition DiffTest.cpp:138

References testProteinList(), and testProteomeData().

Referenced by main().

◆ main()

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

Definition at line 173 of file DiffTest.cpp.

174{
175 TEST_PROLOG_EX(argc, argv, "_ProteomeData")
176
177 try
178 {
179 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
180 test();
181 }
182 catch (exception& e)
183 {
184 TEST_FAILED(e.what())
185 }
186 catch (...)
187 {
188 TEST_FAILED("Caught unknown exception.")
189 }
190
192}
void test()
Definition DiffTest.cpp:165
#define TEST_PROLOG_EX(argc, argv, suffix)
Definition unit.hpp:157
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177

References os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG_EX.

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 35 of file DiffTest.cpp.

Referenced by main(), testProteinList(), and testProteomeData().