Skip to main content

build_spectral_library_tsv

Function build_spectral_library_tsv 

Source
pub fn build_spectral_library_tsv(
    out_path: &Path,
    modified_sequences: &[String],
    modpep_diann: &[String],
    stripped: &[String],
    charges: &[i32],
    prosit_flat: &[f64],
    n_cols: usize,
    precursor_mz: &[f64],
    retention_time: &[f64],
    protein_ids: &[String],
    genes: &[String],
    min_fragments: usize,
    append: bool,
) -> Result<(usize, usize)>
Expand description

Decode one batch of peptides (parallel) and write/append their transitions to out_path as a DiaNN-style .tsv.

Per precursor: b/y ions are read off the reshaped Prosit array, intensities are renormalised to max=1, non-finite / non-positive intensities and m/z are dropped, and a precursor with fewer than min_fragments surviving fragments is skipped entirely (it emits no rows). Returns (transitions_written, precursors_written).

prosit_flat is row-major: peptide i’s vector is prosit_flat[i*n_cols..(i+1)*n_cols]. All metadata slices must have the same length (the peptide count); n_cols is the Prosit vector width (174). With append=false the file is truncated and the header written first; with append=true rows are appended (no header) — for chunked builds.