ProteoWizard
Functions | Variables
UnimodTest.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include "Unimod.hpp"
#include <cstring>

Go to the source code of this file.

Functions

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

Variables

ostream * os_ = 0

Function Documentation

void test ( )

Definition at line 39 of file UnimodTest.cpp.

References Alanine, pwiz::data::unimod::Any(), Asparagine, AsparticAcid, Cysteine, GlutamicAcid, Glutamine, Lysine, Methionine, pwiz::data::unimod::modification(), pwiz::data::unimod::modifications(), MS_ion_trap, MS_modification_specificity_C_term, MS_modification_specificity_N_term, os_, pwiz::data::unimod::position(), Proline, pwiz::data::unimod::ProteinNTerminus(), Serine, pwiz::data::unimod::site(), Threonine, Tyrosine, UNIMOD_Acetyl, UNIMOD_Gln__pyro_Glu, UNIMOD_Met__Hse, UNIMOD_Oxidation, UNIMOD_Phospho, unit_assert, unit_assert_operator_equal, and unit_assert_throws_what.

{
if (os_) *os_ << "test()\n";
unit_assert_operator_equal(Site::NTerminus, site('n'));
unit_assert_operator_equal(Site::CTerminus, site('c'));
unit_assert_throws_what(site('1'), invalid_argument, "[unimod::site] invalid symbol");
unit_assert_throws_what(site('z'), invalid_argument, "[unimod::site] invalid symbol");
unit_assert_operator_equal(Position::Anywhere, position());
unit_assert_throws_what(position(MS_ion_trap), invalid_argument, "[unimod::position] invalid cvid");
if (os_) *os_ << "Unimod entries: " << modifications().size() << endl;
unit_assert(modifications().size() > 500);
const Modification& acetyl = modification("Acetyl");
unit_assert_operator_equal("Acetyl", acetyl.name);
unit_assert(acetyl.approved);
unit_assert_operator_equal("C2H2O1", acetyl.deltaComposition.formula());
unit_assert_operator_equal(8, acetyl.specificities.size());
unit_assert_operator_equal(Site::Lysine, acetyl.specificities[0].site);
unit_assert_operator_equal(Position::Anywhere, acetyl.specificities[0].position);
unit_assert_operator_equal(false, acetyl.specificities[0].hidden);
unit_assert_operator_equal(Classification::Multiple, acetyl.specificities[0].classification);
unit_assert_operator_equal(Site::NTerminus, acetyl.specificities[1].site);
unit_assert_operator_equal(Position::AnyNTerminus, acetyl.specificities[1].position);
unit_assert_operator_equal(false, acetyl.specificities[1].hidden);
unit_assert_operator_equal(Classification::Multiple, acetyl.specificities[1].classification);
unit_assert_operator_equal(Site::Cysteine, acetyl.specificities[2].site);
unit_assert_operator_equal(Position::Anywhere, acetyl.specificities[2].position);
unit_assert_operator_equal(true, acetyl.specificities[2].hidden);
unit_assert_operator_equal(Classification::PostTranslational, acetyl.specificities[2].classification);
unit_assert_operator_equal(Site::NTerminus, acetyl.specificities[4].site);
unit_assert_operator_equal(Position::ProteinNTerminus, acetyl.specificities[4].position);
unit_assert_operator_equal(false, acetyl.specificities[4].hidden);
unit_assert_operator_equal(Classification::PostTranslational, acetyl.specificities[4].classification);
unit_assert_operator_equal(UNIMOD_Acetyl, modifications(acetyl.deltaMonoisotopicMass(), 0)[0].cvid);
unit_assert_operator_equal(UNIMOD_Acetyl, modifications(acetyl.deltaAverageMass(), 0, false)[0].cvid);
// test a position-only filter
unit_assert_operator_equal(1, modifications(acetyl.deltaMonoisotopicMass(), 0.0001,
indeterminate, indeterminate,
Site::Any, Position::AnyNTerminus).size());
unit_assert_operator_equal(UNIMOD_Acetyl, modifications(acetyl.deltaMonoisotopicMass(), 0.5,
indeterminate, indeterminate,
Site::Any, Position::AnyNTerminus)[0].cvid);
const Modification& hse = modification("Met->Hse");
unit_assert_operator_equal("Met->Hse", hse.name);
unit_assert(hse.approved);
unit_assert_operator_equal("C-1H-2O1S-1", hse.deltaComposition.formula());
unit_assert_operator_equal(Site::Methionine, hse.specificities[0].site);
unit_assert_operator_equal(Position::AnyCTerminus, hse.specificities[0].position);
unit_assert_operator_equal(false, hse.specificities[0].hidden);
unit_assert_operator_equal(Classification::ChemicalDerivative, hse.specificities[0].classification);
const Modification& oxidation = modification(UNIMOD_Oxidation);
// 3 mods have the same mass as oxidation
unit_assert_operator_equal(3, modifications(oxidation.deltaMonoisotopicMass(), 0, true, indeterminate).size());
unit_assert_operator_equal(3, modifications(oxidation.deltaAverageMass(), 0, false, indeterminate).size());
// only one of those mods happen on Methionine
unit_assert_operator_equal(1, modifications(oxidation.deltaMonoisotopicMass(), 0, true, indeterminate, Site::Methionine).size());
unit_assert_operator_equal(1, modifications(oxidation.deltaAverageMass(), 0, false, indeterminate, Site::Methionine).size());
// oxidation also happens on Proline (test multi-bit Site mask)
unit_assert_operator_equal(1, modifications(oxidation.deltaAverageMass(), 0, false, indeterminate, Site::Methionine | Site::Proline).size());
// add Alanine as a site and it could be a substitution
unit_assert_operator_equal(2, modifications(oxidation.deltaAverageMass(), 0, false, indeterminate, Site::Methionine | Site::Alanine).size());
// 18 mods are 28 +/- 1 (but 1 of them is an isotope label not yet supported)
unit_assert_operator_equal(17, modifications(28, 1, true, indeterminate).size());
// only two of those mods happen post-translationally on protein N-termini
unit_assert_operator_equal(2, modifications(28, 1, true, indeterminate, Site::Any,
Classification::PostTranslational).size());
const Modification& phospho = modification(UNIMOD_Phospho);
// phospho on S and T are grouped (property names are duplicated)
unit_assert_operator_equal(UNIMOD_Phospho, modifications(phospho.deltaMonoisotopicMass(), 0, true, true, Site::Serine)[0].cvid);
unit_assert_operator_equal(UNIMOD_Phospho, modifications(phospho.deltaMonoisotopicMass(), 0, true, true, Site::Threonine)[0].cvid);
unit_assert_operator_equal(UNIMOD_Phospho, modifications(phospho.deltaMonoisotopicMass(), 0, true, true, Site::Tyrosine)[0].cvid);
// test multi-bit Site mask
unit_assert_operator_equal(UNIMOD_Phospho, modifications(phospho.deltaMonoisotopicMass(), 0, true, true, Site::Serine | Site::Tyrosine)[0].cvid);
// there are no unapproved mods at phospho's mass
unit_assert_operator_equal(0, modifications(phospho.deltaMonoisotopicMass(), 0, true, false).size());
// phospho and sulfo are only distinguishable with PPM mass accuracy
double mass_2000Da_1ppm = 2000 - (2000 - MZTolerance(1, MZTolerance::PPM));
unit_assert_operator_equal(2, modifications(phospho.deltaMonoisotopicMass(), 0.5, true, true, Site::Serine).size());
unit_assert_operator_equal(1, modifications(phospho.deltaMonoisotopicMass(), mass_2000Da_1ppm, true, true, Site::Serine).size());
// test indeterminate and average mass
unit_assert_operator_equal(2, modifications(phospho.deltaMonoisotopicMass(), 0.1, indeterminate, true, Site::Serine).size());
unit_assert_operator_equal(2, modifications(phospho.deltaAverageMass(), 0.1, indeterminate, true, Site::Serine).size());
unit_assert_operator_equal(2, modifications(phospho.deltaAverageMass(), 0.1, false, true, Site::Serine).size());
// test negative mass
mass_2000Da_1ppm,
true, true,
Position::AnyNTerminus)[0].cvid);
// at 14.5 +/- 0.5 there are 3 approved mods and 6 unapproved
unit_assert_operator_equal(3, modifications(14.5, 0.5, true, true).size());
unit_assert_operator_equal(9, modifications(14.5, 0.5, true, false).size());
// all 9 unapproved mods are hidden
unit_assert_operator_equal(0, modifications(14.5, 0.5, true, false, Site::Any,
Position::Anywhere, Classification::Any, false).size());
// test ambiguous residue; this mod could be a Q->P substitution
unit_assert_operator_equal(1, modifications(-31, 0.01, true, indeterminate, site('Z')).size());
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 186 of file UnimodTest.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 36 of file UnimodTest.cpp.