Conformance contract
openproteo-core ships a small conformance harness that codifies the
invariants every vendor source is expected to satisfy. The harness is
the same set of checks the vendor2mzml convert --validate flag
applies before writing mzML.
Invariants
Given an iterator of SpectrumRecord, the harness verifies, for
every record:
- Strictly increasing
index. Indices start at 0 and increment by 1 across the run. - Non-negative
retention_time_secand monotonically non-decreasing per-control-list (per scan trace within a vendor that interleaves traces). - Peak-array length agreement.
mz.len() == intensity.len(). For ion-mobility records,inv_mobility_per_peak, when present, has the same length. ms_level >= 1. No record may declare itself as level zero.- Sorted
mzper spectrum. The peak list is ascending inmz. Equalmzvalues are permitted (some vendors emit zero- intensity flanking points). - No NaN. Neither
mznorintensitycontains NaN; intensity is non-negative.
API
use openproteo_core::conformance::{assert_iter_invariants, assert_source_invariants};
assert_source_invariants(&mut src)consumes the source'siter_spectra()to completion and returnsOk(count)or the firstConformanceErrorencountered.assert_iter_invariants(iter)works against anyIntoIterator<Item = SpectrumRecord>- convenient when the vendor layer is not yet aSpectrumSource.
Errors
ConformanceError is a small enum with one variant per failure
class. Each variant carries the index of the offending spectrum and
a human-readable summary; the Display impl is what
vendor2mzml convert --validate prints before exiting with status 3.
Stability guarantee
The invariants listed here are part of the OpenProteo 0.x contract.
Adding new invariants is a semver-minor change (a previously-accepted
file may start failing); relaxing an invariant is a semver-major
change. The exact wording of Display is not part of the API.