ProteoWizard
Macros | Functions | Variables
ReferencesTest.cpp File Reference
#include "References.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/minimxml/XMLWriter.hpp"
#include "TextWriter.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Macros

#define PWIZ_SOURCE
 

Functions

IdentData createMzid ()
 
void testContactRole ()
 
void testAnalysisSampleCollection ()
 
void testContacts ()
 
void testDBSequence ()
 
void testMeasure ()
 
void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 

Macro Definition Documentation

◆ PWIZ_SOURCE

#define PWIZ_SOURCE

Definition at line 23 of file ReferencesTest.cpp.

Function Documentation

◆ createMzid()

IdentData createMzid ( )

Definition at line 38 of file ReferencesTest.cpp.

39{
40 IdentData mzid;
41 ContactPtr c1 = ContactPtr(new Contact("c1", "larry"));
42 PersonPtr p1 = PersonPtr(new Person("p1", "mo"));
43 PersonPtr p2 = PersonPtr(new Person("p2", "curly"));
44 OrganizationPtr o1 = OrganizationPtr(new Organization("o1", "three stooges"));
45 mzid.auditCollection.push_back(c1);
46 mzid.auditCollection.push_back(p1);
47 mzid.auditCollection.push_back(p2);
48 mzid.auditCollection.push_back(o1);
49
50 return mzid;
51}
boost::shared_ptr< Contact > ContactPtr
Definition TraData.hpp:57
Implementation of ContactType from mzIdentML.
Implementation of the MzIdentMLType from the mzIdentML schema.
std::vector< ContactPtr > auditCollection
Implementation of AbstractOrganizationType from the mzIdentML schema.
Implementation of PersonType from the mzIdentML schema.

References pwiz::identdata::IdentData::auditCollection.

◆ testContactRole()

void testContactRole ( )

Definition at line 54 of file ReferencesTest.cpp.

55{
56 IdentData mzid;
57 ContactPtr c1 = ContactPtr(new Contact("c1", "larry"));
58 PersonPtr p1 = PersonPtr(new Person("p1", "mo"));
59 PersonPtr p2 = PersonPtr(new Person("p2", "curly"));
60 OrganizationPtr o1 = OrganizationPtr(new Organization("o1", "three stooges"));
61 mzid.auditCollection.push_back(c1);
62 mzid.auditCollection.push_back(p1);
63 mzid.auditCollection.push_back(p2);
64 mzid.auditCollection.push_back(o1);
65
67
68 AnalysisSoftwarePtr software(new AnalysisSoftware);
69 software->contactRolePtr.reset(new ContactRole(MS_role_type, ContactPtr(new Person("p2"))));
70 mzid.analysisSoftwareList.push_back(software);
71
72 SamplePtr sample(new Sample);
73 sample->contactRole.push_back(ContactRolePtr(new ContactRole(MS_role_type, ContactPtr(new Person("p1")))));
74 sample->contactRole.push_back(ContactRolePtr(new ContactRole(MS_role_type, ContactPtr(new Organization("o1")))));
75 mzid.analysisSampleCollection.samples.push_back(sample);
76
78
79 unit_assert(mzid.provider.contactRolePtr->contactPtr->name == "larry");
80 unit_assert(software->contactRolePtr->contactPtr->name == "curly");
81 unit_assert(sample->contactRole.front()->contactPtr->name == "mo");
82 unit_assert(dynamic_cast<Person*>(sample->contactRole.front()->contactPtr.get()));
83 unit_assert(sample->contactRole.back()->contactPtr->name == "three stooges");
84 unit_assert(dynamic_cast<Organization*>(sample->contactRole.back()->contactPtr.get()));
85}
MS_role_type
role type: Role of a Person or Organization.
Definition cv.hpp:4218
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
boost::shared_ptr< Sample > SamplePtr
Definition MSData.hpp:118
Implementation of AnalysisSoftwareType from the mzIdentML schema.
Implementation of ContactRoleType from the mzIdentML schema.
std::vector< AnalysisSoftwarePtr > analysisSoftwareList
AnalysisSampleCollection analysisSampleCollection
ContactRolePtr contactRolePtr
Implementation of the SampleType from the mzIdentML schema.
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::identdata::IdentData::analysisSampleCollection, pwiz::identdata::IdentData::analysisSoftwareList, pwiz::identdata::IdentData::auditCollection, pwiz::identdata::Provider::contactRolePtr, MS_role_type, pwiz::identdata::IdentData::provider, pwiz::identdata::References::resolve(), pwiz::identdata::AnalysisSampleCollection::samples, and unit_assert.

Referenced by test().

◆ testAnalysisSampleCollection()

void testAnalysisSampleCollection ( )

Definition at line 88 of file ReferencesTest.cpp.

89{
90 IdentData mzid;
91
92 SamplePtr sample(new Sample("s1", "Sample No. 1"));
93 sample->subSamples.push_back(SamplePtr(new Sample("s2")));
94
95 mzid.analysisSampleCollection.samples.push_back(sample);
96
97 unit_assert(mzid.analysisSampleCollection.samples.at(0)->id == "s1");
98 unit_assert(mzid.analysisSampleCollection.samples.at(0)->subSamples.at(0)->name.empty());
99
100 sample = SamplePtr(new Sample("s2", "Sample No. 2"));
101 sample->subSamples.push_back(SamplePtr(new Sample("s1")));
102
103 mzid.analysisSampleCollection.samples.push_back(sample);
104
106
108 unit_assert(mzid.analysisSampleCollection.samples.at(0)->id == "s1");
109 unit_assert(mzid.analysisSampleCollection.samples.at(1)->id == "s2");
110 unit_assert(mzid.analysisSampleCollection.samples.at(0)->subSamples.at(0)->name == "Sample No. 2");
111 unit_assert(mzid.analysisSampleCollection.samples.at(1)->subSamples.at(0)->name == "Sample No. 1");
112}

References pwiz::identdata::IdentData::analysisSampleCollection, pwiz::identdata::References::resolve(), pwiz::identdata::AnalysisSampleCollection::samples, and unit_assert.

Referenced by test().

◆ testContacts()

void testContacts ( )

Definition at line 114 of file ReferencesTest.cpp.

115{
116 ContactPtr cont(new Contact("c1", "contact1"));
117
118 PersonPtr peep1(new Person("p1", "person1"));
119 peep1->affiliations.push_back(OrganizationPtr(new Organization("o1")));
120 PersonPtr peep2(new Person("p2", "person2"));
121 peep2->affiliations.push_back(OrganizationPtr(new Organization("o2")));
122 peep2->affiliations.push_back(OrganizationPtr(new Organization("O")));
123
124 OrganizationPtr mail_organ(new Organization("o1", "organ1"));
125 OrganizationPtr feemail_organ(new Organization("o2", "organ2"));
126 OrganizationPtr big_Organ(new Organization("O", "Organ"));
127 big_Organ->parent = OrganizationPtr(new Organization("o1"));
128
129 IdentData mzid;
130
131 mzid.auditCollection.push_back(cont);
132 mzid.auditCollection.push_back(peep1);
133 mzid.auditCollection.push_back(peep2);
134 mzid.auditCollection.push_back(mail_organ);
135 mzid.auditCollection.push_back(feemail_organ);
136 mzid.auditCollection.push_back(big_Organ);
137
139
140 Person* tp = (Person*)mzid.auditCollection.at(1).get();
141 unit_assert(tp->affiliations.at(0) == mail_organ);
142 tp = (Person*)mzid.auditCollection.at(2).get();
143 unit_assert(tp->affiliations.at(0) == feemail_organ);
144 unit_assert(tp->affiliations.at(1) == big_Organ);
145
146 Organization* to = (Organization*)mzid.auditCollection.at(5).get();
147 unit_assert(to->parent == mail_organ);
148}
boost::shared_ptr< Organization > parent
std::vector< OrganizationPtr > affiliations

References pwiz::identdata::Person::affiliations, pwiz::identdata::IdentData::auditCollection, pwiz::identdata::Organization::parent, pwiz::identdata::References::resolve(), and unit_assert.

Referenced by test().

◆ testDBSequence()

void testDBSequence ( )

Definition at line 151 of file ReferencesTest.cpp.

152{
153 IdentData mzid;
154
155 SearchDatabasePtr sd(new SearchDatabase("sd1", "searching"));
156 mzid.dataCollection.inputs.searchDatabase.push_back(sd);
157
158 sd = SearchDatabasePtr(new SearchDatabase("sd2", "everywhere"));
159 mzid.dataCollection.inputs.searchDatabase.push_back(sd);
160
161 sd = SearchDatabasePtr(new SearchDatabase("sd3", "for"));
162 mzid.dataCollection.inputs.searchDatabase.push_back(sd);
163
164 sd = SearchDatabasePtr(new SearchDatabase("sd4", "SearchDatabase"));
165 mzid.dataCollection.inputs.searchDatabase.push_back(sd);
166
167 DBSequencePtr dbs(new DBSequence("dbs1", "db pointers"));
168 dbs->searchDatabasePtr = SearchDatabasePtr(new SearchDatabase("sd2"));
169 mzid.sequenceCollection.dbSequences.push_back(dbs);
170
171 dbs = DBSequencePtr(new DBSequence("dbs2", "closing sequence"));
172 dbs->searchDatabasePtr = SearchDatabasePtr(new SearchDatabase("sd3"));
173 mzid.sequenceCollection.dbSequences.push_back(dbs);
174
176
177 DBSequencePtr& dps1 = mzid.sequenceCollection.dbSequences.at(0);
178 unit_assert(dps1->searchDatabasePtr->name == "everywhere");
179
180 dps1 = mzid.sequenceCollection.dbSequences.at(1);
181 unit_assert(dps1->searchDatabasePtr->name == "for");
182}
Implementation of DBSequenceType from the mzIdentML schema.
SequenceCollection sequenceCollection
DataCollection dataCollection
std::vector< SearchDatabasePtr > searchDatabase
Implementation of SearchDatabaseType from the mzIdentML schema.
std::vector< DBSequencePtr > dbSequences

References pwiz::identdata::IdentData::dataCollection, pwiz::identdata::SequenceCollection::dbSequences, pwiz::identdata::DataCollection::inputs, pwiz::identdata::References::resolve(), pwiz::identdata::Inputs::searchDatabase, pwiz::identdata::IdentData::sequenceCollection, and unit_assert.

Referenced by test().

◆ testMeasure()

void testMeasure ( )

Definition at line 185 of file ReferencesTest.cpp.

186{
187 IdentData mzid;
188 SpectrumIdentificationListPtr sil(new SpectrumIdentificationList);
189 SpectrumIdentificationResultPtr sir(new SpectrumIdentificationResult("SIR_1"));
190 SpectrumIdentificationItemPtr sii(new SpectrumIdentificationItem("SII_1"));
191
193 sil->spectrumIdentificationResult.push_back(sir);
194 sir->spectrumIdentificationItem.push_back(sii);
195
196 MeasurePtr measureMz(new Measure("M_MZ", "m/z measure"));
197 sil->fragmentationTable.push_back(measureMz);
198
199 IonTypePtr it(new IonType);
200 sii->fragmentation.push_back(it);
201
202 FragmentArrayPtr fa(new FragmentArray);
203 fa->measurePtr.reset(new Measure("M_MZ"));
204 it->fragmentArray.push_back(fa);
205
207
208 unit_assert_operator_equal("m/z measure", it->fragmentArray.back()->measurePtr->name);
209}
std::vector< SpectrumIdentificationListPtr > spectrumIdentificationList
Implementation of FragmentArrayType from the mzIdentML schema.
Implementation of IonTypeType from the mzIdentML schema.
Implementation of MeasureType from the mzIdentML schema.
Implementation of SpectrumIdentificationItemType from the mzIdentML schema.
Implementation of SpectrumIdentificationListType from the mzIdentML schema.
Implementation of SpectrumIdentificationResultType from the mzIdentML schema.
#define unit_assert_operator_equal(expected, actual)
Definition unit.hpp:92

References pwiz::identdata::DataCollection::analysisData, pwiz::identdata::IdentData::dataCollection, pwiz::identdata::References::resolve(), pwiz::identdata::AnalysisData::spectrumIdentificationList, and unit_assert_operator_equal.

Referenced by test().

◆ test()

void test ( )

Definition at line 212 of file ReferencesTest.cpp.

213{
215 testContacts();
218 testMeasure();
219}
void testContactRole()
void testDBSequence()
void testContacts()
void testAnalysisSampleCollection()
void testMeasure()

References testAnalysisSampleCollection(), testContactRole(), testContacts(), testDBSequence(), and testMeasure().

Referenced by main().

◆ main()

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

Definition at line 221 of file ReferencesTest.cpp.

222{
223 TEST_PROLOG_EX(argc, argv, "_IdentData")
224
225 try
226 {
227 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
228 test();
229 }
230 catch (exception& e)
231 {
232 TEST_FAILED(e.what())
233 }
234 catch (...)
235 {
236 TEST_FAILED("Caught unknown exception.")
237 }
238
240}
ostream * os_
void test()
#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 36 of file ReferencesTest.cpp.

Referenced by main().