35 #ifndef OPENMS_FILTERING_ID_IDFILTER_H
36 #define OPENMS_FILTERING_ID_IDFILTER_H
38 #include <OpenMS/config.h>
72 template <
class IdentificationType>
75 typedef typename IdentificationType::HitType HitType;
76 std::vector<HitType> temp_hits;
77 std::vector<HitType> filtered_hits;
79 filtered_identification = identification;
80 filtered_identification.setHits(std::vector<HitType>());
82 for (
typename std::vector<HitType>::const_iterator it = identification.getHits().begin();
83 it != identification.getHits().end();
86 if (it->getScore() >= threshold_fraction * identification.getSignificanceThreshold())
88 filtered_hits.push_back(*it);
92 if (!filtered_hits.empty())
94 filtered_identification.setHits(filtered_hits);
95 filtered_identification.assignRanks();
106 template <
class IdentificationType>
109 typedef typename IdentificationType::HitType HitType;
110 std::vector<HitType> temp_hits;
111 std::vector<HitType> filtered_hits;
113 filtered_identification = identification;
114 filtered_identification.setHits(std::vector<HitType>());
116 for (
typename std::vector<HitType>::const_iterator it = identification.getHits().begin();
117 it != identification.getHits().end();
120 if (identification.isHigherScoreBetter())
122 if (it->getScore() >= threshold_score)
124 filtered_hits.push_back(*it);
129 if (it->getScore() <= threshold_score)
131 filtered_hits.push_back(*it);
136 if (!filtered_hits.empty())
138 filtered_identification.setHits(filtered_hits);
139 filtered_identification.assignRanks();
149 template <
class IdentificationType>
152 typedef typename IdentificationType::HitType HitType;
153 std::vector<HitType> temp_hits;
154 std::vector<HitType> filtered_hits;
157 IdentificationType temp_identification = identification;
158 temp_identification.sort();
160 filtered_identification = identification;
161 filtered_identification.setHits(std::vector<HitType>());
164 typename std::vector<HitType>::const_iterator it = temp_identification.getHits().begin();
165 while (it != temp_identification.getHits().end()
168 filtered_hits.push_back(*it);
173 if (!filtered_hits.empty())
175 filtered_identification.setHits(filtered_hits);
176 filtered_identification.assignRanks();
187 template <
class IdentificationType>
195 typedef typename IdentificationType::HitType HitType;
196 std::vector<HitType> filtered_hits;
198 IdentificationType temp_identification = identification;
199 temp_identification.sort();
201 filtered_identification = identification;
202 filtered_identification.setHits(std::vector<HitType>());
204 const std::vector<HitType>& hits = temp_identification.getHits();
205 for (
Size i = n - 1; n <= m - 1; ++i)
207 if (i >= hits.size())
211 filtered_hits.push_back(hits[i]);
214 if (!filtered_hits.empty())
216 filtered_identification.setHits(filtered_hits);
217 filtered_identification.assignRanks();
227 void filterIdentificationsByProteins(
const PeptideIdentification& identification,
const std::vector<FASTAFile::FASTAEntry>& proteins,
PeptideIdentification& filtered_identification,
bool no_protein_identifiers =
false);
276 template <
class PeakT>
281 std::vector<ProteinIdentification> filtered_protein_identifications;
285 filterIdentificationsByThreshold(experiment.
getProteinIdentifications()[j], protein_threshold_fraction, temp_protein_identification);
286 if (!temp_protein_identification.
getHits().empty())
288 filtered_protein_identifications.push_back(temp_protein_identification);
295 std::vector<PeptideIdentification> filtered_identifications;
297 for (
Size i = 0; i < experiment.
size(); i++)
299 for (
Size j = 0; j < experiment[i].getPeptideIdentifications().
size(); j++)
301 filterIdentificationsByThreshold(experiment[i].getPeptideIdentifications()[j], peptide_threshold_fraction, temp_identification);
302 if (!temp_identification.
getHits().empty())
304 filtered_identifications.push_back(temp_identification);
307 experiment[i].setPeptideIdentifications(filtered_identifications);
308 filtered_identifications.clear();
313 template <
class PeakT>
318 std::vector<ProteinIdentification> filtered_protein_identifications;
322 filterIdentificationsByScore(experiment.
getProteinIdentifications()[j], protein_threshold_score, temp_protein_identification);
323 if (!temp_protein_identification.
getHits().empty())
325 filtered_protein_identifications.push_back(temp_protein_identification);
332 std::vector<PeptideIdentification> filtered_identifications;
334 for (
Size i = 0; i < experiment.
size(); i++)
336 for (
Size j = 0; j < experiment[i].getPeptideIdentifications().
size(); j++)
338 filterIdentificationsByScore(experiment[i].getPeptideIdentifications()[j], peptide_threshold_score, temp_identification);
339 if (!temp_identification.
getHits().empty())
341 filtered_identifications.push_back(temp_identification);
344 experiment[i].setPeptideIdentifications(filtered_identifications);
345 filtered_identifications.clear();
350 template <
class PeakT>
355 std::vector<ProteinIdentification> filtered_protein_identifications;
360 if (!temp_protein_identification.
getHits().empty())
362 filtered_protein_identifications.push_back(temp_protein_identification);
369 std::vector<PeptideIdentification> filtered_identifications;
371 for (
Size i = 0; i < experiment.
size(); i++)
373 for (
Size j = 0; j < experiment[i].getPeptideIdentifications().
size(); j++)
375 filterIdentificationsByBestNHits(experiment[i].getPeptideIdentifications()[j], n, temp_identification);
376 if (!temp_identification.
getHits().empty())
378 filtered_identifications.push_back(temp_identification);
381 experiment[i].setPeptideIdentifications(filtered_identifications);
382 filtered_identifications.clear();
387 template <
class PeakT>
389 const std::vector<FASTAFile::FASTAEntry>& proteins)
391 std::vector<PeptideIdentification> temp_identifications;
392 std::vector<PeptideIdentification> filtered_identifications;
395 for (
Size i = 0; i < experiment.
size(); i++)
397 if (experiment[i].getMSLevel() == 2)
399 temp_identifications = experiment[i].getPeptideIdentifications();
400 for (
Size j = 0; j < temp_identifications.size(); j++)
402 filterIdentificationsByProteins(temp_identifications[j], proteins, temp_identification);
403 if (!temp_identification.
getHits().empty())
405 filtered_identifications.push_back(temp_identification);
408 experiment[i].setPeptideIdentifications(filtered_identifications);
409 filtered_identifications.clear();
418 #endif // OPENMS_FILTERING_ID_IDFILTER_H
Representation of a protein identification run.
Definition: ProteinIdentification.h:61
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein ProteinIdentification vector
Size size() const
Definition: MSExperiment.h:117
const std::vector< ProteinIdentification > & getProteinIdentifications() const
returns a const reference to the protein ProteinIdentification vector
void filterIdentificationsByThreshold(const IdentificationType &identification, DoubleReal threshold_fraction, IdentificationType &filtered_identification)
filters a ProteinIdentification or PeptideIdentification by only allowing peptides/proteins which rea...
Definition: IDFilter.h:73
void filterIdentificationsByBestNHits(MSExperiment< PeakT > &experiment, Size n)
filters an MS/MS experiment corresponding to the best n hits for every spectrum
Definition: IDFilter.h:351
void filterIdentificationsByScores(MSExperiment< PeakT > &experiment, DoubleReal peptide_threshold_score, DoubleReal protein_threshold_score)
filters an MS/MS experiment corresponding to the threshold_fractions
Definition: IDFilter.h:314
void filterIdentificationsByBestNHits(const IdentificationType &identification, Size n, IdentificationType &filtered_identification)
filters a ProteinIdentification or PeptideIdentification corresponding to the score.
Definition: IDFilter.h:150
void filterIdentificationsByScore(const IdentificationType &identification, DoubleReal threshold_score, IdentificationType &filtered_identification)
filters a ProteinIdentification or PeptideIdentification corresponding to the threshold_score ...
Definition: IDFilter.h:107
const std::vector< PeptideHit > & getHits() const
returns the peptide hits
void filterIdentificationsByBestNToMHits(const IdentificationType &identification, Size n, Size m, IdentificationType &filtered_identification)
filters a ProteinIdentification or PeptideIdentification corresponding to the score.
Definition: IDFilter.h:188
Representation of a mass spectrometry experiment.
Definition: MSExperiment.h:68
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
void filterIdentificationsByThresholds(MSExperiment< PeakT > &experiment, DoubleReal peptide_threshold_fraction, DoubleReal protein_threshold_fraction)
filters an MS/MS experiment corresponding to the threshold_fractions
Definition: IDFilter.h:277
const std::vector< ProteinHit > & getHits() const
Returns the protein hits.
used to filter identifications by different criteria
Definition: IDFilter.h:61
int Int
Signed integer type.
Definition: Types.h:100
void filterIdentificationsByProteins(MSExperiment< PeakT > &experiment, const std::vector< FASTAFile::FASTAEntry > &proteins)
filters an MS/MS experiment corresponding to the given proteins
Definition: IDFilter.h:388
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63