Skip to content

Turn any AI agent into an AI Scientist. The #1 Agent Skills library for science, used by 250,000+ scientists worldwide. 177 ready-to-use validated skills plus 100+ scientific databases covering biology, chemistry, medicine, and drug discovery. Compatible with Cursor, Claude Code, Codex, Pi, Antigravity, and the open Agent Skills standard.

1.0 KB
Raw Blame
"""Input checks shared by the two centroided feature detectors."""
import pyopenms as ms


def centroided_ms1(exp, assume_centroided=False):
    """Copy only MS1 scans, require centroid metadata, and sort RT/m/z."""
    selected = []
    for spec in exp:
        if spec.getMSLevel() != 1:
            continue
        kind = spec.getType()
        if kind == ms.SpectrumSettings.SpectrumType.PROFILE:
            raise ValueError("Feature detection requires centroided MS1; peak-pick profile data first.")
        if kind == ms.SpectrumSettings.SpectrumType.UNKNOWN and not assume_centroided:
            raise ValueError("MS1 spectrum type is unknown; verify acquisition/conversion and use --assume-centroided only when justified.")
        selected.append(spec)
    if not selected:
        raise ValueError("No MS1 spectra available for feature detection.")
    result = ms.MSExperiment(exp)
    result.setSpectra(selected)
    result.setChromatograms([])
    result.sortSpectra(True)
    result.updateRanges()
    return result