library(ompBAM)
# Create a new package template that compiles with ompBAM
pkg_path <- file.path(tempdir(), "MyPkg")
use_ompBAM(pkg_path)
# Retrieve the path to an example BAM file provided by the package
bam_path <- ompBAM::example_BAM("Unsorted")
Input: A destination directory path for the new package. Output: A fully configured R package directory structure containing C++ templates and configuration files linked to ompBAM.
When to Use
Developing R packages that require high-performance, multi-threaded processing of BAM files using C++ and OpenMP.
Writing custom BAM parsing algorithms where you want ompBAM to handle file access, BGZF decompression, and thread management.
Creating packages that need to run on unsorted and unindexed BAM files (e.g., using pbam_in and pbam1_t APIs).
When NOT to Use
For standard BAM manipulation or filtering in R without writing C++ code; use Rsamtools or GenomicAlignments instead.
For querying small genomic regions of sorted and indexed BAM files; use htslib directly as ompBAM is optimized for whole-file sequential reads.
Data Requirements
Input BAM files (can be unsorted and unindexed).
A package development environment with Rcpp and a C++ compiler supporting OpenMP (e.g., gcc or clang with OpenMP libraries).
Key Parameters
path (in use_ompBAM): The directory path where the new package project will be created.
bam_file: Path to the BAM file to be processed.
n_threads: Number of threads to use for parallel execution.
Best Practices
Run devtools::document() on the newly created package to generate the NAMESPACE and export the R wrapper functions.
Use the #ifdef _OPENMP directive in C++ code to ensure compatibility with systems that do not have OpenMP installed (such as default macOS configurations).
Call pbam1_t::realize() if you need to store reads in memory across multiple calls of pbam_in::fillReads(), as virtual reads point to temporary buffers.
Common Pitfalls
macOS Compilation Failure: macOS does not support OpenMP natively. Fix: Install libomp via Homebrew (brew install libomp) and configure compiler flags.
Memory Corruption with Virtual Reads: Accessing pbam1_t objects after calling fillReads() leads to segmentation faults. Fix: Call realize() on the pbam1_t object to copy the data into persistent memory.
Requesting Too Many Threads: Requesting more threads than available can degrade performance. Fix: Use a helper function to cap requested threads at omp_get_max_threads().
Alternatives
Rsamtools: For high-level BAM file manipulation and querying in R.
GenomicAlignments: For representing and manipulating genomic alignments in R.
Rcpp: For general C++ integration in R packages without built-in BAM parsing support.
1---2name: ompbam3description: ompBAM4---56# ompBAM78## Workflows910### Standard Workflow1112```r13library(ompBAM)1415# Create a new package template that compiles with ompBAM16pkg_path <- file.path(tempdir(), "MyPkg")17use_ompBAM(pkg_path)1819# Retrieve the path to an example BAM file provided by the package20bam_path <- ompBAM::example_BAM("Unsorted")21```22*Input:* A destination directory path for the new package. 23*Output:* A fully configured R package directory structure containing C++ templates and configuration files linked to `ompBAM`.2425## When to Use26- Developing R packages that require high-performance, multi-threaded processing of BAM files using C++ and OpenMP.27- Writing custom BAM parsing algorithms where you want `ompBAM` to handle file access, BGZF decompression, and thread management.28- Creating packages that need to run on unsorted and unindexed BAM files (e.g., using `pbam_in` and `pbam1_t` APIs).2930## When NOT to Use31- For standard BAM manipulation or filtering in R without writing C++ code; use `Rsamtools` or `GenomicAlignments` instead.32- For querying small genomic regions of sorted and indexed BAM files; use `htslib` directly as `ompBAM` is optimized for whole-file sequential reads.3334## Data Requirements35- Input BAM files (can be unsorted and unindexed).36- A package development environment with `Rcpp` and a C++ compiler supporting OpenMP (e.g., `gcc` or `clang` with OpenMP libraries).3738## Key Parameters39- **path** (in `use_ompBAM`): The directory path where the new package project will be created.40- **bam_file**: Path to the BAM file to be processed.41- **n_threads**: Number of threads to use for parallel execution.4243## Best Practices44- Run `devtools::document()` on the newly created package to generate the `NAMESPACE` and export the R wrapper functions.45- Use the `#ifdef _OPENMP` directive in C++ code to ensure compatibility with systems that do not have OpenMP installed (such as default macOS configurations).46- Call `pbam1_t::realize()` if you need to store reads in memory across multiple calls of `pbam_in::fillReads()`, as virtual reads point to temporary buffers.4748## Common Pitfalls49- **macOS Compilation Failure**: macOS does not support OpenMP natively. Fix: Install `libomp` via Homebrew (`brew install libomp`) and configure compiler flags.50- **Memory Corruption with Virtual Reads**: Accessing `pbam1_t` objects after calling `fillReads()` leads to segmentation faults. Fix: Call `realize()` on the `pbam1_t` object to copy the data into persistent memory.51- **Requesting Too Many Threads**: Requesting more threads than available can degrade performance. Fix: Use a helper function to cap requested threads at `omp_get_max_threads()`.5253## Alternatives54- **Rsamtools**: For high-level BAM file manipulation and querying in R.55- **GenomicAlignments**: For representing and manipulating genomic alignments in R.56- **Rcpp**: For general C++ integration in R packages without built-in BAM parsing support.5758## Citations59- Alex C H Wong (2026). ompBAM API Documentation.6061## References62- Homepage: https://bioconductor.org/packages/ompbam63- Vignette: https://bioconductor.org/packages/release/bioc/vignettes/ompbam/inst/doc/ompBAM-API-Docs.html
Run npx skillmds@latest add biomate-ai/ompbam in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
ompBAM It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
biomate-ai (@biomate-ai) published this skill. Their other Agent Skills are listed on their SkillMD profile.