| name | alterlab-pyopenms |
| description | Build complete mass-spectrometry workflows with pyOpenMS — feature detection, peptide identification, protein quantification, and full LC-MS/MS pipelines across many MS file formats (mzML, mzXML) and algorithms. Use for comprehensive proteomics and MS data processing — for simple spectral comparison and metabolite identification use matchms. Part of the AlterLab Academic Skills suite. |
| license | MIT |
| allowed-tools | Read Write Edit Bash(python:*) Bash(uv:*) |
| compatibility | Self-contained — runs under `uv run python` with the skill's Python package installed; no API key or account required. |
| metadata | {"skill-author":"AlterLab","version":"1.1.0"} |
PyOpenMS
Overview
PyOpenMS provides Python bindings to the OpenMS library for computational mass spectrometry, enabling analysis of proteomics and metabolomics data. Use for handling mass spectrometry file formats, processing spectral data, detecting features, identifying peptides/proteins, and performing quantitative analysis.
Installation
Install using uv (pyOpenMS 3.x — examples here are verified against 3.5):
uv pip install "pyopenms>=3.4"
Verify installation:
import pyopenms
print(pyopenms.__version__)
Version note: pyOpenMS 3.x removed the old FeatureFinder facade. Use
FeatureFinderAlgorithmPicked (the former "centroided" algorithm) or, for
metabolomics, the MassTraceDetection → ElutionPeakDetection →
FeatureFindingMetabo chain. See references/feature_detection.md.
Core Capabilities
PyOpenMS organizes functionality into these domains:
1. File I/O and Data Formats
Handle mass spectrometry file formats and convert between representations.
Supported formats: mzML, mzXML, TraML, mzTab, FASTA, pepXML, protXML, mzIdentML, featureXML, consensusXML, idXML
Basic file reading:
import pyopenms as ms
exp = ms.MSExperiment()
ms.MzMLFile().load("data.mzML", exp)
for spectrum in exp:
mz, intensity = spectrum.get_peaks()
print(f"Spectrum: {len(mz)} peaks")
For detailed file handling: See references/file_io.md
2. Signal Processing
Process raw spectral data with smoothing, filtering, centroiding, and normalization.
Basic spectrum processing:
gaussian = ms.GaussFilter()
params = gaussian.getParameters()
params.setValue("gaussian_width", 0.1)
gaussian.setParameters(params)
gaussian.filterExperiment(exp)
For algorithm details: See references/signal_processing.md
3. Feature Detection
Detect and link features across spectra and samples for quantitative analysis.
ff = ms.FeatureFinderAlgorithmPicked()
params = ff.getParameters()
ff.setParameters(params)
features = ms.FeatureMap()
seeds = ms.FeatureMap()
ff.run(exp, features, params, seeds)
For complete workflows: See references/feature_detection.md
4. Peptide and Protein Identification
Integrate with search engines and process identification results.
Supported engines: Comet, Mascot, MSGFPlus, XTandem, OMSSA, Myrimatch
Basic identification workflow:
protein_ids = []
peptide_ids = ms.PeptideIdentificationList()
ms.IdXMLFile().load("identifications.idXML", protein_ids, peptide_ids)
fdr = ms.FalseDiscoveryRate()
fdr.apply(peptide_ids)
ms.IDFilter().filterHitsByScore(peptide_ids, 0.01)
ms.IDFilter().removeEmptyIdentifications(peptide_ids)
For detailed workflows: See references/identification.md
5. Metabolomics Analysis
Perform untargeted metabolomics preprocessing and analysis.
Typical workflow:
- Load and process raw data
- Detect features
- Align retention times across samples
- Link features to consensus map
- Annotate with compound databases
For complete metabolomics workflows: See references/metabolomics.md
Data Structures
PyOpenMS uses these primary objects:
- MSExperiment: Collection of spectra and chromatograms
- MSSpectrum: Single mass spectrum with m/z and intensity pairs
- MSChromatogram: Chromatographic trace
- Feature: Detected chromatographic peak with quality metrics
- FeatureMap: Collection of features
- PeptideIdentification: Search results for peptides
- ProteinIdentification: Search results for proteins
For detailed documentation: See references/data_structures.md
Common Workflows
Quick Start: Load and Explore Data
import pyopenms as ms
exp = ms.MSExperiment()
ms.MzMLFile().load("sample.mzML", exp)
print(f"Number of spectra: {exp.getNrSpectra()}")
print(f"Number of chromatograms: {exp.getNrChromatograms()}")
spec = exp.getSpectrum(0)
print(f"MS level: {spec.getMSLevel()}")
print(f"Retention time: {spec.getRT()}")
mz, intensity = spec.get_peaks()
print(f"Peaks: {len(mz)}")
Parameter Management
Most algorithms use a parameter system:
algo = ms.GaussFilter()
params = algo.getParameters()
for param in params.keys():
print(f"{param}: {params.getValue(param)}")
params.setValue("gaussian_width", 0.2)
algo.setParameters(params)
Export to Pandas
Convert data to pandas DataFrames for analysis:
import pyopenms as ms
import pandas as pd
fm = ms.FeatureMap()
ms.FeatureXMLFile().load("features.featureXML", fm)
df = fm.get_df()
print(df.head())
Integration with Other Tools
PyOpenMS integrates with:
- Pandas: Export data to DataFrames
- NumPy: Work with peak arrays
- Scikit-learn: Machine learning on MS data
- Matplotlib/Seaborn: Visualization
- R: Via rpy2 bridge
Resources
References
references/file_io.md - Comprehensive file format handling
references/signal_processing.md - Signal processing algorithms
references/feature_detection.md - Feature detection and linking
references/identification.md - Peptide and protein identification
references/metabolomics.md - Metabolomics-specific workflows
references/data_structures.md - Core objects and data structures