ProteoWizard
ReferencesTest.cpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Robert Burke <robert.burke@proteowizard.org>
6//
7// Copyright 2009 Spielberg Family Center for Applied Proteomics
8// University of Southern California, Los Angeles, California 90033
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23#define PWIZ_SOURCE
24
25#include "References.hpp"
28#include "TextWriter.hpp"
30
31using namespace pwiz::util;
32using namespace pwiz::cv;
33using namespace pwiz::identdata;
34
35
36ostream* os_ = 0;
37
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}
52
53
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
66 mzid.provider.contactRolePtr.reset(new ContactRole(MS_role_type, ContactPtr(new Contact("c1"))));
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}
86
87
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}
113
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}
149
150
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}
183
184
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}
210
211
220
221int main(int argc, char* argv[])
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}
241
MS_role_type
role type: Role of a Person or Organization.
Definition cv.hpp:4218
void testContactRole()
int main(int argc, char *argv[])
IdentData createMzid()
void testDBSequence()
void testContacts()
ostream * os_
void test()
void testAnalysisSampleCollection()
void testMeasure()
PWIZ_API_DECL void resolve(ContactRole &cr, IdentData &mzid)
std::vector< SpectrumIdentificationListPtr > spectrumIdentificationList
Implementation of AnalysisSoftwareType from the mzIdentML schema.
Implementation of ContactType from mzIdentML.
Implementation of ContactRoleType from the mzIdentML schema.
Implementation of DBSequenceType from the mzIdentML schema.
Implementation of FragmentArrayType from the mzIdentML schema.
Implementation of the MzIdentMLType from the mzIdentML schema.
SequenceCollection sequenceCollection
DataCollection dataCollection
std::vector< AnalysisSoftwarePtr > analysisSoftwareList
std::vector< ContactPtr > auditCollection
AnalysisSampleCollection analysisSampleCollection
std::vector< SearchDatabasePtr > searchDatabase
Implementation of IonTypeType from the mzIdentML schema.
Implementation of MeasureType from the mzIdentML schema.
Implementation of AbstractOrganizationType from the mzIdentML schema.
boost::shared_ptr< Organization > parent
Implementation of PersonType from the mzIdentML schema.
std::vector< OrganizationPtr > affiliations
ContactRolePtr contactRolePtr
Implementation of the SampleType from the mzIdentML schema.
Implementation of SearchDatabaseType from the mzIdentML schema.
std::vector< DBSequencePtr > dbSequences
Implementation of SpectrumIdentificationItemType from the mzIdentML schema.
Implementation of SpectrumIdentificationListType from the mzIdentML schema.
Implementation of SpectrumIdentificationResultType from the mzIdentML schema.
#define unit_assert(x)
Definition unit.hpp:85
#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
#define unit_assert_operator_equal(expected, actual)
Definition unit.hpp:92