ProteoWizard
Functions | Variables
PeptideMatcherTest.cpp File Reference
#include "PeptideMatcher.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Functions

PidfPtr makePeptideID_dataFetcher (const char *samplePepXML)
SpectrumQuery makeSpectrumQuery (double precursorNeutralMass, double rt, int charge, string sequence, double score, int startScan, int endScan)
FeaturePtr makeFeature (double mz, double retentionTime)
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0
const char * samplePepXML_a = "</msms_pipeline_analysis>\n"
const char * samplePepXML_b = "</msms_pipeline_analysis>\n"

Function Documentation

PidfPtr makePeptideID_dataFetcher ( const char *  samplePepXML)

Definition at line 120 of file PeptideMatcherTest.cpp.

{
istringstream iss(samplePepXML);
return pidf;
}
SpectrumQuery makeSpectrumQuery ( double  precursorNeutralMass,
double  rt,
int  charge,
string  sequence,
double  score,
int  startScan,
int  endScan 
)

Definition at line 129 of file PeptideMatcherTest.cpp.

References pwiz::data::pepxml::PeptideProphetResult::allNttProb, pwiz::data::pepxml::AnalysisResult::analysis, pwiz::data::pepxml::SearchHit::analysisResult, pwiz::data::pepxml::SpectrumQuery::assumedCharge, pwiz::data::pepxml::SpectrumQuery::endScan, pwiz::data::pepxml::SearchHit::peptide, pwiz::data::pepxml::AnalysisResult::peptideProphetResult, pwiz::data::pepxml::SpectrumQuery::precursorNeutralMass, pwiz::data::pepxml::PeptideProphetResult::probability, pwiz::data::pepxml::SpectrumQuery::retentionTimeSec, pwiz::data::pepxml::SearchResult::searchHit, pwiz::data::pepxml::SpectrumQuery::searchResult, and pwiz::data::pepxml::SpectrumQuery::startScan.

{
SpectrumQuery spectrumQuery;
spectrumQuery.startScan = startScan;
spectrumQuery.endScan = endScan;
spectrumQuery.precursorNeutralMass = precursorNeutralMass;
spectrumQuery.assumedCharge = charge;
spectrumQuery.retentionTimeSec = rt;
SearchResult searchResult;
SearchHit searchHit;
searchHit.peptide = sequence;
AnalysisResult analysisResult;
analysisResult.analysis = "peptideprophet";
PeptideProphetResult peptideProphetResult;
peptideProphetResult.probability = score;
peptideProphetResult.allNttProb.push_back(0);
peptideProphetResult.allNttProb.push_back(0);
peptideProphetResult.allNttProb.push_back(score);
analysisResult.peptideProphetResult = peptideProphetResult;
searchHit.analysisResult = analysisResult;
searchResult.searchHit = searchHit;
spectrumQuery.searchResult = searchResult;
return spectrumQuery;
}
FeaturePtr makeFeature ( double  mz,
double  retentionTime 
)

Definition at line 165 of file PeptideMatcherTest.cpp.

References pwiz::chemistry::Ion::mz().

{
FeaturePtr feature(new Feature());
feature->mz = mz;
feature->retentionTime = retentionTime;
return feature;
}
void test ( )

Definition at line 175 of file PeptideMatcherTest.cpp.

References pwiz::eharmony::PeptideMatcher::calculateDeltaMZDistribution(), pwiz::eharmony::PeptideMatcher::calculateDeltaRTDistribution(), e(), epsilon, pwiz::eharmony::PeptideMatcher::getDeltaMZParams(), pwiz::eharmony::PeptideMatcher::getDeltaRTParams(), pwiz::eharmony::PeptideMatcher::getMatches(), makeFeature(), makePeptideID_dataFetcher(), makeSpectrumQuery(), os_, samplePepXML_a, samplePepXML_b, unit_assert, unit_assert_equal, and pwiz::data::pepxml::SpectrumQuery::write().

{
// construct test fdfs
FeaturePtr a = makeFeature(1,2.1);
FeaturePtr b = makeFeature(3,4.2);
FeaturePtr c = makeFeature(5,6.4);
FeaturePtr d = makeFeature(7,8.8);
vector<FeaturePtr> features_a;
features_a.push_back(a);
features_a.push_back(b);
features_a.push_back(e);
vector<FeaturePtr> features_b;
features_b.push_back(c);
features_b.push_back(d);
features_b.push_back(e);
Feature_dataFetcher fdf_a(features_a);
Feature_dataFetcher fdf_b(features_b);
// construct pidfs
// construct PeptideMatcher
// DataFetcherContainer dfc(pidf_a, pidf_b, fdf_a, fdf_b);
PeptideMatcher pm(pidf_a, pidf_b);
PeptideMatchContainer pmc = pm.getMatches();
// ensure that _matches attribute is filled in
unit_assert(pmc.size() != 0);
// and correctly:
// construct the objects that should be in matches
SpectrumQuery sq_a = makeSpectrumQuery(2.0,2.0,1,"BUCKLEMYSHOE",0.900,1,2);
SpectrumQuery sq_b = makeSpectrumQuery(2.1,3.0,1,"BUCKLEMYSHOE",0.900,1,2);
SpectrumQuery sq_c = makeSpectrumQuery(2.0,4.0,1,"ABIGFATHEN",0.900,9,10);
SpectrumQuery sq_d = makeSpectrumQuery(2.2,2.0,1,"ABIGFATHEN",0.900,9,10);
PeptideMatchContainer::iterator it = pmc.begin();
if (os_)
{
*os_ << "\n[PeptideMatcherTest] Matches found:\n " << endl;
ostringstream oss;
XMLWriter writer(oss);
PeptideMatchContainer::iterator it = pmc.begin();
for(; it != pmc.end(); ++it)
{
it->first->write(writer);
it->second->write(writer);
}
oss << "\n[PeptideMatcherTest] Looking for:\n " << endl;
sq_a.write(writer);
sq_b.write(writer);
*os_ << oss.str() << endl;
}
// assert that known matches are found TODO fix
/*
unit_assert(find(pmc.begin(), pmc.end(), make_pair(sq_a, sq_b)) != pmc.end());
unit_assert(find(pmc.begin(), pmc.end(), make_pair(sq_c, sq_d)) != pmc.end());
*/
// calculate deltaRtDistribution by hand
double mean = 0.5;
double stdev = 1.5;
// and verify that it is correct
pm.calculateDeltaRTDistribution();
unit_assert_equal(pm.getDeltaRTParams().first, mean, 2 * numeric_limits<double>::epsilon());
unit_assert_equal(pm.getDeltaRTParams().second, stdev, 2 * numeric_limits<double>::epsilon());
// calculate deltaMZDistribution by hand
double mz_mean = -0.15;
double mz_stdev = 0.05;
// and verify that it is correct
pm.calculateDeltaMZDistribution();
unit_assert_equal(pm.getDeltaMZParams().first, mz_mean, 2 * numeric_limits<double>::epsilon());
unit_assert_equal(pm.getDeltaMZParams().second, mz_stdev, 2 * numeric_limits<double>::epsilon());
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 267 of file PeptideMatcherTest.cpp.

References e(), os_, and test().

{
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (std::exception& e)
{
cerr << e.what() << endl;
return 1;
}
catch (...)
{
cerr << "Caught unknown exception.\n";
return 1;
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 31 of file PeptideMatcherTest.cpp.

const char* samplePepXML_a = "</msms_pipeline_analysis>\n"

Definition at line 33 of file PeptideMatcherTest.cpp.

Referenced by test().

const char* samplePepXML_b = "</msms_pipeline_analysis>\n"

Definition at line 76 of file PeptideMatcherTest.cpp.

Referenced by test().