or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

alignment.mdchemistry.mdfeature-detection.mdfile-io.mdindex.mdms-data.mdpeptide-protein.mdtargeted-analysis.md
tile.json

tessl/pypi-pyopenms

Python wrapper for C++ LC-MS library OpenMS for comprehensive mass spectrometry data analysis

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyopenms@3.4.x

To install, run

npx @tessl/cli install tessl/pypi-pyopenms@3.4.0

index.mddocs/

pyOpenMS

Python bindings for the OpenMS C++ library providing comprehensive mass spectrometry data analysis capabilities. pyOpenMS enables rapid development of LC-MS data processing workflows through high-performance algorithms for file I/O, signal processing, feature detection, peptide/protein identification, and quantification.

Package Information

  • Package Name: pyopenms
  • Language: Python
  • Installation: pip install pyopenms
  • Documentation: https://pyopenms.readthedocs.io
  • Repository: https://github.com/OpenMS/OpenMS/tree/develop/src/pyOpenMS

Core Imports

import pyopenms

Common usage patterns:

# File I/O
from pyopenms import MzMLFile, FeatureXMLFile, IdXMLFile

# Core data structures
from pyopenms import MSExperiment, MSSpectrum, FeatureMap, ConsensusMap

# Sequence analysis
from pyopenms import AASequence, PeptideIdentification, ProteinIdentification

# Algorithms
from pyopenms import PeakPickerHiRes, FeatureFinderAlgorithmPicked

Basic Usage

Loading and Processing MS Data

import pyopenms

# Load MS experiment from mzML file
exp = pyopenms.MSExperiment()
pyopenms.MzMLFile().load("data.mzML", exp)

# Access spectra
for spectrum in exp:
    rt = spectrum.getRT()
    ms_level = spectrum.getMSLevel()
    mz_array, intensity_array = spectrum.get_peaks()
    print(f"RT: {rt}, MS Level: {ms_level}, Peaks: {len(mz_array)}")

# Save processed experiment
pyopenms.MzMLFile().store("processed.mzML", exp)

Feature Detection Workflow

import pyopenms

# Load raw data
exp = pyopenms.MSExperiment()
pyopenms.MzMLFile().load("data.mzML", exp)

# Peak picking
picker = pyopenms.PeakPickerHiRes()
picker.pickExperiment(exp, exp)

# Feature detection
features = pyopenms.FeatureMap()
finder = pyopenms.FeatureFinderAlgorithmPicked()
finder.run(exp, features, pyopenms.Param(), pyopenms.FeatureMap())

# Access feature results
for feature in features:
    rt = feature.getRT()
    mz = feature.getMZ()
    intensity = feature.getIntensity()
    print(f"Feature: RT={rt:.2f}, m/z={mz:.4f}, Intensity={intensity:.0f}")

# Save features
pyopenms.FeatureXMLFile().store("features.featureXML", features)

Peptide Sequence Analysis

import pyopenms

# Create peptide sequence with modifications
seq = pyopenms.AASequence.fromString("PEPTIDE")
modified_seq = pyopenms.AASequence.fromString("PEPTIDEM(Oxidation)")

# Get sequence properties
mono_weight = seq.getMonoWeight()
average_weight = seq.getAverageWeight()
formula = seq.getFormula()

print(f"Sequence: {seq.toString()}")
print(f"Monoisotopic weight: {mono_weight:.4f}")
print(f"Formula: {formula.toString()}")

# Generate theoretical spectrum
generator = pyopenms.TheoreticalSpectrumGenerator()
spectrum = pyopenms.MSSpectrum()
generator.getSpectrum(spectrum, seq, 1, 1)  # charge=1, intensity=1

Architecture

pyOpenMS provides a comprehensive API organized around several key architectural components:

Data Structures

  • MSExperiment: Central container for LC-MS experiments with spectra and chromatograms
  • Feature/ConsensusFeature: Detected and aligned features with quantitative information
  • AASequence: Peptide sequences with modification support
  • Identification structures: Search results linking spectra to peptide/protein sequences

File I/O Layer

  • Format handlers: Support for mzML, mzXML, featureXML, idXML, and 15+ other formats
  • Cached access: Memory-efficient processing of large datasets
  • Metadata preservation: Complete experimental metadata handling

Algorithm Framework

  • Configurable parameters: All algorithms use Param objects for configuration
  • Processing pipelines: Modular components for complete analysis workflows
  • Quality control: Built-in validation and QC metrics

Integration Layer

  • NumPy arrays: Direct array access for efficient data processing
  • Pandas DataFrames: Export capabilities for statistical analysis
  • Visualization: Basic plotting support for MS data

Capabilities

File I/O and Data Formats

Comprehensive support for mass spectrometry file formats including mzML, mzXML, feature detection results, identification files, and spectral libraries. Handles both reading and writing with full metadata preservation.

class MzMLFile:
    def load(self, filename: str, exp: MSExperiment) -> None: ...
    def store(self, filename: str, exp: MSExperiment) -> None: ...

class FeatureXMLFile:
    def load(self, filename: str, features: FeatureMap) -> None: ...
    def store(self, filename: str, features: FeatureMap) -> None: ...

class IdXMLFile:
    def load(self, filename: str, prot_ids: list, pep_ids: list) -> None: ...
    def store(self, filename: str, prot_ids: list, pep_ids: list) -> None: ...

File I/O and Data Formats

MS Data Structures and Processing

Core data structures for representing mass spectrometry experiments, spectra, and chromatograms with efficient data access patterns and numpy integration.

class MSExperiment:
    def size(self) -> int: ...
    def getSpectrum(self, index: int) -> MSSpectrum: ...
    def addSpectrum(self, spectrum: MSSpectrum) -> None: ...
    def updateRanges(self) -> None: ...
    def get_df(self, long: bool = False) -> DataFrame: ...

class MSSpectrum:
    def getRT(self) -> float: ...
    def getMSLevel(self) -> int: ...
    def get_peaks(self) -> tuple[np.ndarray, np.ndarray]: ...
    def set_peaks(self, mz: np.ndarray, intensity: np.ndarray) -> None: ...

MS Data Structures

Feature Detection and Quantification

Advanced algorithms for detecting LC-MS features, including peak picking, feature finding, and quantitative analysis across multiple experiments.

class PeakPickerHiRes:
    def pickExperiment(self, input: MSExperiment, output: MSExperiment) -> None: ...
    def getParameters(self) -> Param: ...

class FeatureFinderAlgorithmPicked:
    def run(self, input: MSExperiment, features: FeatureMap, 
            params: Param, seeds: FeatureMap) -> None: ...

class Feature:
    def getRT(self) -> float: ...
    def getMZ(self) -> float: ...
    def getIntensity(self) -> float: ...
    def getOverallQuality(self) -> float: ...

Feature Detection

Peptide and Protein Identification

Comprehensive support for peptide sequence analysis, database search results, and protein identification workflows with modification handling.

class AASequence:
    @staticmethod
    def fromString(seq: str) -> AASequence: ...
    def toString(self) -> str: ...
    def getMonoWeight(self) -> float: ...
    def getFormula(self) -> EmpiricalFormula: ...

class PeptideIdentification:
    def getHits(self) -> list[PeptideHit]: ...
    def getRT(self) -> float: ...
    def getMZ(self) -> float: ...

class PeptideHit:
    def getSequence(self) -> AASequence: ...
    def getScore(self) -> float: ...
    def getCharge(self) -> int: ...

Peptide and Protein Analysis

Map Alignment and Consensus Features

Retention time alignment algorithms and consensus feature generation for comparative analysis across multiple LC-MS experiments.

class MapAlignmentAlgorithmPoseClustering:
    def align(self, maps: list[FeatureMap], trafos: list[TransformationDescription]) -> None: ...

class ConsensusMap:
    def getColumnHeaders(self) -> dict[int, ColumnHeader]: ...
    def get_intensity_df(self) -> DataFrame: ...
    def get_metadata_df(self) -> DataFrame: ...

class ConsensusFeature:
    def getFeatureList(self) -> list[FeatureHandle]: ...
    def getRT(self) -> float: ...
    def getMZ(self) -> float: ...

Alignment and Consensus

Targeted Analysis and MRM

Specialized functionality for targeted mass spectrometry including MRM/SRM analysis, transition lists, and quantitative workflows.

class TargetedExperiment:
    def getTransitions(self) -> list[ReactionMonitoringTransition]: ...
    def addTransition(self, transition: ReactionMonitoringTransition) -> None: ...

class ReactionMonitoringTransition:
    def getPrecursor(self) -> Precursor: ...
    def getProduct(self) -> Product: ...
    def getDecoyTransitionType(self) -> DecoyTransitionType: ...

class MRMFeature:
    def getRT(self) -> float: ...
    def getIntensity(self) -> float: ...
    def getOverallQuality(self) -> float: ...

Targeted Analysis

Chemistry and Molecular Properties

Chemical calculations including empirical formulas, isotope distributions, elemental compositions, and theoretical spectrum generation.

class EmpiricalFormula:
    def __init__(self, formula: str = "") -> None: ...
    def getMonoWeight(self) -> float: ...
    def getAverageWeight(self) -> float: ...
    def toString(self) -> str: ...

class IsotopeDistribution:
    def set(self, formula: EmpiricalFormula) -> None: ...
    def getContainer(self) -> list[Peak1D]: ...

class TheoreticalSpectrumGenerator:
    def getSpectrum(self, spectrum: MSSpectrum, peptide: AASequence, 
                    charge: int, intensity: float) -> None: ...

Chemistry and Molecular Properties

Types

Core Data Types

class Peak1D:
    def __init__(self, mz: float = 0.0, intensity: float = 0.0) -> None: ...
    def getMZ(self) -> float: ...
    def getIntensity(self) -> float: ...

class Peak2D:
    def __init__(self, rt: float = 0.0, mz: float = 0.0, intensity: float = 0.0) -> None: ...
    def getRT(self) -> float: ...
    def getMZ(self) -> float: ...
    def getIntensity(self) -> float: ...

class Param:
    def __init__(self) -> None: ...
    def setValue(self, key: str, value: any) -> None: ...
    def getValue(self, key: str) -> any: ...
    def exists(self, key: str) -> bool: ...

Range and Index Types

class DRange:
    def __init__(self, dim: int = 1) -> None: ...
    def getMin(self) -> float: ...
    def getMax(self) -> float: ...
    def setMin(self, min_val: float) -> None: ...
    def setMax(self, max_val: float) -> None: ...

class RangeManager:
    def __init__(self, dim: int = 1) -> None: ...
    def getMin(self, dim: int) -> float: ...
    def getMax(self, dim: int) -> float: ...
    def updateRanges(self) -> None: ...

Instrument and Method Types

class Instrument:
    def __init__(self) -> None: ...
    def getName(self) -> str: ...
    def getVendor(self) -> str: ...
    def getModel(self) -> str: ...

class IonSource:
    def __init__(self) -> None: ...
    def getPolarity(self) -> Polarity: ...
    def setPolarity(self, polarity: Polarity) -> None: ...

class Sample:
    def __init__(self) -> None: ...
    def getName(self) -> str: ...
    def getOrganism(self) -> str: ...
    def getTissue(self) -> str: ...

class Matrix:
    def __init__(self, rows: int = 0, cols: int = 0) -> None: ...
    def getValue(self, row: int, col: int) -> float: ...
    def setValue(self, row: int, col: int, value: float) -> None: ...
    def rows(self) -> int: ...
    def cols(self) -> int: ...

class PeakFileOptions:
    def __init__(self) -> None: ...
    def setMSLevels(self, levels: list[int]) -> None: ...
    def getMSLevels(self) -> list[int]: ...
    def setRTRange(self, min_rt: float, max_rt: float) -> None: ...
    def setMZRange(self, min_mz: float, max_mz: float) -> None: ...

class FeatureFileOptions:
    def __init__(self) -> None: ...
    def setLoadConvexHull(self, load: bool) -> None: ...
    def getLoadConvexHull(self) -> bool: ...

class DriftTimeUnit:
    NONE = 0
    MILLISECOND = 1
    VOLT_SECOND_PER_SQUARE_CENTIMETER = 2

class SpectrumType:
    UNKNOWN = 0
    PROFILE = 1
    CENTROIDED = 2