FeatureMap#
- class pyopenms.FeatureMap(*args, **kwargs)#
Bases:
FeatureMap- __init__(*args, **kwargs)#
Overload:
- __init__(self) None
Overload:
- __init__(self, in_0: FeatureMap) None
Methods
__init__(*args, **kwargs)clearMetaInfo(self)Removes all meta values
clearRanges(self)Resets all range dimensions as empty
clearUniqueId(self)Clear the unique id.
ensureUniqueId(self)Assigns a valid unique id, but only if the present one is invalid.
getDataProcessing(self)getIdentifier(self)Retrieve document identifier (e.g. an LSID).
getKeys(self, keys)Fills the given vector with a list of all keys for which a value is set
getLoadedFilePath(self)Returns the file_name which is the absolute path to the file loaded
getLoadedFileType(self)Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, ...) of the file loaded.
getMaxIntensity(self)Returns the maximum intensity
getMaxMZ(self)Returns the maximum m/z
getMaxRT(self)Returns the maximum RT
getMetaValue(self, in_0)Returns the value corresponding to a string, or
getMinIntensity(self)Returns the minimum intensity
getMinMZ(self)Returns the minimum m/z
getMinRT(self)Returns the minimum RT
getPrimaryMSRunPath(self, toFill)Returns the file path to the first MS run
Returns the protein identification runs stored in this map
Returns peptide identifications that are not assigned to any feature
getUniqueId(self)Returns the unique id
Generates a list with peptide identifications assigned to a feature.
get_df([columns, meta_values, ...])Generates a pandas DataFrame with information contained in the FeatureMap.
get_df_columns([columns, ...])Returns a list of column names that get_df() would produce.
hasInvalidUniqueId(self)Returns whether the unique id is invalid.
hasValidUniqueId(self)Returns whether the unique id is valid.
isMetaEmpty(self)Returns if the MetaInfo is empty
isValid(self, unique_id)Returns true if the unique_id is valid, false otherwise
metaRegistry(self)Returns a reference to the MetaInfoRegistry
metaValueExists(self, in_0)Returns whether an entry with the given name exists
removeMetaValue(self, in_0)Removes the DataValue corresponding to name if it exists
setDataProcessing(self, in_0)Sets the description of the applied data processing
setIdentifier(self, id)Sets document identifier (e.g. an LSID).
setLoadedFilePath(self, file_name)Sets the file_name according to absolute path of the file loaded, preferably done whilst loading
setLoadedFileType(self, file_name)Sets the file_type according to the type of the file loaded from, preferably done whilst loading
setMetaValue(self, in_0, in_1)Sets the DataValue corresponding to a name
setProteinIdentifications(self, in_0)Sets the protein identifications for this map
setUnassignedPeptideIdentifications(self, in_0)Sets the unassigned peptide identifications
setUniqueId(self, rhs)Assigns a new, valid unique id.
size(self)Returns the number of features in the map
sortByMZ(self)Sorts features by mass-to-charge ratio (m/z) in ascending order
sortByOverallQuality(self)Sorts features by overall quality score in ascending order
sortByPosition(self)Sorts features by position using lexicographical comparison
sortByRT(self)Sorts features by retention time (RT) in ascending order
swap(self, in_0)swapFeaturesOnly(self, swapfrom)Swaps the feature content (plus its range information) of this map
updateRanges(self)- clear()#
Overload:
- clear(self) None
Clears all feature data and metadata
After calling this, the map will be empty (size() returns 0)
Overload:
- clear(self, clear_meta_data: bool) None
Clears feature data and optionally metadata
- Parameters:
clear_meta_data – If True, also clears all metadata; if False, keeps metadata
- clearMetaInfo(self) None#
Removes all meta values
- clearRanges(self) None#
Resets all range dimensions as empty
- clearUniqueId(self) int#
Clear the unique id. The new unique id will be invalid. Returns 1 if the unique id was changed, 0 otherwise
- ensureUniqueId(self) int#
Assigns a valid unique id, but only if the present one is invalid. Returns 1 if the unique id was changed, 0 otherwise
- getDataProcessing(self) List[DataProcessing]#
- getKeys(self, keys: List[bytes]) None#
Fills the given vector with a list of all keys for which a value is set
- getLoadedFilePath(self) bytes | str | String#
Returns the file_name which is the absolute path to the file loaded
- getLoadedFileType(self) int#
Returns the file_type (e.g. featureXML, consensusXML, mzData, mzXML, mzML, …) of the file loaded
- getMaxIntensity(self) float#
Returns the maximum intensity
- getMaxMZ(self) float#
Returns the maximum m/z
- getMaxRT(self) float#
Returns the maximum RT
- getMetaValue(self, in_0: bytes | str | String) int | float | bytes | str | List[int] | List[float] | List[bytes]#
Returns the value corresponding to a string, or
- getMinIntensity(self) float#
Returns the minimum intensity
- getMinMZ(self) float#
Returns the minimum m/z
- getMinRT(self) float#
Returns the minimum RT
- getPrimaryMSRunPath(self, toFill: List[bytes]) None#
Returns the file path to the first MS run
- getProteinIdentifications(self) List[ProteinIdentification]#
Returns the protein identification runs stored in this map
- Returns:
Protein identification data from database searches
Protein identifications contain metadata about search parameters and protein hits
- getUnassignedPeptideIdentifications(self) PeptideIdentificationList#
Returns peptide identifications that are not assigned to any feature
- Returns:
Unassigned peptide identification results
These are peptide IDs that could not be matched to features, possibly due to feature detection issues or filtering
- getUniqueId(self) int#
Returns the unique id
- get_assigned_peptide_identifications()#
Generates a list with peptide identifications assigned to a feature.
Adds ‘ID_native_id’ (feature spectrum id), ‘ID_filename’ (primary MS run path of corresponding ProteinIdentification) and ‘feature_id’ (unique ID of corresponding Feature) as meta values to the peptide hits. A DataFrame from the assigned peptides generated with peptide_identifications_to_df(assigned_peptides) can be merged with the FeatureMap DataFrame with: merged_df = _pd.merge(feature_df, assigned_peptide_df, on=[‘feature_id’, ‘ID_native_id’, ‘ID_filename’])
Returns: _PeptideIdentificationList: list of PeptideIdentification objects
- get_df(columns: None | List[str] = None, meta_values: None | List[str] | str = None, export_peptide_identifications: bool = True)#
Generates a pandas DataFrame with information contained in the FeatureMap.
Optionally the feature meta values and information for the assigned PeptideHit can be exported.
Parameters: columns (list or None): List of column names to include. If None,
includes all columns. Use get_df_columns() to discover available columns.
meta_values: meta values to include (None, [custom list of meta value names] or ‘all’)
export_peptide_identifications (bool): export sequence and score for best PeptideHit assigned to a feature. Additionally the ID_filename (file name of the corresponding ProteinIdentification) and the ID_native_id (spectrum ID of the corresponding Feature) are exported. They are also annotated as meta values when collecting all assigned PeptideIdentifications from a FeatureMap with FeatureMap.get_assigned_peptide_identifications(). A DataFrame from the assigned peptides generated with peptide_identifications_to_df(assigned_peptides) can be merged with the FeatureMap DataFrame with: merged_df = pd.merge(feature_df, assigned_peptide_df, on=[‘feature_id’, ‘ID_native_id’, ‘ID_filename’])
Returns: pandas.DataFrame: feature information stored in a DataFrame
- Example:
>>> # Get all columns >>> df = fmap.get_df()
>>> # Discover available columns >>> print(fmap.get_df_columns())
>>> # Get only specific columns >>> df = fmap.get_df(columns=['feature_id', 'mz', 'rt', 'intensity'])
- get_df_columns(columns: str = 'default', export_peptide_identifications: bool = True) List[str]#
Returns a list of column names that get_df() would produce.
Useful for discovering available columns before export.
- Args:
columns (str): ‘default’ for standard columns, ‘all’ to include all meta values. export_peptide_identifications (bool): Whether to include peptide ID columns.
- Returns:
list: List of column name strings.
- Example:
>>> fmap.get_df_columns() ['feature_id', 'peptide_sequence', 'charge', 'rt', 'mz', ...]
- hasInvalidUniqueId(self) int#
Returns whether the unique id is invalid. Returns 1 if the unique id is invalid, 0 otherwise
- hasValidUniqueId(self) int#
Returns whether the unique id is valid. Returns 1 if the unique id is valid, 0 otherwise
- isMetaEmpty(self) bool#
Returns if the MetaInfo is empty
- isValid(self, unique_id: int) bool#
Returns true if the unique_id is valid, false otherwise
- metaRegistry(self) MetaInfoRegistry#
Returns a reference to the MetaInfoRegistry
- metaValueExists(self, in_0: bytes | str | String) bool#
Returns whether an entry with the given name exists
- push_back()#
Overload:
- push_back(self, spec: Feature) None
Adds a Feature to the map
- Parameters:
spec – The feature to add to the map
Overload:
- push_back(self, spec: MRMFeature) None
Adds an MRMFeature to the map
- Parameters:
spec – The MRM feature to add to the map
- removeMetaValue(self, in_0: bytes | str | String) None#
Removes the DataValue corresponding to name if it exists
- setDataProcessing(self, in_0: List[DataProcessing]) None#
Sets the description of the applied data processing
- setLoadedFilePath(self, file_name: bytes | str | String) None#
Sets the file_name according to absolute path of the file loaded, preferably done whilst loading
- setLoadedFileType(self, file_name: bytes | str | String) None#
Sets the file_type according to the type of the file loaded from, preferably done whilst loading
- setMetaValue(self, in_0: bytes | str | String, in_1: int | float | bytes | str | List[int] | List[float] | List[bytes]) None#
Sets the DataValue corresponding to a name
- setPrimaryMSRunPath()#
Overload:
- setPrimaryMSRunPath(self, s: List[bytes]) None
Sets the file path to the primary MS run (usually the mzML file obtained after data conversion from raw files)
Overload:
- setPrimaryMSRunPath(self, s: List[bytes], e: MSExperiment) None
Sets the file path to the primary MS run using the mzML annotated in the MSExperiment argument e
- setProteinIdentifications(self, in_0: List[ProteinIdentification]) None#
Sets the protein identifications for this map
- Parameters:
protein_ids – Protein identification results to associate with this map
- setUnassignedPeptideIdentifications(self, in_0: PeptideIdentificationList) None#
Sets the unassigned peptide identifications
- Parameters:
peptide_ids – Peptide IDs not assigned to features
- setUniqueId(self, rhs: int) None#
Assigns a new, valid unique id. Always returns 1
- setUniqueIds()#
- size(self) int#
Returns the number of features in the map
- Returns:
Number of features stored in this container
- sortByIntensity()#
Overload:
- sortByIntensity(self) None
Sorts features by ascending intensity
After sorting, features can be accessed in order from lowest to highest intensity
Overload:
- sortByIntensity(self, reverse: bool) None
Sorts features by intensity with optional reverse order
- Parameters:
reverse – If True, sorts in descending order (highest to lowest intensity)
- sortByMZ(self) None#
Sorts features by mass-to-charge ratio (m/z) in ascending order
Useful for mass-based grouping or analysis
- sortByOverallQuality(self) None#
Sorts features by overall quality score in ascending order
Higher quality scores indicate better feature detection confidence
- sortByPosition(self) None#
Sorts features by position using lexicographical comparison
Compares RT first, then m/z for features with the same RT
- sortByRT(self) None#
Sorts features by retention time (RT) in ascending order
This is useful for time-based analysis or visualization
- swap(self, in_0: FeatureMap) None#
- swapFeaturesOnly(self, swapfrom: FeatureMap) None#
Swaps the feature content (plus its range information) of this map
- updateRanges(self) None#