Feature#

class pyopenms.Feature#

Bases: object

Cython implementation of _Feature

Original C++ documentation is available here

– Inherits from [‘UniqueIdInterface’, ‘RichPeak2D’]

An LC-MS feature representing a detected analyte signal

The Feature class represents a two-dimensional (RT and m/z) signal from an analyte in LC-MS data. It is one of the core data structures in OpenMS for representing detected peaks or compounds.

A Feature stores:

  • Position: retention time (RT) and mass-to-charge ratio (m/z)

  • Intensity: the signal strength (typically total ion count)

  • Quality metrics: scores indicating detection confidence

  • Charge state: the charge of the ion

  • Convex hulls: the 2D area occupied by the feature in RT-m/z space

  • Peptide identifications: for identified peptides (optional)

  • Subordinate features: for isotopic peaks or related signals

By convention, the feature’s position is at the maximum of the elution profile (RT dimension) and at the monoisotopic peak (m/z dimension).

Example usage:

feature = oms.Feature()
feature.setRT(1234.5)  # Set retention time in seconds
feature.setMZ(445.678)  # Set m/z value
feature.setIntensity(100000.0)  # Set intensity
feature.setCharge(2)  # Set charge state
feature.setOverallQuality(0.95)  # Set quality score (0-1)
# Access the values
print(f"RT: {feature.getRT()}, m/z: {feature.getMZ()}, charge: {feature.getCharge()}")
__init__()#

Overload:

__init__(self) None

Overload:

__init__(self, in_0: Feature) None

Methods

__init__

clearMetaInfo(self)

Removes all meta values

clearUniqueId(self)

Clear the unique id.

encloses(self, rt, mz)

Checks if the feature's convex hulls enclose a given position

ensureUniqueId(self)

Assigns a valid unique id, but only if the present one is invalid.

getAnnotationState(self)

Returns the annotation state of the feature

getCharge(self)

Returns the charge state of the feature

getConvexHull(self)

Returns the overall convex hull of the feature

getConvexHulls(self)

Returns the convex hulls of individual mass traces

getIntensity(self)

Returns the data point intensity (height)

getKeys(self, keys)

Fills the given vector with a list of all keys for which a value is set

getMZ(self)

Returns the m/z coordinate (index 1)

getMetaValue(self, in_0)

Returns the value corresponding to a string, or

getOverallQuality(self)

Returns the overall quality score of the feature

getPeptideIdentifications(self)

Returns the peptide identifications associated with this feature

getQuality(self, index)

Returns the quality score in a specific dimension

getRT(self)

Returns the RT coordinate (index 0)

getSubordinates(self)

Returns subordinate features (e.g., isotopic peaks)

getUniqueId(self)

Returns the unique id

getWidth(self)

Returns the width (FWHM) of the feature in RT dimension

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

setCharge(self, q)

Sets the charge state of the feature

setConvexHulls(self, in_0)

Sets the convex hulls for individual mass traces

setIntensity(self, in_0)

Returns the data point intensity (height)

setMZ(self, in_0)

Returns the m/z coordinate (index 1)

setMetaValue(self, in_0, in_1)

Sets the DataValue corresponding to a name

setOverallQuality(self, q)

Sets the overall quality score of the feature

setPeptideIdentifications(self, peptides)

Sets the peptide identifications for this feature

setQuality(self, index, q)

Sets the quality score for a specific dimension

setRT(self, in_0)

Returns the RT coordinate (index 0)

setSubordinates(self, in_0)

Sets the subordinate features

setUniqueId(self, rhs)

Assigns a new, valid unique id.

setWidth(self, q)

Sets the width (FWHM) of the feature in RT dimension

clearMetaInfo(self) None#

Removes all meta values

clearUniqueId(self) int#

Clear the unique id. The new unique id will be invalid. Returns 1 if the unique id was changed, 0 otherwise

encloses(self, rt: float, mz: float) bool#

Checks if the feature’s convex hulls enclose a given position

Parameters:
  • rt – Retention time in seconds

  • mz – Mass-to-charge ratio

Returns:

True if the position (rt, mz) is within the feature’s convex hulls, False otherwise

This uses the feature’s convex hull representation to determine spatial containment

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

getAnnotationState(self) int#

Returns the annotation state of the feature

Returns:

Enum indicating the annotation status of this feature

getCharge(self) int#

Returns the charge state of the feature

Returns:

Charge state (e.g., 2 for doubly charged ions, 0 if unknown)

getConvexHull(self) ConvexHull2D#

Returns the overall convex hull of the feature

Returns:

The overall 2D convex hull encompassing all mass traces

This is the union of all individual mass trace convex hulls

getConvexHulls(self) List[ConvexHull2D]#

Returns the convex hulls of individual mass traces

Returns:

List of convex hulls, one for each isotopic mass trace

Each isotopic peak typically has its own convex hull in RT-m/z space

getIntensity(self) float#

Returns the data point intensity (height)

getKeys(self, keys: List[bytes]) None#

Fills the given vector with a list of all keys for which a value is set

getMZ(self) float#

Returns the m/z coordinate (index 1)

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

getOverallQuality(self) float#

Returns the overall quality score of the feature

Returns:

Overall quality score (typically 0-1, where 1 is highest quality)

This score represents the overall confidence in the feature detection

getPeptideIdentifications(self) PeptideIdentificationList#

Returns the peptide identifications associated with this feature

Returns:

List of peptide identifications from database search

Only relevant for peptide features. Contains results from peptide identification tools

getQuality(self, index: int) float#

Returns the quality score in a specific dimension

Parameters:

index – The dimension index (0 for RT, 1 for m/z)

Returns:

Quality score for the specified dimension (typically 0-1 range)

getRT(self) float#

Returns the RT coordinate (index 0)

getSubordinates(self) List[Feature]#

Returns subordinate features (e.g., isotopic peaks)

Returns:

List of subordinate features associated with this feature

Subordinate features often represent individual isotopic peaks of the same compound

getUniqueId(self) int#

Returns the unique id

getWidth(self) float#

Returns the width (FWHM) of the feature in RT dimension

Returns:

Full Width at Half Maximum (FWHM) in seconds

Represents the elution peak width

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

removeMetaValue(self, in_0: bytes | str | String) None#

Removes the DataValue corresponding to name if it exists

setCharge(self, q: int) None#

Sets the charge state of the feature

Parameters:

q – Charge state (e.g., 2 for doubly charged ions)

setConvexHulls(self, in_0: List[ConvexHull2D]) None#

Sets the convex hulls for individual mass traces

Parameters:

hulls – List of convex hulls to set for this feature

setIntensity(self, in_0: float) None#

Returns the data point intensity (height)

setMZ(self, in_0: float) None#

Returns the m/z coordinate (index 1)

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

setOverallQuality(self, q: float) None#

Sets the overall quality score of the feature

Parameters:

q – Overall quality score (typically 0-1, where 1 is highest quality)

setPeptideIdentifications(self, peptides: PeptideIdentificationList) None#

Sets the peptide identifications for this feature

Parameters:

peptides – List of peptide identifications to associate with this feature

setQuality(self, index: int, q: float) None#

Sets the quality score for a specific dimension

Parameters:
  • index – The dimension index (0 for RT, 1 for m/z)

  • q – Quality score to set (typically 0-1 range)

setRT(self, in_0: float) None#

Returns the RT coordinate (index 0)

setSubordinates(self, in_0: List[Feature]) None#

Sets the subordinate features

Parameters:

subordinates – List of subordinate features to associate with this feature

setUniqueId(self, rhs: int) None#

Assigns a new, valid unique id. Always returns 1

setWidth(self, q: float) None#

Sets the width (FWHM) of the feature in RT dimension

Parameters:

q – Full Width at Half Maximum in seconds