ProteoWizard
Macros | Functions | Variables
IdentDataTest.cpp File Reference
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include "pwiz/data/common/Unimod.hpp"
#include "IdentData.hpp"
#include "Serializer_mzid.hpp"
#include "examples.hpp"
#include "Diff.hpp"
#include "TextWriter.hpp"

Go to the source code of this file.

Macros

#define PWIZ_SOURCE

Functions

void testDigestedPeptides ()
void testSnapModifications ()
void testConversion ()
void testCleavageAgent ()
int main (int argc, char **argv)

Variables

ostream * os_

Macro Definition Documentation

#define PWIZ_SOURCE

Definition at line 24 of file IdentDataTest.cpp.


Function Documentation

void testDigestedPeptides ( )

Definition at line 46 of file IdentDataTest.cpp.

References pwiz::identdata::digestedPeptide(), pwiz::identdata::digestedPeptides(), pwiz::identdata::examples::initializeBasicSpectrumIdentification(), MS_no_cleavage, MS_Trypsin_P, MS_unspecific_cleavage, unit_assert, and unit_assert_operator_equal.

Referenced by main().

{
using namespace pwiz::proteome;
IdentData mzid;
SpectrumIdentificationProtocolPtr sip = mzid.analysisProtocolCollection.spectrumIdentificationProtocol[0];
SpectrumIdentificationListPtr sil = mzid.dataCollection.analysisData.spectrumIdentificationList[0];
SpectrumIdentificationResultPtr result2 = sil->spectrumIdentificationResult[1];
// test with multiple simultaneous enzymes (Lys-C/P and Arg-C)
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
// both termini are specific now, one cut from each enzyme
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(2, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
}
// test with multiple independent enzymes (Lys-C/P and Arg-C)
sip->enzymes.independent = true;
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
// reassign the original prefix residue
result2_rank1->peptideEvidencePtr[0]->pre = 'K';
// there are two semi-specific peptides, one cut by Lys-C and the other cut by Arg-C;
// only the first one will be returned because they have the same "best specificity"
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(1, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(!result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
}
// change from multiple enzymes to trypsin/p and test again
sip->enzymes.enzymes.clear();
EnzymePtr trypsin(new Enzyme);
trypsin->id = "ENZ_1";
trypsin->cTermGain = "OH";
trypsin->nTermGain = "H";
trypsin->missedCleavages = 2;
trypsin->minDistance = 1;
trypsin->terminalSpecificity = proteome::Digestion::FullySpecific;
trypsin->siteRegexp = "(?<=[KR])";
trypsin->enzymeName.set(MS_Trypsin_P);
sip->enzymes.enzymes.push_back(trypsin);
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(423, result2_rank1_digestedPeptides[0].offset());
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(2, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
unit_assert_operator_equal("K", result2_rank1_digestedPeptides[0].NTerminusPrefix());
unit_assert_operator_equal("A", result2_rank1_digestedPeptides[0].CTerminusSuffix());
// result 2 rank 2: K.RNSTIPT.K
SpectrumIdentificationItemPtr result2_rank2 = result2->spectrumIdentificationItem[1];
vector<DigestedPeptide> result2_rank2_digestedPeptides = digestedPeptides(*sip, *result2_rank2);
unit_assert_operator_equal(2, result2_rank2_digestedPeptides.size());
// both PeptideEvidences have the same values
for (int i=0; i < 2; ++i)
{
unit_assert(digestedPeptide(*sip, *result2_rank2->peptideEvidencePtr[i]) == result2_rank2_digestedPeptides[i]);
unit_assert_operator_equal(415, result2_rank2_digestedPeptides[i].offset());
unit_assert_operator_equal(1, result2_rank2_digestedPeptides[i].missedCleavages());
unit_assert_operator_equal(1, result2_rank2_digestedPeptides[i].specificTermini());
unit_assert(result2_rank2_digestedPeptides[i].NTerminusIsSpecific());
unit_assert(!result2_rank2_digestedPeptides[i].CTerminusIsSpecific());
unit_assert_operator_equal("K", result2_rank2_digestedPeptides[i].NTerminusPrefix());
unit_assert_operator_equal("K", result2_rank2_digestedPeptides[i].CTerminusSuffix());
}
}
// change enzyme from trypsin to Lys-C and test again
sip->enzymes.enzymes[0]->enzymeName.clear();
sip->enzymes.enzymes[0]->siteRegexp = "(?<=K)";
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(1, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(!result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
// result 2 rank 2: K.RNSTIPT.K
SpectrumIdentificationItemPtr result2_rank2 = result2->spectrumIdentificationItem[1];
vector<DigestedPeptide> result2_rank2_digestedPeptides = digestedPeptides(*sip, *result2_rank2);
unit_assert_operator_equal(2, result2_rank2_digestedPeptides.size());
// both PeptideEvidences have the same values
for (int i=0; i < 2; ++i)
{
unit_assert(digestedPeptide(*sip, *result2_rank2->peptideEvidencePtr[i]) == result2_rank2_digestedPeptides[i]);
unit_assert_operator_equal(0, result2_rank2_digestedPeptides[i].missedCleavages());
unit_assert_operator_equal(1, result2_rank2_digestedPeptides[i].specificTermini());
unit_assert(result2_rank2_digestedPeptides[i].NTerminusIsSpecific());
unit_assert(!result2_rank2_digestedPeptides[i].CTerminusIsSpecific());
}
}
// change enzyme from Lys-C to unspecific cleavage and test again
sip->enzymes.enzymes[0]->enzymeName.set(MS_unspecific_cleavage);
sip->enzymes.enzymes[0]->siteRegexp.clear();
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(!result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(!result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
// result 2 rank 2: K.RNSTIPT.K
SpectrumIdentificationItemPtr result2_rank2 = result2->spectrumIdentificationItem[1];
vector<DigestedPeptide> result2_rank2_digestedPeptides = digestedPeptides(*sip, *result2_rank2);
unit_assert_operator_equal(2, result2_rank2_digestedPeptides.size());
// both PeptideEvidences have the same values
for (int i=0; i < 2; ++i)
{
unit_assert(digestedPeptide(*sip, *result2_rank2->peptideEvidencePtr[i]) == result2_rank2_digestedPeptides[i]);
unit_assert_operator_equal(0, result2_rank2_digestedPeptides[i].missedCleavages());
unit_assert_operator_equal(0, result2_rank2_digestedPeptides[i].specificTermini());
unit_assert(!result2_rank2_digestedPeptides[i].NTerminusIsSpecific());
unit_assert(!result2_rank2_digestedPeptides[i].CTerminusIsSpecific());
}
}
// change enzyme from unspecific cleavage to no cleavage and test again
sip->enzymes.enzymes[0]->enzymeName.clear();
sip->enzymes.enzymes[0]->enzymeName.set(MS_no_cleavage);
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(2, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
// result 2 rank 2: K.RNSTIPT.K
SpectrumIdentificationItemPtr result2_rank2 = result2->spectrumIdentificationItem[1];
vector<DigestedPeptide> result2_rank2_digestedPeptides = digestedPeptides(*sip, *result2_rank2);
unit_assert_operator_equal(2, result2_rank2_digestedPeptides.size());
// both PeptideEvidences have the same values
for (int i=0; i < 2; ++i)
{
unit_assert(digestedPeptide(*sip, *result2_rank2->peptideEvidencePtr[i]) == result2_rank2_digestedPeptides[i]);
unit_assert_operator_equal(0, result2_rank2_digestedPeptides[i].missedCleavages());
unit_assert_operator_equal(2, result2_rank2_digestedPeptides[i].specificTermini());
unit_assert(result2_rank2_digestedPeptides[i].NTerminusIsSpecific());
unit_assert(result2_rank2_digestedPeptides[i].CTerminusIsSpecific());
}
}
// change enzyme from no cleavage to Lys-N and test again
sip->enzymes.enzymes[0]->enzymeName.clear();
sip->enzymes.enzymes[0]->siteRegexp = "(?=K)";
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(!result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(!result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
// result 2 rank 2: K.RNSTIPT.K
SpectrumIdentificationItemPtr result2_rank2 = result2->spectrumIdentificationItem[1];
vector<DigestedPeptide> result2_rank2_digestedPeptides = digestedPeptides(*sip, *result2_rank2);
unit_assert_operator_equal(2, result2_rank2_digestedPeptides.size());
// both PeptideEvidences have the same values
for (int i=0; i < 2; ++i)
{
unit_assert(digestedPeptide(*sip, *result2_rank2->peptideEvidencePtr[i]) == result2_rank2_digestedPeptides[i]);
unit_assert_operator_equal(0, result2_rank2_digestedPeptides[i].missedCleavages());
unit_assert_operator_equal(1, result2_rank2_digestedPeptides[i].specificTermini());
unit_assert(!result2_rank2_digestedPeptides[i].NTerminusIsSpecific());
unit_assert(result2_rank2_digestedPeptides[i].CTerminusIsSpecific());
}
}
{
// result 2 rank 1: K.QTQTFTTYSDNQPGVLIQVYEGER.A
SpectrumIdentificationItemPtr result2_rank1 = result2->spectrumIdentificationItem[0];
// move it to the C terminus
result2_rank1->peptideEvidencePtr[0]->start = 618;
result2_rank1->peptideEvidencePtr[0]->post = '-';
vector<DigestedPeptide> result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(617, result2_rank1_digestedPeptides[0].offset());
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(1, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(!result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
unit_assert_operator_equal("K", result2_rank1_digestedPeptides[0].NTerminusPrefix());
unit_assert_operator_equal("-", result2_rank1_digestedPeptides[0].CTerminusSuffix());
// move it to the N terminus
result2_rank1->peptideEvidencePtr[0]->start = 1;
result2_rank1->peptideEvidencePtr[0]->pre = '-';
result2_rank1->peptideEvidencePtr[0]->post = 'A';
result2_rank1_digestedPeptides = digestedPeptides(*sip, *result2_rank1);
unit_assert_operator_equal(1, result2_rank1_digestedPeptides.size());
unit_assert(digestedPeptide(*sip, *result2_rank1->peptideEvidencePtr[0]) == result2_rank1_digestedPeptides[0]);
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].offset());
unit_assert_operator_equal(0, result2_rank1_digestedPeptides[0].missedCleavages());
unit_assert_operator_equal(1, result2_rank1_digestedPeptides[0].specificTermini());
unit_assert(result2_rank1_digestedPeptides[0].NTerminusIsSpecific());
unit_assert(!result2_rank1_digestedPeptides[0].CTerminusIsSpecific());
unit_assert_operator_equal("-", result2_rank1_digestedPeptides[0].NTerminusPrefix());
unit_assert_operator_equal("A", result2_rank1_digestedPeptides[0].CTerminusSuffix());
}
}
void testSnapModifications ( )

Definition at line 304 of file IdentDataTest.cpp.

References pwiz::identdata::IdentData::analysisCollection, pwiz::identdata::IdentData::analysisProtocolCollection, diff(), pwiz::identdata::examples::initializeBasicSpectrumIdentification(), os_, pwiz::identdata::SequenceCollection::peptides, pwiz::identdata::IdentData::sequenceCollection, pwiz::identdata::snapModificationsToUnimod(), pwiz::identdata::AnalysisCollection::spectrumIdentification, pwiz::identdata::AnalysisProtocolCollection::spectrumIdentificationProtocol, and unit_assert.

Referenced by main().

{
IdentData mzid, mzid2;
BOOST_FOREACH(SpectrumIdentificationProtocolPtr& sip, mzid2.analysisProtocolCollection.spectrumIdentificationProtocol)
BOOST_FOREACH(SearchModificationPtr& mod, sip->modificationParams)
mod->cvParams.clear();
BOOST_FOREACH(PeptidePtr& pep, mzid2.sequenceCollection.peptides)
BOOST_FOREACH(ModificationPtr& mod, pep->modification)
mod->cvParams.clear();
Diff<IdentData, DiffConfig> diff(mzid, mzid2);
BOOST_FOREACH(SpectrumIdentificationPtr& si, mzid2.analysisCollection.spectrumIdentification)
diff(mzid, mzid2);
if (diff && os_) *os_ << "diff:\n" << diff_string<TextWriter>(diff) << endl;
unit_assert(!diff);
}
void testConversion ( )

Definition at line 329 of file IdentDataTest.cpp.

References pwiz::util::virtual_map< keyT, valueT, _Pr, _Alloc >::count(), pwiz::proteome::ModificationMap::CTerminus(), pwiz::proteome::ModificationMap::find(), pwiz::identdata::examples::initializeBasicSpectrumIdentification(), pwiz::data::unimod::modification(), pwiz::proteome::Peptide::modifications(), pwiz::proteome::Modification::monoisotopicDeltaMass(), pwiz::identdata::peptide(), pwiz::identdata::SequenceCollection::peptides, pwiz::proteome::Peptide::sequence(), pwiz::identdata::IdentData::sequenceCollection, pwiz::util::virtual_map< keyT, valueT, _Pr, _Alloc >::size(), UNIMOD_Amidated, UNIMOD_Carbamidomethyl, UNIMOD_Phospho, and unit_assert_operator_equal.

Referenced by main().

{
IdentData mzid;
// PEP_2: TAIGIDLGT[80]TYSC[57]VGVFQHGK
unit_assert_operator_equal("TAIGIDLGTTYSCVGVFQHGK", pep2.sequence());
pep2.modifications().find(8)->second.monoisotopicDeltaMass());
pep2.modifications().find(12)->second.monoisotopicDeltaMass());
// PEP_5: RNS[80]TIPT[-1]
unit_assert_operator_equal("RNSTIPT", pep5.sequence());
unit_assert_operator_equal(2, pep5.modifications().size());
unit_assert_operator_equal(1, pep5.modifications().count(2));
pep5.modifications().find(2)->second.monoisotopicDeltaMass());
unit_assert_operator_equal(1, pep5.modifications().count(ModificationMap::CTerminus()));
pep5.modifications().find(ModificationMap::CTerminus())->second.monoisotopicDeltaMass());
}
void testCleavageAgent ( )
int main ( int  argc,
char **  argv 
)

Definition at line 387 of file IdentDataTest.cpp.

References e(), os_, TEST_EPILOG, TEST_FAILED, TEST_PROLOG, testCleavageAgent(), testConversion(), testDigestedPeptides(), and testSnapModifications().

{
TEST_PROLOG(argc, argv)
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
if (os_) *os_ << "MzIdentMLTest\n";
try
{
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_

Definition at line 43 of file IdentDataTest.cpp.