mapping_info
A lightweight Rust helper library for collecting, timing, logging and reporting mapping statistics in sequencing pipelines.
This crate is designed for:
- BAM processing tools
- Single-cell quantification workflows
- Multi-threaded pipelines
- Performance benchmarking
- Structured error reporting
Overview
MappingInfo is a structured statistics collector that tracks:
- Read filtering categories
- Cell/gene assignment success
- PCR duplicates
- Multi-mappers
- Error types
- Per-category read logs
- Histogram counters
- Detailed timing measurements
- File I/O vs CPU vs subprocess time
The recommended modern usage pattern is centered around:
mapping_info.report;
Installation
= { = "https://github.com/stela2502/mapping_info" }
Basic Usage
Create a MappingInfo instance
use MappingInfo;
use File;
let logfile = create.ok;
let mut info = new;
Error Reporting (Recommended)
Modern usage should rely on the flexible report() API.
info.report;
info.report;
info.report;
Retrieve counts:
let n = info.get_issue_count;
Export as:
CSV file
info.report_to_csv;
String (tab-separated)
println!;
Built-in Read Counters
MappingInfo tracks structured counters:
qualitylengthn_spoly_ano_sampleno_dataok_readscellular_readsmultimapperpcr_duplicates
Additionally, you can register custom read types:
info.iter_read_type;
info.iter_read_type;
And print formatted summaries:
println!;
Timing Measurements
MappingInfo contains structured timing support.
Categories
single_processor_timemulti_processor_timefile_io_timesubprocess_time- total runtime
Example
info.start_counter;
// do work
info.stop_single_processor_time;
Split elapsed time:
let = info.elapsed_time_split;
Human-readable timing summary:
println!;
Logging Functionality
MappingInfo supports structured logging to file.
Create with log file
let file = create.ok;
let mut info = new;
Write arbitrary log line
info.write_to_log;
Log report table
info.log_report;
Periodic Progress Logging
Designed to work with indicatif::ProgressBar:
use ProgressBar;
let pb = new;
info.total += 1;
info.log;
This logs every split reads (default: 1,000,000).
Histogram Support
info.iterate_hist;
Internally maintains a fixed-size histogram vector.
Merging Results
Designed for multi-threaded aggregation:
info.merge;
This merges:
- Counters
- Error reports
- Histograms
- Read logs
Full Summary Output
let summary = info.summary;
println!;
Outputs:
- Read breakdown
- Filter reasons
- UMI statistics
- PCR duplicates
- Detailed timing
- Automatically writes to log file (if enabled)
When To Use mapping_info
✔ BAM parsing tools
✔ Single-cell quantifiers
✔ High-performance Rust pipelines
✔ Benchmarking Rust vs Python tools
✔ Reproducible run summaries
✔ HPC logging
Design Goals
- Zero heavy dependencies
- Deterministic aggregation
- Thread-safe merge model
- Explicit timing separation
- Human-readable summaries
- Machine-readable exports
Author
Stefan Lang
Bioinformatics / Single-Cell Systems