
Pyopenms
Guide an agent through PyOpenMS LC-MS data structures and file IO so you can load mzML experiments and manipulate spectra in Python pipelines.
Install
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill pyopenmsWhat is this skill?
- Documents MSExperiment containers for full LC-MS runs including spectra and chromatogram counts
- Covers MSSpectrum peak access via get_peaks() numpy-friendly m/z and intensity arrays
- Shows MzMLFile load patterns and iteration filtered by MS level
- Explains retention time ranges and instrument metadata via ExperimentalSettings
- Maps C++-backed PyOpenMS objects to practical Python manipulation loops
Adoption & trust: 512 installs on skills.sh; 27.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Journey fit
Canonical shelf is Build → integrations because the skill documents binding-level usage of the PyOpenMS library inside application or analysis code rather than market or ops work. Integrations subphase reflects wrapping external scientific SDKs—MSExperiment, MSSpectrum, MzMLFile loaders—into reproducible agent-assisted scripts.
Common Questions / FAQ
Is Pyopenms safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Pyopenms
# Core Data Structures ## Overview PyOpenMS uses C++ objects with Python bindings. Understanding these core data structures is essential for effective data manipulation. ## Spectrum and Experiment Objects ### MSExperiment Container for complete LC-MS experiment data (spectra and chromatograms). ```python import pyopenms as ms # Create experiment exp = ms.MSExperiment() # Load from file ms.MzMLFile().load("data.mzML", exp) # Access properties print(f"Number of spectra: {exp.getNrSpectra()}") print(f"Number of chromatograms: {exp.getNrChromatograms()}") # Get RT range rts = [spec.getRT() for spec in exp] print(f"RT range: {min(rts):.1f} - {max(rts):.1f} seconds") # Access individual spectrum spec = exp.getSpectrum(0) # Iterate through spectra for spec in exp: if spec.getMSLevel() == 2: print(f"MS2 spectrum at RT {spec.getRT():.2f}") # Get metadata exp_settings = exp.getExperimentalSettings() instrument = exp_settings.getInstrument() print(f"Instrument: {instrument.getName()}") ``` ### MSSpectrum Individual mass spectrum with m/z and intensity arrays. ```python # Create empty spectrum spec = ms.MSSpectrum() # Get from experiment exp = ms.MSExperiment() ms.MzMLFile().load("data.mzML", exp) spec = exp.getSpectrum(0) # Basic properties print(f"MS level: {spec.getMSLevel()}") print(f"Retention time: {spec.getRT():.2f} seconds") print(f"Number of peaks: {spec.size()}") # Get peak data as numpy arrays mz, intensity = spec.get_peaks() print(f"m/z range: {mz.min():.2f} - {mz.max():.2f}") print(f"Max intensity: {intensity.max():.0f}") # Access individual peaks for i in range(min(5, spec.size())): # First 5 peaks print(f"Peak {i}: m/z={mz[i]:.4f}, intensity={intensity[i]:.0f}") # Precursor information (for MS2) if spec.getMSLevel() == 2: precursors = spec.getPrecursors() if precursors: precursor = precursors[0] print(f"Precursor m/z: {precursor.getMZ():.4f}") print(f"Precursor charge: {precursor.getCharge()}") print(f"Precursor intensity: {precursor.getIntensity():.0f}") # Set peak data new_mz = [100.0, 200.0, 300.0] new_intensity = [1000.0, 2000.0, 1500.0] spec.set_peaks((new_mz, new_intensity)) ``` ### MSChromatogram Chromatographic trace (TIC, XIC, or SRM transition). ```python # Access chromatogram from experiment for chrom in exp.getChromatograms(): print(f"Chromatogram ID: {chrom.getNativeID()}") # Get data rt, intensity = chrom.get_peaks() print(f" RT points: {len(rt)}") print(f" Max intensity: {intensity.max():.0f}") # Precursor info (for XIC) precursor = chrom.getPrecursor() print(f" Precursor m/z: {precursor.getMZ():.4f}") ``` ## Feature Objects ### Feature Detected chromatographic peak with 2D spatial extent (RT-m/z). ```python # Load features feature_map = ms.FeatureMap() ms.FeatureXMLFile().load("features.featureXML", feature_map) # Access individual feature feature = feature_map[0] # Core properties print(f"m/z: {feature.getMZ():.4f}") print(f"RT: {feature.getRT():.2f} seconds") print(f"Intensity: {feature.getIntensity():.0f}") print(f"Charge: {feature.getCharge()}") # Quality metrics print(f"Overall quality: {feature.getOverallQuality():.3f}") print(f"Width (RT): {feature.getWidth():.2f}") # Convex hull (spatial extent) hull = feature.getConvexHull() print(f"Hull points: {hull.getHullPoints().size()}") # Bounding box bbox = hull.getBoundingBox() print(f"RT range: {bbox.minPosition()[0]:.2f} - {bbox.maxPosition()[0]:.2f}") print(f"m/z range: {bbox.minPosition()[1]:.4f} - {bbox.maxPosition()[1]:.4f}") # Subordinate features (isotopes) subordinates = feature.getSubordinates() if subordinates: print(f"Isotopic features: {len(subordinates)}") for sub in subordinates: print(f" m/z: {sub.getMZ():.4f}, intensity: {sub.getIntensity():.0f}") # Metadata values if feature.metaValueExists("label"): label = feature.getMetaValue("label") print(f"Label: {label}") ``` ### FeatureMap Col