$ show lazear/sage
Sage is a high-performance proteomics database search engine implemented in Rust. It identifies peptides from tandem mass spectra by performing in silico digestion of a protein database (FASTA) and matching theoretical fragment ions to observed spectra. The system supports multiple input formats (mzML, MGF, Bruker TDF) and provides comprehensive quantification capabilities including isobaric labeling (TMT) and label-free quantification (LFQ). It also includes retention time prediction, ion mobility prediction, and statistical validation through linear discriminant analysis and false discovery rate control. The architecture is organized as a Cargo workspace with three crates: `sage` (core library), `sage-cli` (command-line interface), and `sage-cloudpath` (cloud storage abstraction). The CLI entry point in `sage-cli/src/main.rs` parses a JSON configuration file and invokes the `Runner` to orchestrate the search pipeline. The core library handles database construction (digestion, indexing, fragment generation), spectrum processing (deisotoping, charge deconvolution), scoring (X!Tandem hyperscore variants), and machine learning (LDA rescoring, KDE for posterior error probability, retention time alignment). Quantification modules extract ion chromatograms for LFQ and reporter ions for TMT. Key data flows: raw spectra and FASTA database are read (optionally from cloud storage), peptides are generated in silico with variable modifications, fragment ions are indexed and matched to spectra, PSMs are scored and rescored with LDA, FDR is controlled via picked-peptide and picked-protein methods, and results are output as TSV, Parquet, or PIN files. The system is designed for parallel execution using Rayon and can process large datasets efficiently. External dependencies include the `timsrust` library for Bruker TDF files, `object_store` for cloud storage access, and standard Rust crates for compression and serialization. The cloudpath crate provides a uniform interface for reading/writing data from local files, S3, GCS, and Azure, with automatic gzip handling.
The LLM identified 4 files worth highlighting for reuse:
Provides a unified interface for reading and writing files from cloud storage (S3, GCS, Azure) and the local filesystem, with automatic gzip decompression. Uses the `object_store` crate and supports URL-based paths. Can be extracted and used in any Rust project needing cloud file access without modification.
Implements an efficient bounded min-heapify algorithm to select the top-k elements from a collection without sorting the entire set. Useful for any application requiring ranking or selection of best matches, such as search results or nearest neighbors. Self-contained and dependency-free.
Provides a generic Matrix implementation with parallelized dot product operations and a Gauss-Jordan elimination solver for linear systems (in `gauss.rs`). Designed for performance with Rayon parallelism. Can be reused in any Rust project requiring basic linear algebra operations without external dependencies.
Implements a non-parametric kernel density estimator using pre-computed bins and linear interpolation for fast evaluation. Used for peptide probability estimation but applicable to any one-dimensional density estimation problem. Self-contained and efficient.