"""Integrate peaks in a table that already contains peak boundaries."""

from pathlib import Path

import emzed

peaks = emzed.io.load_table(Path("data") / "peaks.table")

# integrate() expects peak-table columns:
# id, mzmin, mzmax, rtmin, rtmax, peakmap
# Available models include: linear, emg, asym_gauss, sgolay, no_integration.
# The linear model integrates the piecewise-linear interpolation of the
# chromatogram, which is equivalent to the trapezoidal rule.
integrated = emzed.quantification.integrate(
    peaks,
    "linear",
    show_progress=False,
)

print("columns:")
for name in integrated.col_names:
    print(f"  - {name}")
print()

# Format None hides object-heavy columns in printed output and inspectors;
# data is still present and formats can be changed back later if required.
integrated.set_col_format("peakmap", None)
integrated.set_col_format("model", None)
print(integrated)
