OpenMS
Loading...
Searching...
No Matches
FeatureGroupingAlgorithm.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Marc Sturm, Clemens Groepl, Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15namespace OpenMS
16{
17
23 class OPENMS_DLLAPI FeatureGroupingAlgorithm :
25 {
26public:
29
32
34 virtual void group(const std::vector<FeatureMap > & maps, ConsensusMap & out) = 0;
35
39 virtual void group(const std::vector<ConsensusMap> & maps, ConsensusMap & out);
40
42 void transferSubelements(const std::vector<ConsensusMap> & maps, ConsensusMap & out) const;
43
44
45protected:
46
49 template<class MapType>
50 void postprocess_(const std::vector<MapType>& maps, ConsensusMap& out)
51 {
52 // add protein IDs and unassigned peptide IDs to the result map here,
53 // to keep the same order as the input maps (useful for output later):
54 auto& newIDs = out.getUnassignedPeptideIdentifications();
55 Size map_idx = 0;
56
57 for (typename std::vector<MapType>::const_iterator map_it = maps.begin();
58 map_it != maps.end(); ++map_it)
59 {
60 // add protein identifications to result map:
61 out.getProteinIdentifications().insert(
62 out.getProteinIdentifications().end(),
63 map_it->getProteinIdentifications().begin(),
64 map_it->getProteinIdentifications().end());
65
66 // assign the map_index to unassigned PepIDs as well.
67 // for the assigned ones, this has to be done in the subclass.
68 for (const PeptideIdentification& pepID : map_it->getUnassignedPeptideIdentifications())
69 {
70 auto newPepID = pepID;
71 // Note: during linking of _consensus_Maps we have the problem that old identifications
72 // should already have a map_index associated. Since we group the consensusFeatures only anyway
73 // (without keeping the subfeatures) the method for now is to "re"-index based on the input file/map index.
74 // Subfeatures have to be transferred in postprocessing if required
75 // (see FeatureGroupingAlgorithm::transferSubelements as used in the TOPP tools, i.e. FeatureLinkerBase),
76 // which also takes care of a re-re-indexing if the old map_index of the IDs was saved.
77 newPepID.setMetaValue("map_index", map_idx);
78 newIDs.push_back(newPepID);
79 }
80 map_idx++;
81 }
82
83 // canonical ordering for checking the results:
84 out.sortByQuality();
85 out.sortByMaps();
86 out.sortBySize();
87 }
88private:
93
94
95
96 };
97
98} // namespace OpenMS
99
A container for consensus elements.
Definition ConsensusMap.h:68
const PeptideIdentificationList & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
void sortByMaps()
Sorts with respect to the sets of maps covered by the consensus features (lexicographically).
void sortBySize()
Sorts with respect to the size (number of elements)
void sortByQuality(bool reverse=false)
Sorts the peaks according to ascending quality.
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
Base class for all feature grouping algorithms.
Definition FeatureGroupingAlgorithm.h:25
void transferSubelements(const std::vector< ConsensusMap > &maps, ConsensusMap &out) const
Transfers subelements (grouped features) from input consensus maps to the result consensus map.
FeatureGroupingAlgorithm & operator=(const FeatureGroupingAlgorithm &)
Assignment operator is not implemented -> private.
FeatureGroupingAlgorithm()
Default constructor.
virtual void group(const std::vector< ConsensusMap > &maps, ConsensusMap &out)
~FeatureGroupingAlgorithm() override
Destructor.
void postprocess_(const std::vector< MapType > &maps, ConsensusMap &out)
Definition FeatureGroupingAlgorithm.h:50
virtual void group(const std::vector< FeatureMap > &maps, ConsensusMap &out)=0
Applies the algorithm. The features in the input maps are grouped and the output is written to the co...
FeatureGroupingAlgorithm(const FeatureGroupingAlgorithm &)
Copy constructor is not implemented -> private.
Represents the set of candidates (SpectrumMatches) identified for a single precursor spectrum.
Definition PeptideIdentification.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19