7#ifndef _CTHEORETICALSPECTRUM_H
8#define _CTHEORETICALSPECTRUM_H
12#include <unordered_set>
91 void store(ofstream& os);
98 void load(ifstream& is);
112 int experimentalpeaksmatched;
113 vector<set<int> > experimentalmatches;
114 int scrambledpeaksmatched;
115 map<eFragmentIonType, map<int, int> > matchedions;
117 double experimentalpeaksmatchedratio;
118 double weightedpeaksratio;
119 double cosinesimilarity;
120 int unmatchedexperimentalpeakscount;
121 string coveragebyseries;
123 double sumofrelativeintensities;
124 vector<string> rotationslabels;
126 int reversevalidposition;
129 map<int, double> targetscores;
130 map<int, double> decoyscores;
131 map<int, double> fdrscores;
134 void clearFalseHits(map<
eFragmentIonType, map<
int, vector<int> > >& series, vector<eFragmentIonType>& ions, vector<int>& losses);
137 void searchForPeakPairs(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks,
double fragmentmasserrortolerance);
140 void computeStatistics(
bool writedescription);
143 void generateChargedFragments(
cPeak& peak, map<string, int>& atoms,
int& peaklistrealsize,
int maxcharge,
bool writedescription,
bool disablesummary);
146 void generatePrecursorIon(vector<int>& intcomposition,
cBricksDatabase& bricksdatabasewithcombinations,
int& theoreticalpeaksrealsize,
bool writedescription);
149 void generatePrecursorIonForOther(
int& theoreticalpeaksrealsize,
bool writedescription);
152 void generateScrambledIons(
cBricksDatabase& bricksdatabase,
bool writedescription,
int& theoreticalpeaksrealsize);
155 void updateListOfNeutralLosses(
cBricksDatabase& bricksdatabase,
cBrick& block, vector<int>& currentlosses, vector<double>& fragmentlossmass, vector<string>& fragmentlosssummary, vector< map<string, int> >& fragmentlossmap,
bool writedescription,
bool disablesummary);
158 void generateInternalFragments(
cBricksDatabase& bricksdatabase,
cPeak& peak,
int maxcharge,
int& peaklistrealsize, vector<int>& intcomposition,
int pos, map<string, int>& atoms, vector<int>& currentlosses,
eFragmentIonType fragmentiontype,
ePeptideType peptidetype,
TRotationInfo* trotation,
bool writedescription,
bool disablesummary);
161 void selectAndNormalizeScrambledSequences(unordered_set<string>& scrambledsequences);
164 void selectHigherPriorityIonTypeCID(
cPeak& experimentalpeak,
cPeak& theoreticalpeak);
167 void addPeakToList(
cPeak& peak,
int& theoreticalpeaksrealsize);
170 void addAdductToDescription(
string& description, vector<string>& metals);
173 void addMetalPeaks(
cPeak& peak, vector<string>& metals,
int& peaklistrealsize,
int peakcharge,
bool writedescription);
176 void removeUnmatchedMetalIsotopes(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
179 void removeUnmatchedIsotopePatterns(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks,
cPeaksList& outputtheoreticalpeaks,
bool storeunmatchedpeaks);
182 int removeUnmatchedFeatures(
bool lcms,
int peaklistseriesvectorid,
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks, vector< vector<int> >& hintsindex);
185 int removeUnmatchedCompounds(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks,
int minimumiontypes);
188 void removeCompoundsOutsideRTRange(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
191 void removePeaksUnderAnnotationThreshold(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
194 void removePatternsUnderAnnotationThreshold(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
197 void removeUnmatchedPatternsFineSpectra(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
200 void removeUnmatchedPatternsByIntensityRatio(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
203 void removeUnmatchedPatternsByMZDifference(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
206 void calculateEnvelopeScores(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
209 void removeDecoyPeakMatches(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks);
212 void normalizeTheoreticalIntensities(
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize);
215 double recalibrateToMostIntenseTheoreticalPeak(
cPeaksList& peaklist);
218 double getStandardPPMDeviation(
cPeaksList& theoreticalpeaks,
int start,
int stop);
221 double getStandardIntensityDeviation(
cPeaksList& theoreticalpeaks,
int start,
int stop,
double maximumexperimentalintensity);
224 double getStandardMZDifferenceDeviation(
cPeaksList& theoreticalpeaks,
int start,
int stop);
227 double getAngleDistance(
cPeaksList& theoreticalpeaks,
int start,
int stop);
230 void generateFragmentIsotopePatterns(
int& theoreticalpeaksrealsize,
bool writedescription, unordered_map<string, int>* isotopeformuladesctoid);
233 void fillExperimentalAnnotationsAndRemoveUnmatchedTheoreticalPeaks(
int& theoreticalpeaksrealsize,
ePeptideType peptidetype,
cPeaksList& unmatchedpeaksinmatchedpatterns,
bool reportunmatchedtheoreticalpeaks,
bool writedescription);
236 bool checkIsotopeHighRes(
string& elementstring,
string& isotopestring,
double isotopemass1,
double isotopemass2,
double minintensityratio,
double maxintensityratio,
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks,
int start,
int stop,
int maximumintensityid,
double maximumexperimentalintensity);
239 bool checkIsotopeLowRes(
string& elementstring,
string& isotopestring,
double isotopemass1,
double isotopemass2,
double minintensityratio,
double maxintensityratio,
cPeaksList& theoreticalpeaks,
int theoreticalpeaksrealsize,
cPeaksList& experimentalpeaks,
int start,
int stop,
int maximumintensityid,
double maximumexperimentalintensity);
242 double getIntensityMultiplier(
cPeaksList& theoreticalpeaks,
int peakid,
string& elementstring,
size_t startpos);
266 void clear(
bool clearpeaklist =
true);
301 int compareBranched(
cPeaksList& sortedpeaklist,
cBricksDatabase& bricksdatabasewithcombinations,
bool writedescription, regex& sequencetag, regex& searchedsequence,
cPeaksList& unmatchedpeaksinmatchedpatterns, unordered_map<string, int>* isotopeformuladesctoid);
315 int compareLinear(
cPeaksList& sortedpeaklist,
cBricksDatabase& bricksdatabasewithcombinations,
bool writedescription, regex& sequencetag, regex& searchedsequence,
cPeaksList& unmatchedpeaksinmatchedpatterns, unordered_map<string, int>* isotopeformuladesctoid);
329 int compareCyclic(
cPeaksList& sortedpeaklist,
cBricksDatabase& bricksdatabasewithcombinations,
bool writedescription, regex& sequencetag, regex& searchedsequence,
cPeaksList& unmatchedpeaksinmatchedpatterns, unordered_map<string, int>* isotopeformuladesctoid);
343 int compareBranchCyclic(
cPeaksList& sortedpeaklist,
cBricksDatabase& bricksdatabasewithcombinations,
bool writedescription, regex& sequencetag, regex& searchedsequence,
cPeaksList& unmatchedpeaksinmatchedpatterns, unordered_map<string, int>* isotopeformuladesctoid);
382 int compareOther(
cPeaksList& sortedpeaklist,
bool writedescription,
cPeaksList& unmatchedpeaksinmatchedpatterns, unordered_map<string, int>* isotopeformuladesctoid);
392 void generateMSSpectrum(
int sequencestart,
int sequencestop,
bool& terminatecomputation,
bool writedescription);
531 void generateNTerminalFragmentIons(
int maxcharge,
int& peaklistrealsize, vector<int>& intcomposition,
eFragmentIonType fragmentiontype,
int neutrallosstype,
cBricksDatabase& bricksdatabase,
bool writedescription,
int rotationid, vector<splitSite>& splittingsites, vector<cFragmentIonType>& searchedmodifications,
ePeptideType peptidetype,
bool regularblocksorder,
TRotationInfo* trotation = 0,
eResidueLossType leftresiduelosstype = h2o_loss,
bool hasfirstblockartificial =
false);
552 void generateCTerminalFragmentIons(
int maxcharge,
int& peaklistrealsize, vector<int>& intcomposition,
eFragmentIonType fragmentiontype,
int neutrallosstype,
cBricksDatabase& bricksdatabase,
bool writedescription,
int rotationid, vector<splitSite>& splittingsites, vector<cFragmentIonType>& searchedmodifications,
ePeptideType peptidetype,
bool regularblocksorder,
TRotationInfo* trotation = 0,
eResidueLossType rightresiduelosstype = h2o_loss,
bool haslastblockartificial =
false);
732 void setFDRs(vector<double>& targetscoresvector, vector<double>& fdrs,
cPeaksList& unmatchedpeaksinmatchedpatterns);
739 void store(ofstream& os);
749 void load(ifstream& is,
int fileversionpart1,
int fileversionpart2,
int fileversionpart3);
eResidueLossType
Residue loss types.
Definition: cBrick.h:24
The representation of a set of peptide sequence candidates.
eFragmentIonType
The types of supported fragment ions.
Definition: cFragmentIons.h:944
Definitions of program parameters.
The representation of a series of peaklists.
int getNumberOfScoreHits(vector< double > &scores, double value)
Get the number of hits with equal or better score.
Definition: cTheoreticalSpectrum.cpp:8
The class representing a building block (brick).
Definition: cBrick.h:41
The class representing a database of building blocks (bricks).
Definition: cBricksDatabase.h:66
The class representing a peptide sequence candidate.
Definition: cCandidate.h:131
The class implementing the de novo graph.
Definition: cDeNovoGraph.h:46
The class representing a thread launched by the command 'Search->Run'.
Definition: cMainThread.h:34
The class storing parameters of the application.
Definition: cParameters.h:82
The class representing a peak list.
Definition: cPeaksList.h:68
The class representing a theoretical mass spectrum.
Definition: cTheoreticalSpectrum.h:106
void compareAverageMSSpectrum(cPeaksList &averagespectrum, cTheoreticalSpectrum &tsfull, cPeaksList &unmatchedpeaksinmatchedpatterns)
Compare theoretical peaks with an average spectrum.
Definition: cTheoreticalSpectrum.cpp:5275
void setPathId(int pathid)
Set path id.
Definition: cTheoreticalSpectrum.cpp:6265
int compareLinear(cPeaksList &sortedpeaklist, cBricksDatabase &bricksdatabasewithcombinations, bool writedescription, regex &sequencetag, regex &searchedsequence, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a linear peptide with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:3832
double getTargetPatternScore(int groupid)
Get target pattern score.
Definition: cTheoreticalSpectrum.cpp:6280
void resizePeakList(int size)
Resize the list of peaks.
Definition: cTheoreticalSpectrum.cpp:6052
double getSumOfRelativeIntensities() const
Get the sum of relative intensities of matched peaks.
Definition: cTheoreticalSpectrum.cpp:6057
int getNumberOfCompletedSeries()
Get a number of series which identify the peptide.
Definition: cTheoreticalSpectrum.cpp:6255
int getNumberOfMatchedPeaks() const
Get the number of matched peaks between an experimental and a theoretical spectrum.
Definition: cTheoreticalSpectrum.cpp:5407
cPeaksList * getTheoreticalPeaks()
Get a list of theoretical peaks.
Definition: cTheoreticalSpectrum.cpp:6095
void store(ofstream &os)
Store the structure into an output stream.
Definition: cTheoreticalSpectrum.cpp:6349
void generateFineMSSpectrum(int sequencestart, int sequencestop, bool &terminatecomputation)
Generate a simple mass spectrum with fine isotopic patterns.
Definition: cTheoreticalSpectrum.cpp:4988
string getCoverageBySeries()
Get coverage of series of fragment ions.
Definition: cTheoreticalSpectrum.cpp:6085
int getNumberOfMatchedPeaksB() const
Get the number of matched B ions between an experimental and a theoretical spectrum.
Definition: cTheoreticalSpectrum.cpp:5427
bool equals(cTheoreticalSpectrum &secondtheoreticalspectrum)
Check if the object equals to another object.
Definition: cTheoreticalSpectrum.cpp:6517
bool isValid()
Check if the candidate sequence corresponds to the searched sequence.
Definition: cTheoreticalSpectrum.cpp:6100
double getRatioOfMatchedPeaks()
Get a ratio of matched peaks.
Definition: cTheoreticalSpectrum.cpp:5486
void setExperimentalSpectrum(cPeaksList &experimentalspectrum)
Set the experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:6072
int getReverseValidPosition()
Get a reverted position of a rotation of a cyclic peptide sequence corresponding to searched sequence...
Definition: cTheoreticalSpectrum.cpp:6110
void generateMSSpectrum(int sequencestart, int sequencestop, bool &terminatecomputation, bool writedescription)
Generate a simple mass spectrum.
Definition: cTheoreticalSpectrum.cpp:4901
void setNumberOfCompletedSeries(int numberofcompletedseries)
Set a number of series which identify the peptide.
Definition: cTheoreticalSpectrum.cpp:6260
void setFDRs(vector< double > &targetscoresvector, vector< double > &fdrs, cPeaksList &unmatchedpeaksinmatchedpatterns)
Set false discovery rates to peak groups.
Definition: cTheoreticalSpectrum.cpp:6300
void getHintsIndex(int id, int peaklistseriesvectorid, cTheoreticalSpectrum &tsfull, cPeaksList &unmatchedpeaksinmatchedpatterns, vector< vector< int > > &hintsindex, bool lcmsrt, bool skipcomparison)
Get a map of search hints to identify features in LC-MS data.
Definition: cTheoreticalSpectrum.cpp:5078
int compareLinearPolyketide(cPeaksList &sortedpeaklist, cBricksDatabase &bricksdatabasewithcombinations, bool writedescription, regex &sequencetag, regex &searchedsequence, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a linear polyketide with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:4634
int getNumberOfMatchedPeaksY() const
Get the number of matched Y ions between an experimental and a theoretical spectrum.
Definition: cTheoreticalSpectrum.cpp:5454
void setValidSequence(regex &searchedsequence)
Set a flag determining if the candidate sequence corresponds to the searched sequence.
Definition: cTheoreticalSpectrum.cpp:6115
int getUnmatchedExperimentalPeaksCount()
Get the number of unmatched experimental peaks.
Definition: cTheoreticalSpectrum.cpp:6090
int getPathId() const
Get path id.
Definition: cTheoreticalSpectrum.cpp:6270
int compareBranched(cPeaksList &sortedpeaklist, cBricksDatabase &bricksdatabasewithcombinations, bool writedescription, regex &sequencetag, regex &searchedsequence, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a branched peptide with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:3624
int compareBranchCyclic(cPeaksList &sortedpeaklist, cBricksDatabase &bricksdatabasewithcombinations, bool writedescription, regex &sequencetag, regex &searchedsequence, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a branch-cyclic peptide with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:4328
cPeaksList & getExperimentalSpectrum()
Get an experimental spectrum which has been compared with the theoretical spectrum.
Definition: cTheoreticalSpectrum.cpp:6067
void compareMSSpectrum(int id, int peaklistseriesvectorid, cTheoreticalSpectrum &tsfull, cPeaksList &unmatchedpeaksinmatchedpatterns, vector< vector< int > > &hintsindex, bool lcmsrt, bool skipcomparison)
Compare theoretical peaks with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:5140
cTheoreticalSpectrum()
The constructor.
Definition: cTheoreticalSpectrum.cpp:3567
map< int, double > & getDecoyScores()
Get map of decoy scores.
Definition: cTheoreticalSpectrum.cpp:6295
set< int > & getExperimentalMatches(int peakid)
Get ids of theoretical peaks which hit an experimental peak.
Definition: cTheoreticalSpectrum.cpp:6080
void generateNTerminalFragmentIons(int maxcharge, int &peaklistrealsize, vector< int > &intcomposition, eFragmentIonType fragmentiontype, int neutrallosstype, cBricksDatabase &bricksdatabase, bool writedescription, int rotationid, vector< splitSite > &splittingsites, vector< cFragmentIonType > &searchedmodifications, ePeptideType peptidetype, bool regularblocksorder, TRotationInfo *trotation=0, eResidueLossType leftresiduelosstype=h2o_loss, bool hasfirstblockartificial=false)
Generate a N-terminal fragment ion series.
Definition: cTheoreticalSpectrum.cpp:5501
int getNumberOfMatchedPeaksYB() const
Get the number of matched Y and B ions between an experimental and a theoretical spectrum.
Definition: cTheoreticalSpectrum.cpp:5481
int getNumberOfScrambledPeaks()
Get the number of matched scrambled peaks between an experimental and a theoretical spectrum.
Definition: cTheoreticalSpectrum.cpp:5412
int compareOther(cPeaksList &sortedpeaklist, bool writedescription, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a metabolite with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:4854
cPeak & operator[](int position)
Overloaded operator [].
Definition: cTheoreticalSpectrum.cpp:6062
void attach(cTheoreticalSpectrum &secondtheoreticalspectrum)
Attach another spectrum.
Definition: cTheoreticalSpectrum.cpp:6631
void clear(bool clearpeaklist=true)
Clear the spectrum.
Definition: cTheoreticalSpectrum.cpp:3579
double getCosineSimilarity() const
Get cosine similarity.
Definition: cTheoreticalSpectrum.cpp:5496
map< int, double > & getTargetScores()
Get map of target scores.
Definition: cTheoreticalSpectrum.cpp:6290
cCandidate & getCandidate()
Get the peptide spectrum candidate.
Definition: cTheoreticalSpectrum.cpp:3614
int compareCyclicPolyketide(cPeaksList &sortedpeaklist, cBricksDatabase &bricksdatabasewithcombinations, bool writedescription, regex &sequencetag, regex &searchedsequence, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a cyclic polyketide with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:4843
void finalizeMSSpectrum(cPeaksList &unmatchedpeaksinmatchedpatterns, bool writedescription)
Finalize MS spectrum after comparison.
Definition: cTheoreticalSpectrum.cpp:5384
int compareCyclic(cPeaksList &sortedpeaklist, cBricksDatabase &bricksdatabasewithcombinations, bool writedescription, regex &sequencetag, regex &searchedsequence, cPeaksList &unmatchedpeaksinmatchedpatterns, unordered_map< string, int > *isotopeformuladesctoid)
Compare the theoretical spectrum of a cyclic peptide with an experimental spectrum.
Definition: cTheoreticalSpectrum.cpp:4012
int getNumberOfPeaks()
Get the number of peaks in the spectrum.
Definition: cTheoreticalSpectrum.cpp:5402
void setParameters(cParameters *parameters)
Set a pointer to the parameters of the application.
Definition: cTheoreticalSpectrum.cpp:6275
void generateCTerminalFragmentIons(int maxcharge, int &peaklistrealsize, vector< int > &intcomposition, eFragmentIonType fragmentiontype, int neutrallosstype, cBricksDatabase &bricksdatabase, bool writedescription, int rotationid, vector< splitSite > &splittingsites, vector< cFragmentIonType > &searchedmodifications, ePeptideType peptidetype, bool regularblocksorder, TRotationInfo *trotation=0, eResidueLossType rightresiduelosstype=h2o_loss, bool haslastblockartificial=false)
Generate a C-terminal fragment ion series.
Definition: cTheoreticalSpectrum.cpp:5785
double getWeightedRatioOfMatchedPeaks() const
Get weighted ratio of matched peaks.
Definition: cTheoreticalSpectrum.cpp:5491
vector< string > & getLabelsOfRotations()
Get the labels of cyclic rotations.
Definition: cTheoreticalSpectrum.cpp:6250
void sortByMass(int limit=-1)
Sort peaks by mass.
Definition: cTheoreticalSpectrum.cpp:6047
double getTargetPatternFDR(int groupid)
Get target pattern FDR.
Definition: cTheoreticalSpectrum.cpp:6285
void setCandidate(cCandidate &candidate)
Set a peptide spectrum candidate.
Definition: cTheoreticalSpectrum.cpp:3619
int getValidPosition()
Get a position of a rotation of a cyclic peptide sequence corresponding to searched sequence.
Definition: cTheoreticalSpectrum.cpp:6105
void load(ifstream &is, int fileversionpart1, int fileversionpart2, int fileversionpart3)
Load the structure from an input stream.
Definition: cTheoreticalSpectrum.cpp:6424
An auxiliary structure representing a branch permutation of a branched peptide.
Definition: cCandidate.h:30
A structure representing a peak in a mass spectrum.
Definition: cPeak.h:22
An auxiliary structure for visualisation of matched series of fragment ions.
Definition: cTheoreticalSpectrum.h:64
void load(ifstream &is)
Load the structure from an input stream.
Definition: cTheoreticalSpectrum.cpp:50
vector< int > series
A vector of matched peaks in a series.
Definition: cTheoreticalSpectrum.h:69
string name
A name of a series of fragment ions.
Definition: cTheoreticalSpectrum.h:75
void store(ofstream &os)
Store the structure into an output stream.
Definition: cTheoreticalSpectrum.cpp:37
matchedSeries()
The constructor.
Definition: cTheoreticalSpectrum.h:81
The structure representing a splitting site of a cyclic peptide.
Definition: cTheoreticalSpectrum.h:40
int first
Order of the first amino acid where a cyclic peptide is split.
Definition: cTheoreticalSpectrum.h:45
int second
Order of the second amino acid where a cyclic peptide is split.
Definition: cTheoreticalSpectrum.h:51
ePeptideType
The types of peptides supported by the application.
Definition: utilities.h:104