Exact shortest-path distances between positions of a bidirected pangenome graph.
biopath builds an index of a graph (GFA or GBZ) once, saves it as a .bpi file, and answers
distance queries from that file alone. Every answer equals a whole-graph Dijkstra search. Linux
only.
A prebuilt Linux x86_64 binary is on the
Releases page: unpack it and run
./biopath --help.
To build from source, you need Linux, rustup and a C linker (cc). The
pinned Rust version is downloaded on the first build.
git clone https://github.com/algbio/biopath
cd biopath
cargo build --release # → target/release/biopath# build the index once per graph (use --graph-gbz-in for a GBZ)
biopath index --graph-gfa-in graph.gfa --index-out graph.bpi
# answer a file of queries from the index
biopath query --index-in graph.bpi --query-in q.tsv --query-out out.tsvq.tsv has one query per line, tab-separated: a source and a target position, each written as
node orientation offset. out.tsv repeats each query's six columns and adds the distance in
bases (None if unreachable).
With the small BRCA2 graph in the repository:
BIN=./target/release/biopath
GFA=tests/golden/graphs/cactus-BRCA2.gfa
# 1. build the index
$BIN index --graph-gfa-in $GFA --index-out brca2.bpi
# 2. write four queries: a source position, then a target position
# (each position is: node orientation offset; tr turns the spaces into tabs)
tr -s ' ' '\t' > q.tsv <<'EOF'
1 + 0 100 + 5
1 + 0 1000 + 0
500 - 3 1 - 0
1 - 0 1 + 0
EOF
# 3. answer them
$BIN query --index-in brca2.bpi --query-in q.tsv --query-out out.tsv
cat out.tsv1 + 0 100 + 5 7276
1 + 0 1000 + 0 74649
500 - 3 1 - 0 39006
1 - 0 1 + 0 None
Each line is the query followed by its distance in bases. The last query is unreachable: no walk
leads from node 1 read backwards to node 1 read forwards.
biopath <command> --help lists all options. USAGE.md is the full reference (input
requirements, file formats, all subcommands); ARCHITECTURE.md explains how the
index works.
24 chromosome graphs of the HPRC v2.1 GRCh38 .full pangenome, 5,000 queries per graph, compared
with the distance index of vg 1.77 (all answers agree):
| biopath | vg 1.77 | |
|---|---|---|
| query time, p50 / p99 | 1.0 / 6.3 µs | 6.8 / 34.1 µs |
| index size, all 24 graphs | 2.9 GB | 48.0 GB |
| peak build memory, chr1 | 6.7 GB | 52.0 GB |
MIT (LICENSE). The vendored spqr-tree crate (BSD-2-Clause) and the test graphs from vg (MIT) keep their own licenses.