Extracting subsets¶
When you only need some of the spectra, push the filter into the extractor so the C core skips the rest. Faster than reading them all and discarding.
By index¶
Ranges work too:
By scan number¶
By MS level¶
Combining filters¶
Filters are AND-combined — only spectra matching all active selectors are emitted.
Streaming extraction¶
For very large output sets, write incrementally:
Each yielded chunk is a bytes of valid mzML fragments; the streaming
form never materializes the full output in memory.
Why this is fast on MSZ¶
MSZ's footer records exactly which block each spectrum lives in. The extractor:
- Resolves the selector to a list of indices.
- Looks up each index's block address.
- Decompresses only the blocks that contain at least one selected spectrum (with caching so a block decompresses once even if multiple selected spectra share it).
Cost is O(selected spectra), not O(file size). Extracting 100 MS2 spectra from a 50 GB MSZ takes milliseconds.