Skip to main content

mzML export

OpenSZRaw doesn't ship a dedicated export binary yet, but since Reader implements openmassspec_core::SpectrumSource, it can be written to mzML using the same writer every reader in the OpenMassSpec stack uses, so output is consistent across vendors:

use openszraw::reader::Reader;
use openmassspec_core::write_mzml;

let mut reader = Reader::open("sample.lcd")?;
let mut out = std::fs::File::create("output.mzML")?;
write_mzml(&mut reader, &mut out)?;

write_mzml stops at the first spectrum that cannot be decoded and returns its error. To write the rest and count the failures instead, use write_mzml_with_options with RecordErrorPolicy::Skip and check the returned WriteSummary.

write_mzml iterates the reader's spectra via SpectrumSource (the same stream described in Reader) and emits PSI-MS CV-annotated mzML, with the source-file-format and instrument CV terms varying by variant (MS:1003009 "Shimadzu Biotech LCD format" for both .lcd variants; the generic MS:1000560 "mass spectrometer file format" node for .qgd, since no PSI-MS CV term dedicated to .qgd exists yet). Given the current reader limitations (QTOF m/z wrong, IT-TOF m/z not validated, IT-TOF MS level not decoded, no QTOF MS2 precursor m/z, no polarity), exported mzML will carry those same gaps until the underlying fields are decoded.