| Title: | Native R Bindings and SIMD Dispatch for 'minibwa' |
|---|---|
| Description: | Provides native R bindings to the 'minibwa' genomic read aligner with raw-vector query input, external-pointer alignment batches, ALTREP column views, and an installed C API for downstream packages. The package builds staged Single Instruction Multiple Data ('SIMD') KSW backends and selects portable scalar, SSE4, or AVX2 code at runtime without global instruction-set compiler flags. |
| Authors: | Sounkou Mahamane Toure [aut, cre], Abiomix FZ LLC [cph, fnd] (Copyright holder and funder of Abiomix contributions), Dana-Farber Cancer Institute [cph] (Copyright holder of upstream minibwa), Ilya Grebnov [cph] (libsais copyright holder), N. Jesper Larsson [cph] (QSufSort copyright holder), Wong Chi Kwong [cph] (BWT-SW/bwtgen copyright holder) |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.4.0-0.0.1.9000 |
| Built: | 2026-07-13 12:23:33 UTC |
| Source: | https://github.com/abiomix/abiomix-r-open |
mb_align_col() returns ALTREP views over native alignment columns. These
views do not copy columns unless R forces materialization. mb_align_read_col()
returns ALTREP views over the read-level sidecar with one row per input read,
including reads without hits. C consumers should prefer the installed
Rminibwa.h API.
mb_align_n(x) mb_align_read_n(x) mb_align_col(x, name) mb_align_read_col(x, name) mb_align_cigar_words(x)mb_align_n(x) mb_align_read_n(x) mb_align_col(x, name) mb_align_read_col(x, name) mb_align_cigar_words(x)
x |
Native alignment batch returned by |
name |
Column name. Alignment columns include |
mb_align_n() returns the number of alignment records.
mb_align_read_n() returns the number of input reads represented in the
batch. mb_align_col() and mb_align_read_col() return ALTREP integer or
real vectors. mb_align_cigar_words() returns a raw debug copy of packed
minibwa CIGAR words.
mb_fastx_iter() opens one FASTA/FASTQ file, or two mate files, using the
vendored minibwa reader. mb_fastx_next() returns a native FASTX batch, and
mb_map_fastx_batch() maps that batch directly from native sequence buffers.
mb_fastx_iter( path, paired = c("auto", "none", "by_name", "two_file"), batch_bases = 100000000L, max_batch_bases = batch_bases, with_qual = FALSE, with_comment = FALSE ) mb_fastx_next(iter) mb_fastx_n(batch) mb_map_fastx_batch(batch, index, opt = mb_opts())mb_fastx_iter( path, paired = c("auto", "none", "by_name", "two_file"), batch_bases = 100000000L, max_batch_bases = batch_bases, with_qual = FALSE, with_comment = FALSE ) mb_fastx_next(iter) mb_fastx_n(batch) mb_map_fastx_batch(batch, index, opt = mb_opts())
path |
One FASTA/FASTQ path, or two paths for |
paired |
Pairing mode. |
batch_bases |
Approximate number of sequence bases to read per batch. |
max_batch_bases |
Maximum bases to read when extending a batch to keep a short paired fragment together. |
with_qual, with_comment
|
Preserve qualities/comments in the native batch. |
iter |
Native FASTX iterator returned by |
batch |
Native FASTX batch returned by |
index |
Index handle returned by |
opt |
Options list from |
Pairing modes follow the CLI reader shape: "none" treats each record as a
fragment, "by_name" groups adjacent records in one file with matching query
names, and "two_file" reads one record from each of two files per fragment.
"auto" selects "two_file" for two paths and "none" for one path.
mb_fastx_iter() returns a native iterator. mb_fastx_next() returns
a native FASTX batch or NULL at EOF. mb_fastx_n() returns the number of
records in a FASTX batch. mb_map_fastx_batch() returns a native alignment
batch.
Builds index files at prefix using the vendored minibwa C library. The
package is GPL, so the native build includes minibwa's GPL-compatible
low-memory indexing path; low_memory = FALSE uses the default libsais
path.
mb_index_build(fasta, prefix, meth = FALSE, threads = 1L, low_memory = FALSE)mb_index_build(fasta, prefix, meth = FALSE, threads = 1L, low_memory = FALSE)
fasta |
Reference FASTA path. Gzip-compressed input is supported by minibwa/zlib. |
prefix |
Output prefix for |
meth |
Build the directional methylation index as well. |
threads |
Number of index-build threads requested by minibwa. |
low_memory |
Use minibwa's low-memory BWT builder. |
prefix, invisibly.
Names are returned as raw byte vectors to avoid forced string materialization.
mb_index_contigs(index)mb_index_contigs(index)
index |
Index handle returned by |
A list with raw-vector name entries and numeric length values.
Load a native minibwa index
mb_index_load(prefix, meth = FALSE)mb_index_load(prefix, meth = FALSE)
prefix |
Index prefix. |
meth |
Load the methylation BWT index. |
An external pointer handle to a native minibwa index.
mb_map() is pipe-friendly: the sequence bytes are the first argument.
The result is a native alignment batch external pointer. Use mb_align_col()
for ALTREP column views or pass the batch to downstream C consumers.
mb_map(x, index, opt = mb_opts(), name = NULL, meth = c("none", "c2t", "g2a"))mb_map(x, index, opt = mb_opts(), name = NULL, meth = c("none", "c2t", "g2a"))
x |
Raw vector of query sequence bytes. |
index |
Index handle returned by |
opt |
Options list from |
name |
Optional read name as raw bytes. Character names are accepted for convenience but raw bytes are preferred. |
meth |
Methylation code: |
A native alignment batch external pointer.
# See vignettes for full index-backed examples.# See vignettes for full index-backed examples.
mb_map_batch() maps many reads in one native call and returns the same
columnar alignment-batch object as mb_map(). Input may be a character
vector of sequence bytes or a list whose elements are raw vectors or
character scalars. Unlike the CLI reader, this direct batch API defaults to
unpaired mapping unless opt = mb_opts(paired = TRUE). In paired mode, order
records as R1, R2, R1, R2, ...; this call pairs adjacent records and does
not group FASTQ records by name for you.
mb_map_batch(x, index, opt = mb_opts(), name = NULL)mb_map_batch(x, index, opt = mb_opts(), name = NULL)
x |
Character vector or list of raw vectors / character scalars. |
index |
Index handle returned by |
opt |
Options list from |
name |
Optional character vector of read names, or a list of raw vectors
/ character scalars. If supplied, it must have the same length as |
A native alignment batch external pointer.
mb_map_pair_batch() is the explicit two-batch paired-end interface. r1[i]
and r2[i] are flattened as adjacent records before mapping, matching the
two-file CLI layout. The read sidecar records fragment_id and mate.
mb_map_pair_batch(r1, r2, index, opt = mb_opts(), name1 = NULL, name2 = NULL)mb_map_pair_batch(r1, r2, index, opt = mb_opts(), name1 = NULL, name2 = NULL)
r1, r2
|
Character vectors or lists of raw vectors / character scalars. They must have the same non-zero length. |
index |
Index handle returned by |
opt |
Options list from |
name1, name2
|
Optional read-name vectors for |
A native alignment batch external pointer.
Returns a plain list consumed by native mapping functions. Only the selected options are exposed initially; all other fields use minibwa defaults for the chosen preset.
mb_opts( preset = c("adap", "sr", "lr"), paired = NULL, methylation = NULL, out_n = NULL, min_seed_len = NULL, threads = NULL, match_score = NULL, mismatch_penalty = NULL, gap_open = NULL, gap_extend = NULL )mb_opts( preset = c("adap", "sr", "lr"), paired = NULL, methylation = NULL, out_n = NULL, min_seed_len = NULL, threads = NULL, match_score = NULL, mismatch_penalty = NULL, gap_open = NULL, gap_extend = NULL )
preset |
One of |
paired, methylation
|
Optional logical overrides for minibwa flags. |
out_n, min_seed_len, threads, match_score, mismatch_penalty, gap_open, gap_extend
|
Optional integer overrides for common minibwa fields. |
A plain list.
Test whether the minibwa CLI is available
minibwa_available(path = NULL)minibwa_available(path = NULL)
path |
Optional executable name or path. When |
TRUE when an executable can be resolved, otherwise FALSE.
Low-level helper for invoking arbitrary minibwa commands from R. Prefer
minibwa_index() and minibwa_map() for common workflows.
minibwa_cli(args = character(), stdout = TRUE, path = minibwa_path())minibwa_cli(args = character(), stdout = TRUE, path = minibwa_path())
args |
Character vector of command-line arguments passed to |
stdout |
Passed to |
path |
Executable name or path. |
If stdout = TRUE, a character vector of captured output; otherwise
an invisible process status.
Build a minibwa index through the CLI
minibwa_index( reference, prefix = NULL, threads = NULL, meth = FALSE, low_memory = FALSE, extra_args = character(), path = minibwa_path() )minibwa_index( reference, prefix = NULL, threads = NULL, meth = FALSE, low_memory = FALSE, extra_args = character(), path = minibwa_path() )
reference |
Path to a FASTA reference. |
prefix |
Optional output prefix. When |
threads |
Optional number of worker threads. |
meth |
If |
low_memory |
If |
extra_args |
Additional CLI arguments inserted before positional arguments. |
path |
Executable name or path. |
Invisibly, the expected index prefix.
Map reads through the minibwa CLI
minibwa_map( index, reads, output = NULL, format = c("sam", "paf"), threads = NULL, meth = FALSE, hic = FALSE, extra_args = character(), path = minibwa_path() )minibwa_map( index, reads, output = NULL, format = c("sam", "paf"), threads = NULL, meth = FALSE, hic = FALSE, extra_args = character(), path = minibwa_path() )
index |
Index prefix produced by |
reads |
One or more FASTA/FASTQ input paths. The common cases are one single-end file or two paired-end files. |
output |
Optional output file. When |
format |
Output format: |
threads |
Optional number of worker threads. |
meth |
If |
hic |
If |
extra_args |
Additional CLI arguments inserted before positional arguments. |
path |
Executable name or path. |
If output = NULL, captured alignment records as a character vector;
otherwise the output path, invisibly.
minibwa_path() resolves the command-line executable used by the CLI-backed
helpers. By default it returns the executable built from the vendored minibwa
sources and installed with Rminibwa. Supplying path is mainly for developer
comparisons against another minibwa build.
minibwa_path(path = NULL, must_work = TRUE)minibwa_path(path = NULL, must_work = TRUE)
path |
Optional executable name or path. When |
must_work |
If |
A scalar character path, or NA_character_ when must_work = FALSE
and no executable is found.
Rminibwa pins a specific upstream minibwa commit for native-library work.
minibwa_upstream_info() reports the installed copy of that provenance
metadata.
minibwa_upstream_info()minibwa_upstream_info()
A named list with fields such as Component, Version,
Repository, Commit, and PatchDirectory.
minibwa_upstream_info()[c("Version", "Commit")]minibwa_upstream_info()[c("Version", "Commit")]
Report the minibwa CLI version
minibwa_version(path = minibwa_path())minibwa_version(path = minibwa_path())
path |
Optional executable name or path. When |
A scalar character version string.
Report the selected SIMD backend
simd_backend()simd_backend()
A character scalar.
Report SIMD dispatch diagnostics
simd_info()simd_info()
An object of class rminibwa_simd_info: a named list with dispatch
mode, requested backend, selected backend, compiled backends,
CPU-supported backends, available backends, and target.
Rminibwa compiles staged KSW backend objects and switches among them at
runtime. Use "auto" for the best available backend, or force one of
"scalar", "sse4", or "avx2" for diagnostics and benchmarks. The
"scalar" backend is the portable SIMDe baseline with native intrinsics
disabled; compilers may still lower portable vector types efficiently.
simd_set_backend(backend = "auto")simd_set_backend(backend = "auto")
backend |
Character scalar backend name. |
The selected backend, invisibly.