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.

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

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 }
Implementation of ContactType from mzIdentML.
Definition: IdentData.hpp:117
Implementation of PersonType from the mzIdentML schema.
Definition: IdentData.hpp:152
boost::shared_ptr< Contact > ContactPtr
Definition: TraData.hpp:57
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
Implementation of AbstractOrganizationType from the mzIdentML schema.
Definition: IdentData.hpp:135
std::vector< ContactPtr > auditCollection
Definition: IdentData.hpp:1010

§ testContactRole()

void testContactRole ( )

Definition at line 54 of file ReferencesTest.cpp.

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().

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 
77  References::resolve(mzid);
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 }
Implementation of ContactType from mzIdentML.
Definition: IdentData.hpp:117
Implementation of PersonType from the mzIdentML schema.
Definition: IdentData.hpp:152
AnalysisSampleCollection analysisSampleCollection
Definition: IdentData.hpp:1012
boost::shared_ptr< Contact > ContactPtr
Definition: TraData.hpp:57
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
Implementation of the SampleType from the mzIdentML schema.
Definition: IdentData.hpp:195
Implementation of AbstractOrganizationType from the mzIdentML schema.
Definition: IdentData.hpp:135
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
std::vector< ContactPtr > auditCollection
Definition: IdentData.hpp:1010
MS_role_type
role type: Role of a Person or Organization.
Definition: cv.hpp:4066
ContactRolePtr contactRolePtr
Definition: IdentData.hpp:239
Implementation of AnalysisSoftwareType from the mzIdentML schema.
Definition: IdentData.hpp:211
std::vector< AnalysisSoftwarePtr > analysisSoftwareList
Definition: IdentData.hpp:1006
boost::shared_ptr< Sample > SamplePtr
Definition: MSData.hpp:117
Implementation of ContactRoleType from the mzIdentML schema.
Definition: IdentData.hpp:175
#define unit_assert(x)
Definition: unit.hpp:85

§ testAnalysisSampleCollection()

void testAnalysisSampleCollection ( )

Definition at line 88 of file ReferencesTest.cpp.

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

Referenced by test().

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 
105  References::resolve(mzid);
106 
107  unit_assert(mzid.analysisSampleCollection.samples.size() == 2);
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 }
AnalysisSampleCollection analysisSampleCollection
Definition: IdentData.hpp:1012
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
Implementation of the SampleType from the mzIdentML schema.
Definition: IdentData.hpp:195
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
boost::shared_ptr< Sample > SamplePtr
Definition: MSData.hpp:117
#define unit_assert(x)
Definition: unit.hpp:85

§ testContacts()

void testContacts ( )

Definition at line 114 of file ReferencesTest.cpp.

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

Referenced by test().

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 
138  References::resolve(mzid);
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 }
std::vector< OrganizationPtr > affiliations
Definition: IdentData.hpp:161
Implementation of ContactType from mzIdentML.
Definition: IdentData.hpp:117
Implementation of PersonType from the mzIdentML schema.
Definition: IdentData.hpp:152
boost::shared_ptr< Contact > ContactPtr
Definition: TraData.hpp:57
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
Implementation of AbstractOrganizationType from the mzIdentML schema.
Definition: IdentData.hpp:135
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
std::vector< ContactPtr > auditCollection
Definition: IdentData.hpp:1010
#define unit_assert(x)
Definition: unit.hpp:85

§ testDBSequence()

void testDBSequence ( )

Definition at line 151 of file ReferencesTest.cpp.

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().

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 
175  References::resolve(mzid);
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 }
DataCollection dataCollection
Definition: IdentData.hpp:1020
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
std::vector< DBSequencePtr > dbSequences
Definition: IdentData.hpp:654
SequenceCollection sequenceCollection
Definition: IdentData.hpp:1014
Implementation of SearchDatabaseType from the mzIdentML schema.
Definition: IdentData.hpp:270
std::vector< SearchDatabasePtr > searchDatabase
Definition: IdentData.hpp:947
Implementation of DBSequenceType from the mzIdentML schema.
Definition: IdentData.hpp:296
#define unit_assert(x)
Definition: unit.hpp:85

§ testMeasure()

void testMeasure ( )

Definition at line 185 of file ReferencesTest.cpp.

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().

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 
206  References::resolve(mzid);
207 
208  unit_assert_operator_equal("m/z measure", it->fragmentArray.back()->measurePtr->name);
209 }
Implementation of MeasureType from the mzIdentML schema.
Definition: IdentData.hpp:573
std::vector< SpectrumIdentificationListPtr > spectrumIdentificationList
Definition: IdentData.hpp:962
Implementation of SpectrumIdentificationResultType from the mzIdentML schema.
Definition: IdentData.hpp:722
DataCollection dataCollection
Definition: IdentData.hpp:1020
#define unit_assert_operator_equal(expected, actual)
Definition: unit.hpp:92
Implementation of the MzIdentMLType from the mzIdentML schema.
Definition: IdentData.hpp:993
Implementation of IonTypeType from the mzIdentML schema.
Definition: IdentData.hpp:607
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
Implementation of FragmentArrayType from the mzIdentML schema.
Definition: IdentData.hpp:589
Implementation of SpectrumIdentificationItemType from the mzIdentML schema.
Definition: IdentData.hpp:669
Implementation of SpectrumIdentificationListType from the mzIdentML schema.
Definition: IdentData.hpp:743

§ test()

void test ( )

Definition at line 212 of file ReferencesTest.cpp.

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

Referenced by main().

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

§ main()

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

Definition at line 221 of file ReferencesTest.cpp.

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

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 }
#define TEST_EPILOG
Definition: unit.hpp:182
#define TEST_PROLOG_EX(argc, argv, suffix)
Definition: unit.hpp:157
#define TEST_FAILED(x)
Definition: unit.hpp:176
void test()
ostream * os_

Variable Documentation

§ os_

ostream* os_ = 0