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

#define PWIZ_SOURCE

Definition at line 23 of file ReferencesTest.cpp.


Function Documentation

IdentData createMzid ( )

Definition at line 38 of file ReferencesTest.cpp.

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

{
IdentData mzid;
ContactPtr c1 = ContactPtr(new Contact("c1", "larry"));
PersonPtr p1 = PersonPtr(new Person("p1", "mo"));
PersonPtr p2 = PersonPtr(new Person("p2", "curly"));
OrganizationPtr o1 = OrganizationPtr(new Organization("o1", "three stooges"));
mzid.auditCollection.push_back(c1);
mzid.auditCollection.push_back(p1);
mzid.auditCollection.push_back(p2);
mzid.auditCollection.push_back(o1);
return mzid;
}
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.

{
IdentData mzid;
ContactPtr c1 = ContactPtr(new Contact("c1", "larry"));
PersonPtr p1 = PersonPtr(new Person("p1", "mo"));
PersonPtr p2 = PersonPtr(new Person("p2", "curly"));
OrganizationPtr o1 = OrganizationPtr(new Organization("o1", "three stooges"));
mzid.auditCollection.push_back(c1);
mzid.auditCollection.push_back(p1);
mzid.auditCollection.push_back(p2);
mzid.auditCollection.push_back(o1);
AnalysisSoftwarePtr software(new AnalysisSoftware);
software->contactRolePtr.reset(new ContactRole(MS_role_type, ContactPtr(new Person("p2"))));
mzid.analysisSoftwareList.push_back(software);
SamplePtr sample(new Sample);
sample->contactRole.push_back(ContactRolePtr(new ContactRole(MS_role_type, ContactPtr(new Person("p1")))));
sample->contactRole.push_back(ContactRolePtr(new ContactRole(MS_role_type, ContactPtr(new Organization("o1")))));
mzid.analysisSampleCollection.samples.push_back(sample);
unit_assert(mzid.provider.contactRolePtr->contactPtr->name == "larry");
unit_assert(software->contactRolePtr->contactPtr->name == "curly");
unit_assert(sample->contactRole.front()->contactPtr->name == "mo");
unit_assert(dynamic_cast<Person*>(sample->contactRole.front()->contactPtr.get()));
unit_assert(sample->contactRole.back()->contactPtr->name == "three stooges");
unit_assert(dynamic_cast<Organization*>(sample->contactRole.back()->contactPtr.get()));
}
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.

{
IdentData mzid;
SamplePtr sample(new Sample("s1", "Sample No. 1"));
sample->subSamples.push_back(SamplePtr(new Sample("s2")));
mzid.analysisSampleCollection.samples.push_back(sample);
unit_assert(mzid.analysisSampleCollection.samples.at(0)->id == "s1");
unit_assert(mzid.analysisSampleCollection.samples.at(0)->subSamples.at(0)->name.empty());
sample = SamplePtr(new Sample("s2", "Sample No. 2"));
sample->subSamples.push_back(SamplePtr(new Sample("s1")));
mzid.analysisSampleCollection.samples.push_back(sample);
unit_assert(mzid.analysisSampleCollection.samples.at(0)->id == "s1");
unit_assert(mzid.analysisSampleCollection.samples.at(1)->id == "s2");
unit_assert(mzid.analysisSampleCollection.samples.at(0)->subSamples.at(0)->name == "Sample No. 2");
unit_assert(mzid.analysisSampleCollection.samples.at(1)->subSamples.at(0)->name == "Sample No. 1");
}
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().

{
ContactPtr cont(new Contact("c1", "contact1"));
PersonPtr peep1(new Person("p1", "person1"));
peep1->affiliations.push_back(OrganizationPtr(new Organization("o1")));
PersonPtr peep2(new Person("p2", "person2"));
peep2->affiliations.push_back(OrganizationPtr(new Organization("o2")));
peep2->affiliations.push_back(OrganizationPtr(new Organization("O")));
OrganizationPtr mail_organ(new Organization("o1", "organ1"));
OrganizationPtr feemail_organ(new Organization("o2", "organ2"));
OrganizationPtr big_Organ(new Organization("O", "Organ"));
big_Organ->parent = OrganizationPtr(new Organization("o1"));
IdentData mzid;
mzid.auditCollection.push_back(cont);
mzid.auditCollection.push_back(peep1);
mzid.auditCollection.push_back(peep2);
mzid.auditCollection.push_back(mail_organ);
mzid.auditCollection.push_back(feemail_organ);
mzid.auditCollection.push_back(big_Organ);
Person* tp = (Person*)mzid.auditCollection.at(1).get();
unit_assert(tp->affiliations.at(0) == mail_organ);
tp = (Person*)mzid.auditCollection.at(2).get();
unit_assert(tp->affiliations.at(0) == feemail_organ);
unit_assert(tp->affiliations.at(1) == big_Organ);
Organization* to = (Organization*)mzid.auditCollection.at(5).get();
unit_assert(to->parent == mail_organ);
}
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.

{
IdentData mzid;
SearchDatabasePtr sd(new SearchDatabase("sd1", "searching"));
mzid.dataCollection.inputs.searchDatabase.push_back(sd);
sd = SearchDatabasePtr(new SearchDatabase("sd2", "everywhere"));
mzid.dataCollection.inputs.searchDatabase.push_back(sd);
sd = SearchDatabasePtr(new SearchDatabase("sd3", "for"));
mzid.dataCollection.inputs.searchDatabase.push_back(sd);
sd = SearchDatabasePtr(new SearchDatabase("sd4", "SearchDatabase"));
mzid.dataCollection.inputs.searchDatabase.push_back(sd);
DBSequencePtr dbs(new DBSequence("dbs1", "db pointers"));
dbs->searchDatabasePtr = SearchDatabasePtr(new SearchDatabase("sd2"));
mzid.sequenceCollection.dbSequences.push_back(dbs);
dbs = DBSequencePtr(new DBSequence("dbs2", "closing sequence"));
dbs->searchDatabasePtr = SearchDatabasePtr(new SearchDatabase("sd3"));
mzid.sequenceCollection.dbSequences.push_back(dbs);
DBSequencePtr& dps1 = mzid.sequenceCollection.dbSequences.at(0);
unit_assert(dps1->searchDatabasePtr->name == "everywhere");
dps1 = mzid.sequenceCollection.dbSequences.at(1);
unit_assert(dps1->searchDatabasePtr->name == "for");
}
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.

{
IdentData mzid;
SpectrumIdentificationListPtr sil(new SpectrumIdentificationList);
SpectrumIdentificationResultPtr sir(new SpectrumIdentificationResult("SIR_1"));
SpectrumIdentificationItemPtr sii(new SpectrumIdentificationItem("SII_1"));
sil->spectrumIdentificationResult.push_back(sir);
sir->spectrumIdentificationItem.push_back(sii);
MeasurePtr measureMz(new Measure("M_MZ", "m/z measure"));
sil->fragmentationTable.push_back(measureMz);
IonTypePtr it(new IonType);
sii->fragmentation.push_back(it);
FragmentArrayPtr fa(new FragmentArray);
fa->measurePtr.reset(new Measure("M_MZ"));
it->fragmentArray.push_back(fa);
unit_assert_operator_equal("m/z measure", it->fragmentArray.back()->measurePtr->name);
}
void test ( )
int main ( int  argc,
char *  argv[] 
)

Definition at line 221 of file ReferencesTest.cpp.

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

{
TEST_PROLOG_EX(argc, argv, "_IdentData")
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 36 of file ReferencesTest.cpp.