| OpenMS 2.5.0

IDFilter.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Mathias Walzer $
32 // $Authors: Nico Pfeifer, Mathias Walzer, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/config.h>
38 #include <OpenMS/CHEMISTRY/ProteaseDigestion.h>
39 #include <OpenMS/CONCEPT/LogStream.h>
40 #include <OpenMS/FORMAT/FASTAFile.h>
41 #include <OpenMS/KERNEL/MSExperiment.h>
42 #include <OpenMS/KERNEL/StandardTypes.h>
43 #include <OpenMS/METADATA/PeptideIdentification.h>
44 #include <OpenMS/METADATA/PeptideEvidence.h>
45 #include <OpenMS/METADATA/ProteinIdentification.h>
46 #include <OpenMS/METADATA/ID/IdentificationData.h>
47
48 #include <algorithm>
49 #include <climits>
50 #include <vector>
51 #include <set>
52 #include <map>
53 #include <unordered_set>
54
55 namespace OpenMS
56 {
77 class OPENMS_DLLAPI IDFilter
78 {
79 public:
80
82 IDFilter();
83
85 virtual ~IDFilter();
86
88 typedef std::map<Int, PeptideHit*> ChargeToPepHitP;
89 typedef std::unordered_map<std::string, ChargeToPepHitP> SequenceToChargeToPepHitP;
90 typedef std::map<std::string, SequenceToChargeToPepHitP> RunToSequenceToChargeToPepHitP;
91
97
100 template <class HitType>
101 struct HasGoodScore
102 {
103 typedef HitType argument_type; // for use as a predicate
104
105 double score;
106 bool higher_score_better;
107
108 HasGoodScore(double score_, bool higher_score_better_) :
109 score(score_),
110 higher_score_better(higher_score_better_)
111 {}
112
113 bool operator()(const HitType& hit) const
114 {
115 if (higher_score_better)
116 {
117 return hit.getScore() >= score;
118 }
119 return hit.getScore() <= score;
120 }
121 };
122
128 template <class HitType>
129 struct HasMaxRank
130 {
131 typedef HitType argument_type; // for use as a predicate
132
133 Size rank;
134
135 HasMaxRank(Size rank_):
136 rank(rank_)
137 {
138 if (rank_ == 0)
139 {
140 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "The cut-off value for rank filtering must not be zero!");
141 }
142 }
143
144 bool operator()(const HitType& hit) const
145 {
146 Size hit_rank = hit.getRank();
147 if (hit_rank == 0)
148 {
149 throw Exception::MissingInformation(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No rank assigned to peptide or protein hit");
150 }
151 return hit_rank <= rank;
152 }
153 };
154
160 template <class HitType>
161 struct HasMetaValue
162 {
163 typedef HitType argument_type; // for use as a predicate
164
165 String key;
166 DataValue value;
167
168 HasMetaValue(const String& key_, const DataValue& value_):
169 key(key_),
170 value(value_)
171 {}
172
173 bool operator()(const HitType& hit) const
174 {
175 DataValue found = hit.getMetaValue(key);
176 if (found.isEmpty()) return false; // meta value "key" not set
177 if (value.isEmpty()) return true; // "key" is set, value doesn't matter
178 return found == value;
179 }
180 };
181
183 template <class HitType>
184 struct HasMaxMetaValue
185 {
186 typedef HitType argument_type; // for use as a predicate
187
188 String key;
189 double value;
190
191 HasMaxMetaValue(const String& key_, const double& value_):
192 key(key_),
193 value(value_)
194 {}
195
196 bool operator()(const HitType& hit) const
197 {
198 DataValue found = hit.getMetaValue(key);
199 if (found.isEmpty()) return false; // meta value "key" not set
200 return double(found) <= value;
201 }
202 };
203
205 template <class HitType>
206 struct HasDecoyAnnotation
207 {
208 typedef HitType argument_type; // for use as a predicate
209
210 struct HasMetaValue<HitType> target_decoy, is_decoy;
211
212 HasDecoyAnnotation():
213 target_decoy("target_decoy", "decoy"), is_decoy("isDecoy", "true")
214 {}
215
216 bool operator()(const HitType& hit) const
217 {
218 // @TODO: this could be done slightly more efficiently by returning
219 // false if the "target_decoy" meta value is "target" or "target+decoy",
220 // without checking for an "isDecoy" meta value in that case
221 return target_decoy(hit) || is_decoy(hit);
222 }
223 };
224
230 template <class HitType>
231 struct HasMatchingAccessionUnordered
232 {
233 typedef HitType argument_type; // for use as a predicate
234
235 const std::unordered_set<String>& accessions;
236
237 HasMatchingAccessionUnordered(const std::unordered_set<String>& accessions_):
238 accessions(accessions_)
239 {}
240
241 bool operator()(const PeptideHit& hit) const
242 {
243 for (const auto& it : hit.extractProteinAccessionsSet())
244 {
245 if (accessions.count(it) > 0) return true;
246 }
247 return false;
248 }
249
250 bool operator()(const ProteinHit& hit) const
251 {
252 return (accessions.count(hit.getAccession()) > 0);
253 }
254
255 bool operator()(const PeptideEvidence& evidence) const
256 {
257 return (accessions.count(evidence.getProteinAccession()) > 0);
258 }
259 };
260
266 template <class HitType>
267 struct HasMatchingAccession
268 {
269 typedef HitType argument_type; // for use as a predicate
270
271 const std::set<String>& accessions;
272
273 HasMatchingAccession(const std::set<String>& accessions_):
274 accessions(accessions_)
275 {}
276
277 bool operator()(const PeptideHit& hit) const
278 {
279 for (const auto& it : hit.extractProteinAccessionsSet())
280 {
281 if (accessions.count(it) > 0) return true;
282 }
283 return false;
284 }
285
286 bool operator()(const ProteinHit& hit) const
287 {
288 return (accessions.count(hit.getAccession()) > 0);
289 }
290
291 bool operator()(const PeptideEvidence& evidence) const
292 {
293 return (accessions.count(evidence.getProteinAccession()) > 0);
294 }
295 };
296
302 template <class HitType, class Entry>
303 struct GetMatchingItems
304 {
305 typedef HitType argument_type; // for use as a predicate
306 typedef std::map<String, Entry*> ItemMap;//Store pointers to avoid copying data
307 ItemMap items;
308
309 GetMatchingItems(std::vector<Entry>& records)
310 {
311 for(typename std::vector<Entry>::iterator rec_it = records.begin();
312 rec_it != records.end(); ++rec_it)
313 {
314 items[getKey(*rec_it)] = &(*rec_it);
315 }
316 }
317
318 GetMatchingItems(){}
319
320 const String& getKey(const FASTAFile::FASTAEntry& entry) const
321 {
322 return entry.identifier;
323 }
324
325 bool exists(const HitType& hit) const
326 {
327 return items.count(getHitKey(hit)) > 0;
328 }
329
330 const String& getHitKey(const PeptideEvidence& p) const
331 {
332 return p.getProteinAccession();
333 }
334
335 const Entry& getValue(const PeptideEvidence& evidence) const
336 {
337 if(!exists(evidence)){
338 throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Accession: '"+ getHitKey(evidence) + "'. peptide evidence accession not in data");
339 }
340 return *(items.find(getHitKey(evidence))->second);
341 }
342
343 };
344
346
347
353
356 struct HasMinPeptideLength;
357
359 struct HasMinCharge;
360
362 struct HasLowMZError;
363
369 struct HasMatchingModification;
370
376 struct HasMatchingSequence;
377
379 struct HasNoEvidence;
380
381
387 class PeptideDigestionFilter
388 {
389 private:
390 EnzymaticDigestion& digestion_;
391 Int min_cleavages_;
392 Int max_cleavages_;
393
394 public:
395 typedef PeptideHit argument_type;
396 PeptideDigestionFilter(EnzymaticDigestion& digestion, Int min, Int max) :
397 digestion_(digestion), min_cleavages_(min), max_cleavages_(max)
398 {}
399
400 static inline Int disabledValue(){ return -1; }
401
404 bool operator()(PeptideHit& p)
405 {
406 return digestion_.filterByMissedCleavages(
407 p.getSequence().toUnmodifiedString(),
408 [&](const Int missed_cleavages)
409 {
410
411 bool max_filter = max_cleavages_ != disabledValue() ?
412 missed_cleavages > max_cleavages_ : false;
413 bool min_filter = min_cleavages_ != disabledValue() ?
414 missed_cleavages < min_cleavages_ : false;
415 return max_filter || min_filter;
416 });
417 }
418
419 void filterPeptideSequences(std::vector<PeptideHit>& hits)
420 {
421 hits.erase(std::remove_if(hits.begin(), hits.end(), (*this)),
422 hits.end());
423 }
424
425 };
426
427
433 struct DigestionFilter
434 {
435 typedef PeptideEvidence argument_type;
436
437 // Build an accession index to avoid the linear search cost
438 GetMatchingItems<PeptideEvidence, FASTAFile::FASTAEntry>accession_resolver_;
439 ProteaseDigestion& digestion_;
440 bool ignore_missed_cleavages_;
441 bool methionine_cleavage_;
442
443 DigestionFilter(std::vector<FASTAFile::FASTAEntry>& entries,
444 ProteaseDigestion& digestion,
445 bool ignore_missed_cleavages,
446 bool methionine_cleavage) :
447 accession_resolver_(entries),
448 digestion_(digestion),
449 ignore_missed_cleavages_(ignore_missed_cleavages),
450 methionine_cleavage_(methionine_cleavage)
451 {}
452
453 bool operator()(const PeptideEvidence& evidence) const
454 {
455 if(!evidence.hasValidLimits())
456 {
457 OPENMS_LOG_WARN << "Invalid limits! Peptide '" << evidence.getProteinAccession() << "' not filtered" << std::endl;
458 return true;
459 }
460
461 if (accession_resolver_.exists(evidence))
462 {
463 return digestion_.isValidProduct(
464 AASequence::fromString(accession_resolver_.getValue(evidence).sequence),
465 evidence.getStart(), evidence.getEnd() - evidence.getStart(), ignore_missed_cleavages_, methionine_cleavage_);
466 }
467 else
468 {
469 if (evidence.getProteinAccession().empty())
470 {
471 OPENMS_LOG_WARN << "Peptide accession not available! Skipping Evidence." << std::endl;
472 }
473 else
474 {
475 OPENMS_LOG_WARN << "Peptide accession '" << evidence.getProteinAccession()
476 << "' not found in fasta file!" << std::endl;
477 }
478 return true;
479 }
480 }
481
482 void filterPeptideEvidences(std::vector<PeptideIdentification>& peptides)
483 {
484 IDFilter::FilterPeptideEvidences<IDFilter::DigestionFilter>(*this,peptides);
485 }
486
487 };
488
490
491
494
496 template <class IdentificationType>
497 struct HasNoHits
498 {
499 typedef IdentificationType argument_type; // for use as a predicate
500
501 bool operator()(const IdentificationType& id) const
502 {
503 return id.getHits().empty();
504 }
505 };
506
508
509
512
514 struct HasRTInRange;
515
517 struct HasMZInRange;
518
520
521
527
530 template <class Container, class Predicate>
531 static void removeMatchingItems(Container& items, const Predicate& pred)
532 {
533 items.erase(std::remove_if(items.begin(), items.end(), pred),
534 items.end());
535 }
536
538 template <class Container, class Predicate>
539 static void keepMatchingItems(Container& items, const Predicate& pred)
540 {
541 items.erase(std::remove_if(items.begin(), items.end(), std::not1(pred)),
542 items.end());
543 }
544
546 template <class IDContainer, class Predicate>
547 static void removeMatchingItemsUnroll(IDContainer& items, const Predicate& pred)
548 {
549 for (auto& item : items)
550 {
551 removeMatchingItems(item.getHits(), pred);
552 }
553 }
554
556 template <class IDContainer, class Predicate>
557 static void keepMatchingItemsUnroll(IDContainer& items, const Predicate& pred)
558 {
559 for (auto& item : items)
560 {
561 keepMatchingItems(item.getHits(), pred);
562 }
563 }
564
565 template <class MapType, class Predicate>
566 static void keepMatchingPeptideHits(MapType& prot_and_pep_ids, Predicate& pred)
567 {
568 for (auto& feat : prot_and_pep_ids)
569 {
570 keepMatchingItemsUnroll(feat.getPeptideIdentifications(), pred);
571 }
572 keepMatchingItemsUnroll(prot_and_pep_ids.getUnassignedPeptideIdentifications(), pred);
573 }
574
575 template <class MapType, class Predicate>
576 static void removeMatchingPeptideHits(MapType& prot_and_pep_ids, Predicate& pred)
577 {
578 for (auto& feat : prot_and_pep_ids)
579 {
580 removeMatchingItemsUnroll(feat.getPeptideIdentifications(), pred);
581 }
582 removeMatchingItemsUnroll(prot_and_pep_ids.getUnassignedPeptideIdentifications(), pred);
583 }
584
586
587
590
592 template <class IdentificationType>
593 static Size countHits(const std::vector<IdentificationType>& ids)
594 {
595 Size counter = 0;
596 for (typename std::vector<IdentificationType>::const_iterator id_it =
597 ids.begin(); id_it != ids.end(); ++id_it)
598 {
599 counter += id_it->getHits().size();
600 }
601 return counter;
602 }
603
616 template <class IdentificationType>
617 static bool getBestHit(
618 const std::vector<IdentificationType>& identifications,
619 bool assume_sorted, typename IdentificationType::HitType& best_hit)
620 {
621 if (identifications.empty()) return false;
622
623 typename std::vector<IdentificationType>::const_iterator best_id_it =
624 identifications.end();
625 typename std::vector<typename IdentificationType::HitType>::const_iterator
626 best_hit_it;
627
628 for (typename std::vector<IdentificationType>::const_iterator id_it =
629 identifications.begin(); id_it != identifications.end(); ++id_it)
630 {
631 if (id_it->getHits().empty()) continue;
632
633 if (best_id_it == identifications.end()) // no previous "best" hit
634 {
635 best_id_it = id_it;
636 best_hit_it = id_it->getHits().begin();
637 }
638 else if (best_id_it->getScoreType() != id_it->getScoreType())
639 {
640 throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Can't compare scores of different types", best_id_it->getScoreType() + "/" + id_it->getScoreType());
641 }
642
643 bool higher_better = best_id_it->isHigherScoreBetter();
644 for (typename std::vector<typename IdentificationType::HitType>::
645 const_iterator hit_it = id_it->getHits().begin(); hit_it !=
646 id_it->getHits().end(); ++hit_it)
647 {
648 if ((higher_better && (hit_it->getScore() >
649 best_hit_it->getScore())) ||
650 (!higher_better && (hit_it->getScore() <
651 best_hit_it->getScore())))
652 {
653 best_hit_it = hit_it;
654 }
655 if (assume_sorted) break; // only consider the first hit
656 }
657 }
658
659 if (best_id_it == identifications.end())
660 {
661 return false; // no hits in any IDs
662 }
663
664 best_hit = *best_hit_it;
665 return true;
666 }
667
675 static void extractPeptideSequences(
676 const std::vector<PeptideIdentification>& peptides,
677 std::set<String>& sequences, bool ignore_mods = false);
678
685 template<class EvidenceFilter>
686 static void FilterPeptideEvidences(
687 EvidenceFilter& filter,
688 std::vector<PeptideIdentification>& peptides)
689 {
690 for(std::vector<PeptideIdentification>::iterator pep_it = peptides.begin();
691 pep_it != peptides.end(); ++pep_it)
692 {
693 for(std::vector<PeptideHit>::iterator hit_it = pep_it->getHits().begin();
694 hit_it != pep_it->getHits().end(); ++hit_it )
695 {
696 std::vector<PeptideEvidence> evidences;
697 remove_copy_if(hit_it->getPeptideEvidences().begin(),
698 hit_it->getPeptideEvidences().end(),
699 back_inserter(evidences),
700 std::not1(filter));
701 hit_it->setPeptideEvidences(evidences);
702 }
703 }
704 }
705
707
708
711
713 template <class IdentificationType>
714 static void updateHitRanks(std::vector<IdentificationType>& ids)
715 {
716 for (typename std::vector<IdentificationType>::iterator it = ids.begin();
717 it != ids.end(); ++it)
718 {
719 it->assignRanks();
720 }
721 }
722
724 static void removeUnreferencedProteins(
725 std::vector<ProteinIdentification>& proteins,
726 const std::vector<PeptideIdentification>& peptides);
727
735 static void updateProteinReferences(
736 std::vector<PeptideIdentification>& peptides,
737 const std::vector<ProteinIdentification>& proteins,
738 bool remove_peptides_without_reference = false);
739
747 static void updateProteinReferences(
748 ConsensusMap& cmap,
749 bool remove_peptides_without_reference = false);
750
759 static bool updateProteinGroups(
760 std::vector<ProteinIdentification::ProteinGroup>& groups,
761 const std::vector<ProteinHit>& hits);
762
764
765
768
770 template <class IdentificationType>
771 static void removeEmptyIdentifications(std::vector<IdentificationType>& ids)
772 {
773 struct HasNoHits<IdentificationType> empty_filter;
774 removeMatchingItems(ids, empty_filter);
775 }
776
782 template <class IdentificationType>
783 static void filterHitsByScore(std::vector<IdentificationType>& ids,
784 double threshold_score)
785 {
786 for (typename std::vector<IdentificationType>::iterator id_it =
787 ids.begin(); id_it != ids.end(); ++id_it)
788 {
789 struct HasGoodScore<typename IdentificationType::HitType> score_filter(
790 threshold_score, id_it->isHigherScoreBetter());
791 keepMatchingItems(id_it->getHits(), score_filter);
792 }
793 }
794
800 template <class IdentificationType>
801 static void filterHitsByScore(IdentificationType& id,
802 double threshold_score)
803 {
804 struct HasGoodScore<typename IdentificationType::HitType> score_filter(
805 threshold_score, id->isHigherScoreBetter());
806 keepMatchingItems(id->getHits(), score_filter);
807 }
808
814 template <class IdentificationType>
815 static void keepNBestHits(std::vector<IdentificationType>& ids, Size n)
816 {
817 for (typename std::vector<IdentificationType>::iterator id_it =
818 ids.begin(); id_it != ids.end(); ++id_it)
819 {
820 id_it->sort();
821 if (n < id_it->getHits().size()) id_it->getHits().resize(n);
822 }
823 }
824
839 template <class IdentificationType>
840 static void filterHitsByRank(std::vector<IdentificationType>& ids,
841 Size min_rank, Size max_rank)
842 {
843 updateHitRanks(ids);
844 if (min_rank > 1)
845 {
846 struct HasMaxRank<typename IdentificationType::HitType>
847 rank_filter(min_rank - 1);
848 for (typename std::vector<IdentificationType>::iterator id_it =
849 ids.begin(); id_it != ids.end(); ++id_it)
850 {
851 removeMatchingItems(id_it->getHits(), rank_filter);
852 }
853 }
854 if (max_rank >= min_rank)
855 {
856 struct HasMaxRank<typename IdentificationType::HitType>
857 rank_filter(max_rank);
858 for (typename std::vector<IdentificationType>::iterator id_it =
859 ids.begin(); id_it != ids.end(); ++id_it)
860 {
861 keepMatchingItems(id_it->getHits(), rank_filter);
862 }
863 }
864 }
865
873 template <class IdentificationType>
874 static void removeDecoyHits(std::vector<IdentificationType>& ids)
875 {
876 struct HasDecoyAnnotation<typename IdentificationType::HitType>
877 decoy_filter;
878 for (typename std::vector<IdentificationType>::iterator id_it =
879 ids.begin(); id_it != ids.end(); ++id_it)
880 {
881 removeMatchingItems(id_it->getHits(), decoy_filter);
882 }
883 }
884
892 template <class IdentificationType>
893 static void removeHitsMatchingProteins(std::vector<IdentificationType>& ids,
894 const std::set<String> accessions)
895 {
896 struct HasMatchingAccession<typename IdentificationType::HitType> acc_filter(accessions);
897 for (auto& id_it : ids)
898 {
899 removeMatchingItems(id_it.getHits(), acc_filter);
900 }
901 }
902
910 template <class IdentificationType>
911 static void keepHitsMatchingProteins(std::vector<IdentificationType>& ids,
912 const std::set<String>& accessions)
913 {
914 struct HasMatchingAccession<typename IdentificationType::HitType> acc_filter(accessions);
915 for (auto& id_it : ids)
916 {
917 keepMatchingItems(id_it.getHits(), acc_filter);
918 }
919 }
920
922
923
926
933 static void keepBestPeptideHits(
934 std::vector<PeptideIdentification>& peptides, bool strict = false);
935
944 static void filterPeptidesByLength(
945 std::vector<PeptideIdentification>& peptides, Size min_length,
946 Size max_length = UINT_MAX);
947
956 static void filterPeptidesByCharge(
957 std::vector<PeptideIdentification>& peptides, Int min_charge,
958 Int max_charge);
959
961 static void filterPeptidesByRT(std::vector<PeptideIdentification>& peptides,
962 double min_rt, double max_rt);
963
965 static void filterPeptidesByMZ(std::vector<PeptideIdentification>& peptides,
966 double min_mz, double max_mz);
967
979 static void filterPeptidesByMZError(
980 std::vector<PeptideIdentification>& peptides, double mass_error,
981 bool unit_ppm);
982
983
990 template <class Filter>
991 static void filterPeptideEvidences(
992 Filter& filter,
993 std::vector<PeptideIdentification>& peptides);
994
1006 static void filterPeptidesByRTPredictPValue(
1007 std::vector<PeptideIdentification>& peptides,
1008 const String& metavalue_key, double threshold = 0.05);
1009
1011 static void removePeptidesWithMatchingModifications(
1012 std::vector<PeptideIdentification>& peptides,
1013 const std::set<String>& modifications);
1014
1016 static void keepPeptidesWithMatchingModifications(
1017 std::vector<PeptideIdentification>& peptides,
1018 const std::set<String>& modifications);
1019
1027 static void removePeptidesWithMatchingSequences(
1028 std::vector<PeptideIdentification>& peptides,
1029 const std::vector<PeptideIdentification>& bad_peptides,
1030 bool ignore_mods = false);
1031
1039 static void keepPeptidesWithMatchingSequences(
1040 std::vector<PeptideIdentification>& peptides,
1041 const std::vector<PeptideIdentification>& good_peptides,
1042 bool ignore_mods = false);
1043
1045 static void keepUniquePeptidesPerProtein(std::vector<PeptideIdentification>&
1046 peptides);
1047
1053 static void removeDuplicatePeptideHits(std::vector<PeptideIdentification>&
1054 peptides, bool seq_only = false);
1055
1057
1058
1061
1063 static void filterHitsByScore(PeakMap& experiment,
1064 double peptide_threshold_score,
1065 double protein_threshold_score)
1066 {
1067 // filter protein hits:
1068 filterHitsByScore(experiment.getProteinIdentifications(),
1069 protein_threshold_score);
1070 // don't remove empty protein IDs - they contain search meta data and may
1071 // be referenced by peptide IDs (via run ID)
1072
1073 // filter peptide hits:
1074 for (PeakMap::Iterator exp_it = experiment.begin();
1075 exp_it != experiment.end(); ++exp_it)
1076 {
1077 filterHitsByScore(exp_it->getPeptideIdentifications(),
1078 peptide_threshold_score);
1079 removeEmptyIdentifications(exp_it->getPeptideIdentifications());
1080 updateProteinReferences(exp_it->getPeptideIdentifications(),
1081 experiment.getProteinIdentifications());
1082 }
1083 // @TODO: remove proteins that aren't referenced by peptides any more?
1084 }
1085
1087 static void keepNBestHits(PeakMap& experiment, Size n)
1088 {
1089 // don't filter the protein hits by "N best" here - filter the peptides
1090 // and update the protein hits!
1091 std::vector<PeptideIdentification> all_peptides; // IDs from all spectra
1092
1093 // filter peptide hits:
1094 for (PeakMap::Iterator exp_it = experiment.begin();
1095 exp_it != experiment.end(); ++exp_it)
1096 {
1097 std::vector<PeptideIdentification>& peptides =
1098 exp_it->getPeptideIdentifications();
1099 keepNBestHits(peptides, n);
1100 removeEmptyIdentifications(peptides);
1101 updateProteinReferences(peptides,
1102 experiment.getProteinIdentifications());
1103 all_peptides.insert(all_peptides.end(), peptides.begin(),
1104 peptides.end());
1105 }
1106 // update protein hits:
1107 removeUnreferencedProteins(experiment.getProteinIdentifications(),
1108 all_peptides);
1109 }
1110
1112 template <class MapType>
1113 static void keepNBestPeptideHits(MapType& map, Size n)
1114 {
1115 // The rank predicate needs annotated ranks, not sure if they are always updated. Use the following instead,
1116 // which sorts Hits first.
1117 for (auto& feat : map)
1118 {
1119 keepNBestHits(feat.getPeptideIdentifications(), n);
1120 }
1121 keepNBestHits(map.getUnassignedPeptideIdentifications(), n);
1122 }
1123
1124 template <class MapType>
1125 static void removeEmptyIdentifications(MapType& prot_and_pep_ids)
1126 {
1127 removeMatchingPeptideHits(prot_and_pep_ids, HasNoHits<PeptideHit>());
1128 }
1129
1131 static void keepBestPerPeptide(std::vector<PeptideIdentification>& pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1132 {
1133 annotateBestPerPeptide(pep_ids, ignore_mods, ignore_charges, nr_best_spectrum);
1134 HasMetaValue<PeptideHit> best_per_peptide{"best_per_peptide", 1};
1135 keepMatchingItemsUnroll(pep_ids, best_per_peptide);
1136 }
1137
1138 static void keepBestPerPeptidePerRun(std::vector<ProteinIdentification>& prot_ids, std::vector<PeptideIdentification>& pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1139 {
1140 annotateBestPerPeptidePerRun(prot_ids, pep_ids, ignore_mods, ignore_charges, nr_best_spectrum);
1141 HasMetaValue<PeptideHit> best_per_peptide{"best_per_peptide", 1};
1142 keepMatchingItemsUnroll(pep_ids, best_per_peptide);
1143 }
1144
1145 template <class MapType>
1146 static void keepBestPerPeptidePerRun(MapType& prot_and_pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1147 {
1148 const auto& prot_ids = prot_and_pep_ids.getProteinIdentifications();
1149
1150 RunToSequenceToChargeToPepHitP best_peps_per_run;
1151 for (const auto& idrun : prot_ids)
1152 {
1153 best_peps_per_run[idrun.getIdentifier()] = SequenceToChargeToPepHitP();
1154 }
1155
1156 for (auto& feat : prot_and_pep_ids)
1157 {
1158 annotateBestPerPeptidePerRunWithData(best_peps_per_run, feat.getPeptideIdentifications(), ignore_mods, ignore_charges, nr_best_spectrum);
1159 }
1160
1161 annotateBestPerPeptidePerRunWithData(best_peps_per_run, prot_and_pep_ids.getUnassignedPeptideIdentifications(), ignore_mods, ignore_charges, nr_best_spectrum);
1162
1163 HasMetaValue<PeptideHit> best_per_peptide{"best_per_peptide", 1};
1164 keepMatchingPeptideHits(prot_and_pep_ids, best_per_peptide);
1165 }
1166
1169 static void annotateBestPerPeptidePerRun(const std::vector<ProteinIdentification>& prot_ids, std::vector<PeptideIdentification>& pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1170 {
1171 RunToSequenceToChargeToPepHitP best_peps_per_run;
1172 for (const auto& id : prot_ids)
1173 {
1174 best_peps_per_run[id.getIdentifier()] = SequenceToChargeToPepHitP();
1175 }
1176 annotateBestPerPeptidePerRunWithData(best_peps_per_run, pep_ids, ignore_mods, ignore_charges, nr_best_spectrum);
1177 }
1178
1182 static void annotateBestPerPeptidePerRunWithData(RunToSequenceToChargeToPepHitP& best_peps_per_run, std::vector<PeptideIdentification>& pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1183 {
1184 for (auto &pep : pep_ids)
1185 {
1186 SequenceToChargeToPepHitP& best_pep = best_peps_per_run[pep.getIdentifier()];
1187 annotateBestPerPeptideWithData(best_pep, pep, ignore_mods, ignore_charges, nr_best_spectrum);
1188 }
1189 }
1190
1194 static void annotateBestPerPeptide(std::vector<PeptideIdentification>& pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1195 {
1196 SequenceToChargeToPepHitP best_pep;
1197 for (auto& pep : pep_ids)
1198 {
1199 annotateBestPerPeptideWithData(best_pep, pep, ignore_mods, ignore_charges, nr_best_spectrum);
1200 }
1201 }
1202
1207 static void annotateBestPerPeptideWithData(SequenceToChargeToPepHitP& best_pep, PeptideIdentification& pep, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
1208 {
1209 bool higher_score_better = pep.isHigherScoreBetter();
1210 //make sure that first = best hit
1211 pep.sort();
1212
1213 auto pepIt = pep.getHits().begin();
1214 auto pepItEnd = nr_best_spectrum == 0 || pep.getHits().size() <= nr_best_spectrum ? pep.getHits().end() : pep.getHits().begin() + nr_best_spectrum;
1215 for (; pepIt != pepItEnd; ++pepIt)
1216 {
1217 PeptideHit &hit = *pepIt;
1218
1219 String lookup_seq;
1220 if (ignore_mods)
1221 {
1222 lookup_seq = hit.getSequence().toUnmodifiedString();
1223 }
1224 else
1225 {
1226 lookup_seq = hit.getSequence().toString();
1227 }
1228
1229 int lookup_charge = 0;
1230 if (!ignore_charges)
1231 {
1232 lookup_charge = hit.getCharge();
1233 }
1234
1235 // try to insert
1236 auto it_inserted = best_pep.emplace(std::move(lookup_seq), ChargeToPepHitP());
1237 auto it_inserted_chg = it_inserted.first->second.emplace(lookup_charge, &hit);
1238
1239 PeptideHit* &p = it_inserted_chg.first->second; //now this gets either the old one if already present, or this
1240 if (!it_inserted_chg.second) //was already present -> possibly update
1241 {
1242 if (
1243 (higher_score_better && (hit.getScore() > p->getScore())) ||
1244 (!higher_score_better && (hit.getScore() < p->getScore()))
1245 )
1246 {
1247 p->setMetaValue("best_per_peptide", 0);
1248 hit.setMetaValue("best_per_peptide", 1);
1249 p = &hit;
1250 }
1251 else //note that this was def. not the best
1252 {
1253 // TODO if it is only about filtering, we can omit writing this metavalue (absence = false)
1254 hit.setMetaValue("best_per_peptide", 0);
1255 }
1256 }
1257 else //newly inserted -> first for that sequence (and optionally charge)
1258 {
1259 hit.setMetaValue("best_per_peptide", 1);
1260 }
1261 }
1262 }
1263
1265 static void keepHitsMatchingProteins(
1266 PeakMap& experiment,
1267 const std::vector<FASTAFile::FASTAEntry>& proteins)
1268 {
1269 std::set<String> accessions;
1270 for (std::vector<FASTAFile::FASTAEntry>::const_iterator it =
1271 proteins.begin(); it != proteins.end(); ++it)
1272 {
1273 accessions.insert(it->identifier);
1274 }
1275
1276 // filter protein hits:
1277 keepHitsMatchingProteins(experiment.getProteinIdentifications(),
1278 accessions);
1279 updateHitRanks(experiment.getProteinIdentifications());
1280
1281 // filter peptide hits:
1282 for (PeakMap::Iterator exp_it = experiment.begin();
1283 exp_it != experiment.end(); ++exp_it)
1284 {
1285 if (exp_it->getMSLevel() == 2)
1286 {
1287 keepHitsMatchingProteins(exp_it->getPeptideIdentifications(),
1288 accessions);
1289 removeEmptyIdentifications(exp_it->getPeptideIdentifications());
1290 updateHitRanks(exp_it->getPeptideIdentifications());
1291 }
1292 }
1293 }
1294
1296
1297
1300 static void keepBestMatchPerQuery(
1301 IdentificationData& id_data,
1302 IdentificationData::ScoreTypeRef score_ref);
1303
1304 static void filterQueryMatchesByScore(
1305 IdentificationData& id_data,
1306 IdentificationData::ScoreTypeRef score_ref, double cutoff);
1307
1308 static void removeDecoys(IdentificationData& id_data);
1310
1311 };
1312
1313 } // namespace OpenMS
1314
OpenMS::IDFilter::HasMetaValue::operator()
bool operator()(const HitType &hit) const
Definition: IDFilter.h:173
OpenMS::IDFilter::PeptideDigestionFilter::operator()
bool operator()(PeptideHit &p)
Definition: IDFilter.h:404
ProteinIdentification.h
OpenMS::IDFilter::filterHitsByRank
static void filterHitsByRank(std::vector< IdentificationType > &ids, Size min_rank, Size max_rank)
Filters peptide or protein identifications according to the ranking of the hits.
Definition: IDFilter.h:840
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::DataValue
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:56
OpenMS::IDFilter::HasMatchingAccessionUnordered::accessions
const std::unordered_set< String > & accessions
Definition: IDFilter.h:235
OpenMS::IDFilter::filterHitsByScore
static void filterHitsByScore(PeakMap &experiment, double peptide_threshold_score, double protein_threshold_score)
Filters an MS/MS experiment according to score thresholds.
Definition: IDFilter.h:1063
OpenMS::IDFilter::HasMaxMetaValue::value
double value
Definition: IDFilter.h:189
OpenMS::IDFilter::updateHitRanks
static void updateHitRanks(std::vector< IdentificationType > &ids)
Updates the hit ranks on all peptide or protein IDs.
Definition: IDFilter.h:714
OpenMS::IDFilter::HasMatchingAccession::accessions
const std::set< String > & accessions
Definition: IDFilter.h:271
OpenMS::IDFilter::filterHitsByScore
static void filterHitsByScore(std::vector< IdentificationType > &ids, double threshold_score)
Filters peptide or protein identifications according to the score of the hits.
Definition: IDFilter.h:783
OpenMS::IDFilter::removeHitsMatchingProteins
static void removeHitsMatchingProteins(std::vector< IdentificationType > &ids, const std::set< String > accessions)
Filters peptide or protein identifications according to the given proteins (negative).
Definition: IDFilter.h:893
OpenMS::IDFilter::PeptideDigestionFilter::disabledValue
static Int disabledValue()
Definition: IDFilter.h:400
OpenMS::IDFilter::PeptideDigestionFilter::min_cleavages_
Int min_cleavages_
Definition: IDFilter.h:391
OpenMS::IDFilter::annotateBestPerPeptideWithData
static void annotateBestPerPeptideWithData(SequenceToChargeToPepHitP &best_pep, PeptideIdentification &pep, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Definition: IDFilter.h:1207
OpenMS::IDFilter::FilterPeptideEvidences
static void FilterPeptideEvidences(EvidenceFilter &filter, std::vector< PeptideIdentification > &peptides)
remove peptide evidences based on a filter
Definition: IDFilter.h:686
OpenMS::PeptideHit::getSequence
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
ProteaseDigestion.h
OpenMS::ProteinHit::getAccession
const String & getAccession() const
returns the accession of the protein
OpenMS::IDFilter::keepNBestHits
static void keepNBestHits(PeakMap &experiment, Size n)
Filters an MS/MS experiment by keeping the N best peptide hits for every spectrum.
Definition: IDFilter.h:1087
OpenMS::PeptideIdentification::isHigherScoreBetter
bool isHigherScoreBetter() const
returns the peptide score orientation
OpenMS::IDFilter::HasMaxMetaValue::operator()
bool operator()(const HitType &hit) const
Definition: IDFilter.h:196
OpenMS::IDFilter::HasMaxRank::HasMaxRank
HasMaxRank(Size rank_)
Definition: IDFilter.h:135
OpenMS::IDFilter::HasMatchingAccessionUnordered::operator()
bool operator()(const ProteinHit &hit) const
Definition: IDFilter.h:250
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::IDFilter::keepMatchingItemsUnroll
static void keepMatchingItemsUnroll(IDContainer &items, const Predicate &pred)
Keep Hit items that satisfy a condition in one of our ID containers (e.g. vector of Peptide or Protei...
Definition: IDFilter.h:557
OpenMS::IDFilter::HasMetaValue::key
String key
Definition: IDFilter.h:165
OpenMS::IDFilter::HasGoodScore
Is the score of this hit at least as good as the given value?
Definition: IDFilter.h:101
OpenMS::AASequence::toUnmodifiedString
String toUnmodifiedString() const
returns the peptide as string without any modifications or (e.g., "PEPTIDER")
OpenMS::IDFilter::GetMatchingItems::ItemMap
std::map< String, Entry * > ItemMap
Definition: IDFilter.h:306
OpenMS::IDFilter::HasNoHits::operator()
bool operator()(const IdentificationType &id) const
Definition: IDFilter.h:501
OpenMS::IDFilter::GetMatchingItems::items
ItemMap items
Definition: IDFilter.h:307
OpenMS::IDFilter::removeEmptyIdentifications
static void removeEmptyIdentifications(std::vector< IdentificationType > &ids)
Removes peptide or protein identifications that have no hits in them.
Definition: IDFilter.h:771
OpenMS::IDFilter::countHits
static Size countHits(const std::vector< IdentificationType > &ids)
Returns the total number of peptide/protein hits in a vector of peptide/protein identifications.
Definition: IDFilter.h:593
OpenMS::IDFilter::HasMatchingAccessionUnordered::operator()
bool operator()(const PeptideEvidence &evidence) const
Definition: IDFilter.h:255
OpenMS::AASequence::toString
String toString() const
returns the peptide as string with modifications embedded in brackets
OpenMS::IDFilter::PeptideDigestionFilter::argument_type
PeptideHit argument_type
Definition: IDFilter.h:395
OpenMS::ProteinHit
Representation of a protein hit.
Definition: ProteinHit.h:57
OpenMS::IDFilter::HasMetaValue::value
DataValue value
Definition: IDFilter.h:166
OpenMS::IDFilter::HasGoodScore::operator()
bool operator()(const HitType &hit) const
Definition: IDFilter.h:113
StandardTypes.h
OpenMS::IDFilter::HasMaxMetaValue::argument_type
HitType argument_type
Definition: IDFilter.h:186
OpenMS::IDFilter::GetMatchingItems::getKey
const String & getKey(const FASTAFile::FASTAEntry &entry) const
Definition: IDFilter.h:320
OpenMS::IdentificationDataInternal::IteratorWrapper
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:43
OpenMS::IDFilter::annotateBestPerPeptidePerRun
static void annotateBestPerPeptidePerRun(const std::vector< ProteinIdentification > &prot_ids, std::vector< PeptideIdentification > &pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Definition: IDFilter.h:1169
OpenMS::IDFilter::keepMatchingPeptideHits
static void keepMatchingPeptideHits(MapType &prot_and_pep_ids, Predicate &pred)
Definition: IDFilter.h:566
OpenMS::IDFilter::HasMaxMetaValue::key
String key
Definition: IDFilter.h:188
OpenMS::PeptideEvidence
Representation of a peptide evidence.
Definition: PeptideEvidence.h:50
OpenMS::IDFilter::PeptideDigestionFilter::filterPeptideSequences
void filterPeptideSequences(std::vector< PeptideHit > &hits)
Definition: IDFilter.h:419
OpenMS::IDFilter::GetMatchingItems::getValue
const Entry & getValue(const PeptideEvidence &evidence) const
Definition: IDFilter.h:335
OpenMS::IDFilter::HasMatchingAccessionUnordered
Given a list of protein accessions, do any occur in the annotation(s) of this hit?
Definition: IDFilter.h:231
OpenMS::MSExperiment::Iterator
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:111
OpenMS::IDFilter::keepNBestPeptideHits
static void keepNBestPeptideHits(MapType &map, Size n)
Filters a Consensus/FeatureMap by keeping the N best peptide hits for every spectrum.
Definition: IDFilter.h:1113
OpenMS::IDFilter::HasMatchingAccession::operator()
bool operator()(const PeptideHit &hit) const
Definition: IDFilter.h:277
OpenMS::ProteaseDigestion
Class for the enzymatic digestion of proteins.
Definition: ProteaseDigestion.h:60
OpenMS::IDFilter::getBestHit
static bool getBestHit(const std::vector< IdentificationType > &identifications, bool assume_sorted, typename IdentificationType::HitType &best_hit)
Finds the best-scoring hit in a vector of peptide or protein identifications.
Definition: IDFilter.h:617
OpenMS::IDFilter::PeptideDigestionFilter::digestion_
EnzymaticDigestion & digestion_
Definition: IDFilter.h:390
OpenMS::IDFilter::GetMatchingItems::exists
bool exists(const HitType &hit) const
Definition: IDFilter.h:325
OpenMS::IDFilter::HasMaxRank::operator()
bool operator()(const HitType &hit) const
Definition: IDFilter.h:144
OpenMS::IDFilter::removeMatchingItemsUnroll
static void removeMatchingItemsUnroll(IDContainer &items, const Predicate &pred)
Remove Hit items that satisfy a condition in one of our ID containers (e.g. vector of Peptide or Prot...
Definition: IDFilter.h:547
PeptideEvidence.h
OpenMS::IDFilter::HasMatchingAccession::HasMatchingAccession
HasMatchingAccession(const std::set< String > &accessions_)
Definition: IDFilter.h:273
OpenMS::IDFilter::HasMaxMetaValue::HasMaxMetaValue
HasMaxMetaValue(const String &key_, const double &value_)
Definition: IDFilter.h:191
OpenMS::PeptideEvidence::getStart
Int getStart() const
get the position in the protein (starting at 0 for the N-terminus). If not available UNKNOWN_POSITION...
OpenMS::IDFilter::RunToSequenceToChargeToPepHitP
std::map< std::string, SequenceToChargeToPepHitP > RunToSequenceToChargeToPepHitP
Definition: IDFilter.h:90
OpenMS::PeptideEvidence::getEnd
Int getEnd() const
get the position of the last AA of the peptide in protein coordinates (starting at 0 for the N-termin...
OPENMS_LOG_WARN
#define OPENMS_LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged...
Definition: LogStream.h:460
IdentificationData.h
OpenMS::IDFilter::removeEmptyIdentifications
static void removeEmptyIdentifications(MapType &prot_and_pep_ids)
Definition: IDFilter.h:1125
OpenMS::IDFilter::DigestionFilter::argument_type
PeptideEvidence argument_type
Definition: IDFilter.h:435
OpenMS::IDFilter::HasMaxRank::argument_type
HitType argument_type
Definition: IDFilter.h:131
OpenMS::IDFilter::HasMaxRank::rank
Size rank
Definition: IDFilter.h:133
FASTAFile.h
OpenMS::ProteaseDigestion::isValidProduct
bool isValidProduct(const String &protein, int pep_pos, int pep_length, bool ignore_missed_cleavages=true, bool allow_nterm_protein_cleavage=false, bool allow_random_asp_pro_cleavage=false) const
Variant of EnzymaticDigestion::isValidProduct() with support for n-term protein cleavage and random D...
OpenMS::EnzymaticDigestion::filterByMissedCleavages
bool filterByMissedCleavages(const String &sequence, std::function< bool(const Int)> filter) const
Filter based on the number of missed cleavages.
OpenMS::EnzymaticDigestion
Class for the enzymatic digestion of sequences.
Definition: EnzymaticDigestion.h:62
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:347
OpenMS::IDFilter::HasMetaValue
Is a meta value with given key and value set on this hit?
Definition: IDFilter.h:161
OpenMS::IDFilter::GetMatchingItems::GetMatchingItems
GetMatchingItems(std::vector< Entry > &records)
Definition: IDFilter.h:309
OpenMS::IDFilter
Collection of functions for filtering peptide and protein identifications.
Definition: IDFilter.h:77
PeptideIdentification.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::ExperimentalSettings::getProteinIdentifications
const std::vector< ProteinIdentification > & getProteinIdentifications() const
returns a const reference to the protein ProteinIdentification vector
OpenMS::IDFilter::HasGoodScore::argument_type
HitType argument_type
Definition: IDFilter.h:103
OpenMS::IDFilter::PeptideDigestionFilter::PeptideDigestionFilter
PeptideDigestionFilter(EnzymaticDigestion &digestion, Int min, Int max)
Definition: IDFilter.h:396
OpenMS::IDFilter::HasGoodScore::score
double score
Definition: IDFilter.h:105
OpenMS::IDFilter::PeptideDigestionFilter::max_cleavages_
Int max_cleavages_
Definition: IDFilter.h:392
OpenMS::IDFilter::HasMatchingAccession::argument_type
HitType argument_type
Definition: IDFilter.h:269
MSExperiment.h
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:54
OpenMS::Exception::MissingInformation
Not all required information provided.
Definition: Exception.h:195
OpenMS::IDFilter::HasMatchingAccession::operator()
bool operator()(const ProteinHit &hit) const
Definition: IDFilter.h:286
OpenMS::IDFilter::keepMatchingItems
static void keepMatchingItems(Container &items, const Predicate &pred)
Keep items that satisfy a condition in a container (e.g. vector), removing all others.
Definition: IDFilter.h:539
OpenMS::IDFilter::DigestionFilter::accession_resolver_
GetMatchingItems< PeptideEvidence, FASTAFile::FASTAEntry > accession_resolver_
Definition: IDFilter.h:438
LogStream.h
OpenMS::FASTAFile::FASTAEntry
FASTA entry type (identifier, description and sequence)
Definition: FASTAFile.h:76
OpenMS::IDFilter::GetMatchingItems
Builds a map index of data that have a String index to find matches and return the objects...
Definition: IDFilter.h:303
OpenMS::IDFilter::GetMatchingItems::getHitKey
const String & getHitKey(const PeptideEvidence &p) const
Definition: IDFilter.h:330
OpenMS::IDFilter::HasDecoyAnnotation::HasDecoyAnnotation
HasDecoyAnnotation()
Definition: IDFilter.h:212
OpenMS::IDFilter::HasDecoyAnnotation
Is this a decoy hit?
Definition: IDFilter.h:206
OpenMS::IDFilter::HasMatchingAccession::operator()
bool operator()(const PeptideEvidence &evidence) const
Definition: IDFilter.h:291
OpenMS::IDFilter::HasGoodScore::HasGoodScore
HasGoodScore(double score_, bool higher_score_better_)
Definition: IDFilter.h:108
OpenMS::IDFilter::SequenceToChargeToPepHitP
std::unordered_map< std::string, ChargeToPepHitP > SequenceToChargeToPepHitP
Definition: IDFilter.h:89
OpenMS::Exception::InvalidValue
Invalid value exception.
Definition: Exception.h:335
OpenMS::IDFilter::keepBestPerPeptidePerRun
static void keepBestPerPeptidePerRun(std::vector< ProteinIdentification > &prot_ids, std::vector< PeptideIdentification > &pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Definition: IDFilter.h:1138
OpenMS::IDFilter::HasMaxRank
Is the rank of this hit below or at the given cut-off?
Definition: IDFilter.h:129
OpenMS::IDFilter::HasMatchingAccessionUnordered::argument_type
HitType argument_type
Definition: IDFilter.h:233
OpenMS::IDFilter::HasDecoyAnnotation::argument_type
HitType argument_type
Definition: IDFilter.h:208
OpenMS::Exception::IllegalArgument
A method or algorithm argument contains illegal values.
Definition: Exception.h:648
OpenMS::IDFilter::DigestionFilter::DigestionFilter
DigestionFilter(std::vector< FASTAFile::FASTAEntry > &entries, ProteaseDigestion &digestion, bool ignore_missed_cleavages, bool methionine_cleavage)
Definition: IDFilter.h:443
OpenMS::IDFilter::DigestionFilter::ignore_missed_cleavages_
bool ignore_missed_cleavages_
Definition: IDFilter.h:440
OpenMS::IDFilter::annotateBestPerPeptide
static void annotateBestPerPeptide(std::vector< PeptideIdentification > &pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Definition: IDFilter.h:1194
double
OpenMS::FASTAFile::FASTAEntry::identifier
String identifier
Definition: FASTAFile.h:78
OpenMS::IDFilter::HasMatchingAccessionUnordered::operator()
bool operator()(const PeptideHit &hit) const
Definition: IDFilter.h:241
OpenMS::PeptideHit::getCharge
Int getCharge() const
returns the charge of the peptide
OpenMS::IDFilter::DigestionFilter::digestion_
ProteaseDigestion & digestion_
Definition: IDFilter.h:439
OpenMS::IDFilter::DigestionFilter
Is peptide evidence digestion product of some protein.
Definition: IDFilter.h:433
OpenMS::IDFilter::keepBestPerPeptide
static void keepBestPerPeptide(std::vector< PeptideIdentification > &pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Filters PeptideHits from PeptideIdentification by keeping only the best peptide hits for every peptid...
Definition: IDFilter.h:1131
OpenMS::IDFilter::keepHitsMatchingProteins
static void keepHitsMatchingProteins(std::vector< IdentificationType > &ids, const std::set< String > &accessions)
Filters peptide or protein identifications according to the given proteins (positive).
Definition: IDFilter.h:911
OpenMS::IDFilter::GetMatchingItems::GetMatchingItems
GetMatchingItems()
Definition: IDFilter.h:318
OpenMS::IDFilter::HasMatchingAccessionUnordered::HasMatchingAccessionUnordered
HasMatchingAccessionUnordered(const std::unordered_set< String > &accessions_)
Definition: IDFilter.h:237
OpenMS::PeptideIdentification::getHits
const std::vector< PeptideHit > & getHits() const
returns the peptide hits as const
OpenMS::IDFilter::HasMatchingAccession
Given a list of protein accessions, do any occur in the annotation(s) of this hit?
Definition: IDFilter.h:267
OpenMS::PeptideIdentification
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:62
int
OpenMS::IDFilter::HasMetaValue::HasMetaValue
HasMetaValue(const String &key_, const DataValue &value_)
Definition: IDFilter.h:168
OpenMS::IDFilter::removeMatchingPeptideHits
static void removeMatchingPeptideHits(MapType &prot_and_pep_ids, Predicate &pred)
Definition: IDFilter.h:576
OpenMS::IDFilter::HasMaxMetaValue
Does a meta value of this hit have at most the given value?
Definition: IDFilter.h:184
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:79
OpenMS::MSExperiment::begin
Iterator begin()
Definition: MSExperiment.h:157
OpenMS::IDFilter::DigestionFilter::filterPeptideEvidences
void filterPeptideEvidences(std::vector< PeptideIdentification > &peptides)
Definition: IDFilter.h:482
OpenMS::PeptideHit::extractProteinAccessionsSet
std::set< String > extractProteinAccessionsSet() const
extracts the set of non-empty protein accessions from peptide evidences
OpenMS::IDFilter::keepBestPerPeptidePerRun
static void keepBestPerPeptidePerRun(MapType &prot_and_pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Definition: IDFilter.h:1146
OpenMS::IDFilter::removeMatchingItems
static void removeMatchingItems(Container &items, const Predicate &pred)
Remove items that satisfy a condition from a container (e.g. vector)
Definition: IDFilter.h:531
OpenMS::IDFilter::annotateBestPerPeptidePerRunWithData
static void annotateBestPerPeptidePerRunWithData(RunToSequenceToChargeToPepHitP &best_peps_per_run, std::vector< PeptideIdentification > &pep_ids, bool ignore_mods, bool ignore_charges, Size nr_best_spectrum)
Definition: IDFilter.h:1182
OpenMS::IDFilter::HasNoHits::argument_type
IdentificationType argument_type
Definition: IDFilter.h:499
OpenMS::IDFilter::HasGoodScore::higher_score_better
bool higher_score_better
Definition: IDFilter.h:106
OpenMS::IDFilter::DigestionFilter::methionine_cleavage_
bool methionine_cleavage_
Definition: IDFilter.h:441
OpenMS::IDFilter::HasMetaValue::argument_type
HitType argument_type
Definition: IDFilter.h:163
OpenMS::MetaInfoInterface::setMetaValue
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
OpenMS::PeptideEvidence::hasValidLimits
bool hasValidLimits() const
start and end numbers in evidence represent actual numeric indices
OpenMS::IDFilter::HasDecoyAnnotation::operator()
bool operator()(const HitType &hit) const
Definition: IDFilter.h:216
OpenMS::IDFilter::PeptideDigestionFilter
Filter Peptide Hit by its digestion product.
Definition: IDFilter.h:387
OpenMS::MSExperiment::end
Iterator end()
Definition: MSExperiment.h:167
OpenMS::IDFilter::keepHitsMatchingProteins
static void keepHitsMatchingProteins(PeakMap &experiment, const std::vector< FASTAFile::FASTAEntry > &proteins)
Filters an MS/MS experiment according to the given proteins.
Definition: IDFilter.h:1265
OpenMS::PeptideIdentification::sort
void sort()
Sorts the hits by score.
OpenMS::IDFilter::ChargeToPepHitP
std::map< Int, PeptideHit * > ChargeToPepHitP
Typedefs.
Definition: IDFilter.h:88
OpenMS::IDFilter::DigestionFilter::operator()
bool operator()(const PeptideEvidence &evidence) const
Definition: IDFilter.h:453
OpenMS::AASequence::fromString
static AASequence fromString(const String &s, bool permissive=true)
create AASequence object by parsing an OpenMS string
OpenMS::IDFilter::GetMatchingItems::argument_type
HitType argument_type
Definition: IDFilter.h:305
OpenMS::IdentificationData
Representation of spectrum identification results and associated data.
Definition: IdentificationData.h:89
OpenMS::PeptideHit::getScore
double getScore() const
returns the PSM score
OpenMS::PeptideEvidence::getProteinAccession
const String & getProteinAccession() const
get the protein accession the peptide matches to. If not available the empty string is returned...
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::IDFilter::HasNoHits
Is the list of hits of this peptide/protein ID empty?
Definition: IDFilter.h:497
OpenMS::DataValue::isEmpty
bool isEmpty() const
Test if the value is empty.
Definition: DataValue.h:375
OpenMS::IDFilter::removeDecoyHits
static void removeDecoyHits(std::vector< IdentificationType > &ids)
Removes hits annotated as decoys from peptide or protein identifications.
Definition: IDFilter.h:874