Skip to main content

Crate psltools

Crate psltools 

Source
Expand description

§psltools

A high-performance library and CLI for the PSL alignment format (BLAT/lastz output), modeled on chaintools.

§Design

  • Zero-copy parsing. Names and PSLx sequence columns are ByteSlice views into a shared (memory-mapped or owned) buffer; the three block coordinate lists live in one structure-of-arrays arena. The whole-file Reader allocates nothing per record.
  • One record per line. Unlike chain, a PSL record is a single line, so parsing chunks in parallel, indexing, and streaming are all simple.
  • Kent-exact scoring. psl_score / milli_bad / percent_id reproduce kent/src/lib/psl.c bit-for-bit (including repMatch >> 1, sizeMul derivation, and i32 integer semantics).
  • Correctness on the hard corners. Negative-strand qStarts/tStarts, translated (two-char) strands, and PSLx sequence columns are handled in the model from the start.

§Quick start

use psltools::Reader;

let reader = Reader::<psltools::Psl>::from_path("example.psl")?;
for psl in reader.records() {
    println!(
        "{} -> {}  score={}",
        psl.query_name_str(),
        psl.reference_name_str(),
        psl.score()
    );
}

§Feature flags

  • mmap (default): memory-map inputs for zero-copy parsing.
  • cli (default): build the psltools binary (implies parallel).
  • gzip: transparently read/write .gz PSL.
  • parallel: multi-threaded parsing and parallel record iteration.
  • index: record-offset and interval indexes.
  • serde: derive Serialize/Deserialize on the owned types.
  • bigcoords: widen Coord to u64 for exotic assemblies.

Re-exports§

pub use model::Coord;
pub use model::block::Block;
pub use model::block::BlockSlice;
pub use model::block::Blocks;
pub use model::error::PslError;
pub use model::psl::Psl;
pub use model::psl::PslFlavor;
pub use model::psl::PslRecord;
pub use model::psl::PslxSeq;
pub use model::psl::Strand;
pub use model::psl::Strands;
pub use io::reader::Reader;
pub use io::reader::ReaderOptions;
pub use io::storage::ByteSlice;
pub use io::storage::SharedBytes;
pub use io::stream::OwnedBlocks;
pub use io::stream::OwnedPsl;
pub use io::stream::OwnedPslHeader;
pub use io::stream::StreamItem;
pub use io::stream::StreamingReader;
pub use io::writer::PslWriter;
pub use io::writer::write_psl;
pub use io::writer::write_psl_header;
pub use ops::check::CheckReport;
pub use ops::check::check;
pub use ops::convert::to_bed;
pub use ops::convert::to_bed12;
pub use ops::convert::to_genepred;
pub use ops::score::ScoreOpts;
pub use ops::score::milli_bad;
pub use ops::score::percent_id;
pub use ops::score::psl_score;
pub use ops::swap::swap;
pub use ops::swap::swap_with;
pub use genepred;

Modules§

io
PSL input/output.
model
Core PSL data model.
ops
Record-level operations shared by library users and the CLI.
parser
PSL parsing primitives.