OpenMS
Loading...
Searching...
No Matches
MapConversion Class Reference

Static helpers that convert between the three OpenMS container types (PeakMap, FeatureMap, ConsensusMap). More...

#include <OpenMS/KERNEL/ConversionHelper.h>

Static Public Member Functions

static void convert (UInt64 const input_map_index, PeakMap &input_map, ConsensusMap &output_map, Size n=-1)
 Copy the most intense peaks of a PeakMap into a ConsensusMap.
 
static void convert (ConsensusMap const &input_map, const bool keep_uids, FeatureMap &output_map)
 Convert a ConsensusMap to a FeatureMap.
 
static void convert (UInt64 const input_map_index, FeatureMap const &input_map, ConsensusMap &output_map, Size n=-1)
 Convert a FeatureMap to a ConsensusMap.
 

Detailed Description

Static helpers that convert between the three OpenMS container types (PeakMap, FeatureMap, ConsensusMap).

Each overload replaces the contents of the destination, gives it a container-level unique id, and leaves it in a state where the standard range queries reflect the new contents without further bookkeeping by the caller.

The conversions are not symmetric: which fields are preserved (container / element unique ids, protein and unassigned peptide identifications) depends on the source and target container, so see each overload for the exact contract.

Member Function Documentation

◆ convert() [1/3]

static void convert ( ConsensusMap const &  input_map,
const bool  keep_uids,
FeatureMap output_map 
)
static

Convert a ConsensusMap to a FeatureMap.

Every element of input_map is converted to a Feature in output_map (the BaseFeature portion is copied; positional and meta data are preserved). The document identifier and the protein / unassigned peptide identifications are preserved on the output.

Parameters
[in]input_mapSource ConsensusMap.
[in]keep_uidsIf true, the container unique id and every element's unique id are preserved from input_map; otherwise they are replaced with fresh ones.
[out]output_mapResulting FeatureMap; previous contents are replaced.

◆ convert() [2/3]

static void convert ( UInt64 const  input_map_index,
FeatureMap const &  input_map,
ConsensusMap output_map,
Size  n = -1 
)
static

Convert a FeatureMap to a ConsensusMap.

The first n features of input_map (in input order; no sorting is performed) are written to output_map as ConsensusFeature entries tagged with input_map_index. The output's container unique id is taken from input_map (an intentional design choice – callers that need a fresh id must overwrite it afterwards). The protein and unassigned peptide identifications are preserved on the output.

Note
Because features are taken in input order, n is mainly useful after pre-sorting input_map (e.g. by intensity); it exists for symmetry with the PeakMap overload above.
The column header size for input_map_index is set to input_map.size() – the full input size – even when n truncates the actual copy. Inspect the output container's size for the number of features that were actually written.
Parameters
[in]input_map_indexIndex assigned to the input map in the resulting ConsensusMap column headers.
[in]input_mapSource FeatureMap.
[out]output_mapResulting ConsensusMap; previous contents are replaced.
[in]nMaximum number of features to copy. The default (Size(-1)) keeps all features.

◆ convert() [3/3]

static void convert ( UInt64 const  input_map_index,
PeakMap input_map,
ConsensusMap output_map,
Size  n = -1 
)
static

Copy the most intense peaks of a PeakMap into a ConsensusMap.

The output's previous contents are dropped and it is given a fresh container unique id (PeakMap has no container-level unique id, so one is generated). The n peaks with the highest intensity are written to the output as ConsensusFeature entries tagged with input_map_index; their order in the output is by descending intensity. The column header size for input_map_index reflects the number of peaks written.

Parameters
[in]input_map_indexIndex assigned to the input map in the resulting ConsensusMap column headers.
[in,out]input_mapSource peaks; its range queries are left consistent with its contents as a side effect.
[out]output_mapResulting ConsensusMap; previous contents are replaced.
[in]nMaximum number of peaks to copy. The default (Size(-1)) keeps all peaks.