ProteoWizard
Functions | Variables
obotest.cpp File Reference
#include "obo.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include <boost/filesystem/operations.hpp>
#include "pwiz/utility/misc/Std.hpp"
#include <cstring>

Go to the source code of this file.

Functions

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

Variables

ostream * os_ = 0
const char * oboText_ = "\n"

Function Documentation

void test ( )

Definition at line 133 of file obotest.cpp.

References pwiz::data::OBO::filename, pwiz::data::OBO::header, oboText_, os_, pwiz::data::OBO::prefix, pwiz::data::OBO::terms, and unit_assert.

{
const string& filename = "obotest_temp.txt";
ofstream temp(filename.c_str());
temp << oboText_ << endl;
temp.close();
OBO obo(filename);
if (os_) *os_ << obo << endl;
unit_assert(obo.filename == filename);
unit_assert(obo.header.size() == 5);
unit_assert(obo.prefix == "MS");
unit_assert(obo.terms.size() == 12); // including obsolete terms
set<Term>::const_iterator term = obo.terms.begin();
unit_assert(term->prefix == "MS");
unit_assert(term->id == 0);
unit_assert(term->name == "MZ controlled vocabularies");
unit_assert(term->def == "MZ controlled vocabularies.");
unit_assert(term->parentsPartOf.empty());
unit_assert(term->parentsIsA.empty());
++term;
unit_assert(term->id == 1);
unit_assert(term->name == "sample number");
unit_assert(term->parentsPartOf.size() == 1);
unit_assert(term->parentsPartOf[0] == 1000548);
++term;
unit_assert(term->id == 11);
unit_assert(term->name == "mass resolution");
unit_assert(term->parentsIsA.size() == 1);
unit_assert(term->parentsIsA[0] == 1000503);
++term;
unit_assert(term->id == 1000025);
unit_assert(term->exactSynonyms.size() == 1);
unit_assert(term->exactSynonyms[0] == "B");
++term;
unit_assert(term->id == 1000030);
unit_assert(term->isObsolete);
++term;
unit_assert(term->id == 1000035);
unit_assert(term->isObsolete);
// test unescaping "\!"
++term;
unit_assert(term->id == 1001272);
unit_assert(term->name == "(?<=R)(?!P)");
// test other relationships
++term;
unit_assert(term->id == 1001280);
unit_assert(term->relations.size() == 2);
unit_assert(term->relations.begin()->first == "has_units");
unit_assert(term->relations.begin()->second.first == "MS");
unit_assert(term->relations.begin()->second.second == 1000040);
unit_assert(term->relations.rbegin()->second.first == "UO");
unit_assert(term->relations.rbegin()->second.second == 169);
++term;
unit_assert(term->id == 1001303);
unit_assert(term->name == "Arg-C");
unit_assert(term->relations.size() == 1);
unit_assert(term->relations.begin()->first == "has_regexp");
unit_assert(term->relations.begin()->second.first == "MS");
unit_assert(term->relations.begin()->second.second == 1001272);
// test term with OBO 1.2 synonym format
++term;
unit_assert(term->id == 2000025);
unit_assert(term->exactSynonyms.size() == 1);
unit_assert(term->exactSynonyms[0] == "B");
// test term with [stuff to ignore]
++term;
unit_assert(term->id == 9999999);
unit_assert(term->def == "description");
++term;
// test property values
unit_assert(term->id == 99999999);
unit_assert(term->name == "Label:2H(4)+GlyGly");
unit_assert(term->def == "Ubiquitination 2H4 lysine");
unit_assert(term->propertyValues.size() == 9);
unit_assert(term->propertyValues.find("record_id")->second == "853");
unit_assert(term->propertyValues.find("delta_mono_mass")->second == "118.068034");
unit_assert(term->propertyValues.find("delta_avge_mass")->second == "118.1273");
unit_assert(term->propertyValues.find("delta_composition")->second == "H(2) 2H(4) C(4) N(2) O(2)");
unit_assert(term->propertyValues.find("spec_classification_1")->second == "Post-translational");
boost::filesystem::remove(filename);
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 232 of file obotest.cpp.

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

{
TEST_PROLOG(argc, argv)
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 35 of file obotest.cpp.

const char* oboText_ = "\n"

Definition at line 38 of file obotest.cpp.

Referenced by test().